fix get_active_super()/umount() race
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 23 Mar 2010 00:15:33 +0000 (20:15 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 May 2010 22:31:15 +0000 (18:31 -0400)
This one needs restarts...

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

index 4df8233dfb61fa28b6d18611fdbb23ed93b607cf..44971d7df1cecc47ca33d8320b26c1bb6f4b7bd7 100644 (file)
@@ -471,17 +471,17 @@ struct super_block *get_active_super(struct block_device *bdev)
        if (!bdev)
                return NULL;
 
+restart:
        spin_lock(&sb_lock);
        list_for_each_entry(sb, &super_blocks, s_list) {
                if (list_empty(&sb->s_instances))
                        continue;
-               if (sb->s_bdev != bdev)
-                       continue;
-
-               if (grab_super(sb)) /* drops sb_lock */
-                       return sb;
-
-               spin_lock(&sb_lock);
+               if (sb->s_bdev == bdev) {
+                       if (grab_super(sb)) /* drops sb_lock */
+                               return sb;
+                       else
+                               goto restart;
+               }
        }
        spin_unlock(&sb_lock);
        return NULL;