[PATCH 2/2] fs: Move check for mappings without pages from iterate_bdevs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, iterate_bdevs() skips block devices without any pages in page
cache. That is fine for current use by sync(2) but may be rather surprising
for possible future users. So move the checks from iterate_bdevs() to
callback functions used by sync(2).

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 fs/block_dev.c |    3 +--
 fs/sync.c      |   12 ++++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 220391c..ad31709 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1727,8 +1727,7 @@ void iterate_bdevs(void (*func)(struct block_device *, void *), void *arg)
 		 * With i_lock we can safely check bdev isn't freeing and
 		 * grab our reference.
 		 */
-		if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW) ||
-		    inode->i_mapping->nrpages == 0) {
+		if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) {
 			spin_unlock(&inode->i_lock);
 			continue;
 		}
diff --git a/fs/sync.c b/fs/sync.c
index eb8722d..536a272 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -81,12 +81,20 @@ static void sync_fs_one_sb(struct super_block *sb, void *arg)
 
 static void fdatawrite_one_bdev(struct block_device *bdev, void *arg)
 {
-	filemap_fdatawrite(bdev->bd_inode->i_mapping);
+	struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+	if (mapping->nrpages == 0)
+		return;
+	filemap_fdatawrite(mapping);
 }
 
 static void fdatawait_one_bdev(struct block_device *bdev, void *arg)
 {
-	filemap_fdatawait(bdev->bd_inode->i_mapping);
+	struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+	if (mapping->nrpages == 0)
+		return;
+	filemap_fdatawait(mapping);
 }
 
 /*
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux