aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-03-22 20:27:55 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-05-21 18:31:16 -0400
commit79893c17b45dec0d3c25bc22d28d9f319b14f573 (patch)
tree560c5f13193cbb1e2d2bf5dc1fd6f25d49c01165 /fs
parentdf40c01a9249873e4ad0625ae5d9fb831962b75c (diff)
fix prune_dcache()/umount() race
... and get rid of the last __put_super_and_need_restart() caller Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 5afc4994bb27..d96047b4a633 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -536,7 +536,7 @@ restart:
536 */ 536 */
537static void prune_dcache(int count) 537static void prune_dcache(int count)
538{ 538{
539 struct super_block *sb; 539 struct super_block *sb, *n;
540 int w_count; 540 int w_count;
541 int unused = dentry_stat.nr_unused; 541 int unused = dentry_stat.nr_unused;
542 int prune_ratio; 542 int prune_ratio;
@@ -545,13 +545,12 @@ static void prune_dcache(int count)
545 if (unused == 0 || count == 0) 545 if (unused == 0 || count == 0)
546 return; 546 return;
547 spin_lock(&dcache_lock); 547 spin_lock(&dcache_lock);
548restart:
549 if (count >= unused) 548 if (count >= unused)
550 prune_ratio = 1; 549 prune_ratio = 1;
551 else 550 else
552 prune_ratio = unused / count; 551 prune_ratio = unused / count;
553 spin_lock(&sb_lock); 552 spin_lock(&sb_lock);
554 list_for_each_entry(sb, &super_blocks, s_list) { 553 list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
555 if (list_empty(&sb->s_instances)) 554 if (list_empty(&sb->s_instances))
556 continue; 555 continue;
557 if (sb->s_nr_dentry_unused == 0) 556 if (sb->s_nr_dentry_unused == 0)
@@ -592,14 +591,10 @@ restart:
592 } 591 }
593 spin_lock(&sb_lock); 592 spin_lock(&sb_lock);
594 count -= pruned; 593 count -= pruned;
595 /* 594 __put_super(sb);
596 * restart only when sb is no longer on the list and 595 /* more work left to do? */
597 * we have more work to do. 596 if (count <= 0)
598 */ 597 break;
599 if (__put_super_and_need_restart(sb) && count > 0) {
600 spin_unlock(&sb_lock);
601 goto restart;
602 }
603 } 598 }
604 spin_unlock(&sb_lock); 599 spin_unlock(&sb_lock);
605 spin_unlock(&dcache_lock); 600 spin_unlock(&dcache_lock);