diff options
author | Christoph Hellwig <hch@lst.de> | 2010-06-09 09:31:01 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-06-11 06:58:08 -0400 |
commit | 29cb48594b873f6193d6327097e504bd3e2314de (patch) | |
tree | 1c93364fd70d93d42c6749c261f96f84a66d71e2 /fs | |
parent | 334132ae921a14ac2b2ba48e174136f7f2c9aae1 (diff) |
writeback: fix pin_sb_for_writeback
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs-writeback.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 3a066e91ec8d..0609607d3955 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -534,19 +534,21 @@ select_queue: | |||
534 | static bool pin_sb_for_writeback(struct super_block *sb) | 534 | static bool pin_sb_for_writeback(struct super_block *sb) |
535 | { | 535 | { |
536 | spin_lock(&sb_lock); | 536 | spin_lock(&sb_lock); |
537 | if (list_empty(&sb->s_instances)) { | ||
538 | spin_unlock(&sb_lock); | ||
539 | return false; | ||
540 | } | ||
541 | |||
537 | sb->s_count++; | 542 | sb->s_count++; |
543 | spin_unlock(&sb_lock); | ||
544 | |||
538 | if (down_read_trylock(&sb->s_umount)) { | 545 | if (down_read_trylock(&sb->s_umount)) { |
539 | if (sb->s_root) { | 546 | if (sb->s_root) |
540 | spin_unlock(&sb_lock); | ||
541 | return true; | 547 | return true; |
542 | } | ||
543 | /* | ||
544 | * umounted, drop rwsem again and fall through to failure | ||
545 | */ | ||
546 | up_read(&sb->s_umount); | 548 | up_read(&sb->s_umount); |
547 | } | 549 | } |
548 | sb->s_count--; | 550 | |
549 | spin_unlock(&sb_lock); | 551 | put_super(sb); |
550 | return false; | 552 | return false; |
551 | } | 553 | } |
552 | 554 | ||