vfs: Move noop_backing_dev_info check from sync into writeback
authorJan Kara <jack@suse.cz>
Tue, 3 Jul 2012 14:45:27 +0000 (16:45 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 22 Jul 2012 19:58:18 +0000 (23:58 +0400)
In principle, a filesystem may want to have ->sync_fs() called during sync(1)
although it does not have a bdi (i.e. s_bdi is set to noop_backing_dev_info).
Only writeback code really needs bdi set to something reasonable. So move the
checks where they are more logical.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/fs-writeback.c
fs/sync.c

index 41a3ccff18d87bdfc3f65148e2f39f8067f3a8ce..8f660dd6137a1105ba648e1a1412ffc5900c1233 100644 (file)
@@ -1315,6 +1315,8 @@ void writeback_inodes_sb_nr(struct super_block *sb,
                .reason                 = reason,
        };
 
+       if (sb->s_bdi == &noop_backing_dev_info)
+               return;
        WARN_ON(!rwsem_is_locked(&sb->s_umount));
        bdi_queue_work(sb->s_bdi, &work);
        wait_for_completion(&done);
@@ -1398,6 +1400,9 @@ void sync_inodes_sb(struct super_block *sb)
                .reason         = WB_REASON_SYNC,
        };
 
+       /* Nothing to do? */
+       if (sb->s_bdi == &noop_backing_dev_info)
+               return;
        WARN_ON(!rwsem_is_locked(&sb->s_umount));
 
        bdi_queue_work(sb->s_bdi, &work);
index 11e3d1c449018dcf9a95c352746f46d6522c4cb2..b3d2a001293f429b980141d680e555b26309dd2b 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
  */
 static int __sync_filesystem(struct super_block *sb, int wait)
 {
-       /*
-        * This should be safe, as we require bdi backing to actually
-        * write out data in the first place
-        */
-       if (sb->s_bdi == &noop_backing_dev_info)
-               return 0;
-
        if (sb->s_qcop && sb->s_qcop->quota_sync)
                sb->s_qcop->quota_sync(sb, -1, wait);