Btrfs: close all bdevs on mount failure

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>
This commit is contained in:
Ilya Dryomov 2011-10-20 00:06:20 +03:00 committed by David Sterba
parent 5f524444c3
commit 20bcd64934

View file

@ -597,10 +597,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
set_blocksize(bdev, 4096); set_blocksize(bdev, 4096);
bh = btrfs_read_dev_super(bdev); bh = btrfs_read_dev_super(bdev);
if (!bh) { if (!bh)
ret = -EINVAL;
goto error_close; goto error_close;
}
disk_super = (struct btrfs_super_block *)bh->b_data; disk_super = (struct btrfs_super_block *)bh->b_data;
devid = btrfs_stack_device_id(&disk_super->dev_item); devid = btrfs_stack_device_id(&disk_super->dev_item);
@ -655,7 +653,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
continue; continue;
} }
if (fs_devices->open_devices == 0) { if (fs_devices->open_devices == 0) {
ret = -EIO; ret = -EINVAL;
goto out; goto out;
} }
fs_devices->seeding = seeding; fs_devices->seeding = seeding;