]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
fix prune_dcache()/umount() race
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 23 Mar 2010 00:27:55 +0000 (20:27 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 May 2010 22:31:16 +0000 (18:31 -0400)
... and get rid of the last __put_super_and_need_restart() caller

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index 5afc4994bb278621864457e317bcf47f2b5932ea..d96047b4a633a86cb7ae711cb29362ac6cda061a 100644 (file)
@@ -536,7 +536,7 @@ restart:
  */
 static void prune_dcache(int count)
 {
-       struct super_block *sb;
+       struct super_block *sb, *n;
        int w_count;
        int unused = dentry_stat.nr_unused;
        int prune_ratio;
@@ -545,13 +545,12 @@ static void prune_dcache(int count)
        if (unused == 0 || count == 0)
                return;
        spin_lock(&dcache_lock);
-restart:
        if (count >= unused)
                prune_ratio = 1;
        else
                prune_ratio = unused / count;
        spin_lock(&sb_lock);
-       list_for_each_entry(sb, &super_blocks, s_list) {
+       list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
                if (list_empty(&sb->s_instances))
                        continue;
                if (sb->s_nr_dentry_unused == 0)
@@ -592,14 +591,10 @@ restart:
                }
                spin_lock(&sb_lock);
                count -= pruned;
-               /*
-                * restart only when sb is no longer on the list and
-                * we have more work to do.
-                */
-               if (__put_super_and_need_restart(sb) && count > 0) {
-                       spin_unlock(&sb_lock);
-                       goto restart;
-               }
+               __put_super(sb);
+               /* more work left to do? */
+               if (count <= 0)
+                       break;
        }
        spin_unlock(&sb_lock);
        spin_unlock(&dcache_lock);