]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Btrfs: close all bdevs on mount failure
authorIlya Dryomov <idryomov@gmail.com>
Wed, 19 Oct 2011 21:06:20 +0000 (00:06 +0300)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:45 +0000 (21:20 -0500)
Fix a bug introduced by 20b45077.  We have to return EINVAL on mount
failure, but doing that too early in the sequence leaves all of the
devices opened exclusively.  This also fixes an issue where under some
scenarios only a second mount -o degraded <devices> command would
succeed.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 20bcd64934e4eb8f3f90a0dca54fb0ac2edd7795)

fs/btrfs/volumes.c

index 031e7dc3927d8dd339e1068d97bf53ae54c0306f..068beed5aed9438e74784a1106829692c032b5a9 100644 (file)
@@ -605,10 +605,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                set_blocksize(bdev, 4096);
 
                bh = btrfs_read_dev_super(bdev);
-               if (!bh) {
-                       ret = -EINVAL;
+               if (!bh)
                        goto error_close;
-               }
 
                disk_super = (struct btrfs_super_block *)bh->b_data;
                devid = btrfs_stack_device_id(&disk_super->dev_item);
@@ -663,7 +661,7 @@ error:
                continue;
        }
        if (fs_devices->open_devices == 0) {
-               ret = -EIO;
+               ret = -EINVAL;
                goto out;
        }
        fs_devices->seeding = seeding;