]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
writeback: fix pin_sb_for_writeback
authorChristoph Hellwig <hch@lst.de>
Wed, 9 Jun 2010 13:31:01 +0000 (15:31 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 11 Jun 2010 10:58:08 +0000 (12:58 +0200)
We need to check for s_instances to make sure we don't bother working
against a filesystem that is beeing unmounted, and we need to call
put_super to make sure a superblock is freed when we race against
umount.  Also no need to keep sb_lock after we got a reference on it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fs/fs-writeback.c

index 3a066e91ec8d3762802db3b870362f2fd17fc842..0609607d395591ad5b23ee52283ad25c85e2bc10 100644 (file)
@@ -534,19 +534,21 @@ select_queue:
 static bool pin_sb_for_writeback(struct super_block *sb)
 {
        spin_lock(&sb_lock);
+       if (list_empty(&sb->s_instances)) {
+               spin_unlock(&sb_lock);
+               return false;
+       }
+
        sb->s_count++;
+       spin_unlock(&sb_lock);
+
        if (down_read_trylock(&sb->s_umount)) {
-               if (sb->s_root) {
-                       spin_unlock(&sb_lock);
+               if (sb->s_root)
                        return true;
-               }
-               /*
-                * umounted, drop rwsem again and fall through to failure
-                */
                up_read(&sb->s_umount);
        }
-       sb->s_count--;
-       spin_unlock(&sb_lock);
+
+       put_super(sb);
        return false;
 }