diff mbox

bug adding device to seed device, btrfs fi show fails

Message ID 53EC3D01.1030502@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Aug. 14, 2014, 4:37 a.m. UTC
Chris,

For the seed replace issues. you have to try this patch set.
Thanks.
  https://patchwork.kernel.org/patch/4716371/

Next, for the failing 'btrfs fi show' issue the following diff
is the latest. The last attempt was ..
  [PATCH] btrfs: ioctl BTRFS_IOC_FS_INFO and BTRFS_IOC_DEV_INFO 
miss-matched with slots

However as Wang mentioned we would need to show both seed and
sprout together, to make sense to the user.

So I have the following fix. which will soon be sent out
when tests are completed.


kernel:
-------------
+       i++;
+
----------------


Thanks, Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index da73ab3..05dd88b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2725,7 +2725,7 @@  static long btrfs_ioctl_fs_info(struct btrfs_root 
*root, void __user *arg)
                 return -ENOMEM;

         mutex_lock(&fs_devices->device_list_mutex);
-       fi_args->num_devices = fs_devices->num_devices;
+       fi_args->num_devices = fs_devices->total_devices;
         memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid));

         list_for_each_entry_safe(device, next, &fs_devices->devices, 
dev_list) {
----------------


btrfs-progs:
----------------
diff --git a/utils.c b/utils.c
index 8bdc2a7..fa837b9 100644
--- a/utils.c
+++ b/utils.c
@@ -1929,12 +1929,29 @@  int get_fs_info(char *path, struct 
btrfs_ioctl_fs_info_args *fi_args,
         if (!fi_args->num_devices)
                 goto out;

-       di_args = *di_ret = malloc(fi_args->num_devices * sizeof(*di_args));
+       /*
+        * with kernel patch
+        * btrfs: ioctl BTRFS_IOC_FS_INFO and BTRFS_IOC_DEV_INFO 
miss-matched with slots
+        * the kernel now returns total_devices which does not include
+        * replacing device if running. There might be a race condition
+	 * where replace might have been completed before DEVS are
+	 * probed. So we anyway probe the replacing at devid 0
+	 * separately which would return -ENODEV if replace has
+	 * finished.
+        */
+
+       di_args = *di_ret = malloc((fi_args->num_devices + 1) * 
sizeof(*di_args));
         if (!di_args) {
                 ret = -errno;
                 goto out;
         }

+       /* get the replace target device if it is there */
+       ret = get_device_info(fd, i, &di_args[ndevs]);
+       if (!ret) {
+               ndevs++;
+               fi_args->num_devices++;
+       }