diff mbox

[2/2] btrfs: we are not yet ready if device is missing

Message ID 1403614303-4210-2-git-send-email-Anand.Jain@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Anand Jain June 24, 2014, 12:51 p.m. UTC
reproducer:

mkfs.btrfs -f -draid1 -mraid1 /dev/sdf /dev/sdd
modprobe -r btrfs && modprobe btrfs
mount -o degraded /dev/sdd /btrfs  <-- calls add_missing_dev() to add missing btrfs_device
umount /btrfs
btrfs dev ready /dev/sdd
echo $?
0
mount /dev/sdd /btrfs
mount: wrong fs type, bad option, bad superblock on /dev/sdd,
       missing codepage or helper program, or other error

fix this by checking if the device name is present in the BTRFS_IOC_DEVICES_READY
ioctl

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
---
 fs/btrfs/super.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox

Patch

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b9efe58..74ef9bf 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1857,6 +1857,7 @@  static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	struct btrfs_fs_devices *fs_devices;
 	int ret = -ENOTTY;
 	void __user *argp = (void __user *)arg;
+	struct btrfs_device *dev;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -1882,6 +1883,14 @@  static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 		kfree(vol);
 		if (ret)
 			break;
+
+		list_for_each_entry(dev, &fs_devices->devices, dev_list) {
+			if (dev->name)
+				continue;
+
+			return !0;
+		}
+
 		ret = !(fs_devices->num_devices == fs_devices->total_devices);
 		break;
 	case BTRFS_IOC_GET_FSLIST: