Commit f63e0cca authored by Eric Sandeen's avatar Eric Sandeen Committed by Josef Bacik

btrfs: ignore device open failures in __btrfs_open_devices

This:

   # mkfs.btrfs /dev/sdb{1,2} ; wipefs -a /dev/sdb1; mount /dev/sdb2 /mnt/test

would lead to a blkdev open/close mismatch when the mount fails, and
a permanently busy (opened O_EXCL) sdb2:

   # wipefs -a /dev/sdb2
   wipefs: error: /dev/sdb2: probing initialization failed: Device or resource busy

It's because btrfs_open_devices() may open some devices, fail on
the last one, and return that failure stored in "ret."   The mount
then fails, but the caller then does not clean up the open devices.

Chris assures me that:

"btrfs_open_devices just means: go off and open every bdev you can from
this uuid.  It should return success if we opened any of them at all."

So change the logic to ignore any open failures; just skip processing
of that device.  Later on it's decided whether we have enough devices
to continue.
Reported-by: default avatarJan Safranek <jsafrane@redhat.com>
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent e4100d98
...@@ -717,9 +717,9 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, ...@@ -717,9 +717,9 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
if (!device->name) if (!device->name)
continue; continue;
ret = btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1, /* Just open everything we can; ignore failures here */
&bdev, &bh); if (btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1,
if (ret) &bdev, &bh))
continue; continue;
disk_super = (struct btrfs_super_block *)bh->b_data; disk_super = (struct btrfs_super_block *)bh->b_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment