btrfs: enhance btrfs_find_device_by_user_input() to check device path
authorAnand Jain <anand.jain@oracle.com>
Sat, 13 Feb 2016 02:01:37 +0000 (10:01 +0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 28 Apr 2016 08:59:13 +0000 (10:59 +0200)
The operation of device replace and device delete follows same steps upto
some depth with in btrfs kernel, however they don't share codes. This
enhancement will help replace and delete to share codes.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dev-replace.c
fs/btrfs/volumes.c

index 7ad8ae994ca04cc0719b28b6f158fb3ecc4e7774..fdd2880707df45ba755614a2eb90e4dd1ead32f9 100644 (file)
@@ -320,10 +320,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
                return -EINVAL;
        }
 
-       if ((args->start.srcdevid == 0 && args->start.srcdev_name[0] == '\0') ||
-           args->start.tgtdev_name[0] == '\0')
-               return -EINVAL;
-
        /* the disk copy procedure reuses the scrub code */
        mutex_lock(&fs_info->volume_mutex);
        ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,
index 40bbe0a2715bd4a85703fa029d88f4a83e082d25..d74260567bea4d37054ddd883bb69f7d2f89ee6d 100644 (file)
@@ -2113,6 +2113,9 @@ int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
                if (!*device)
                        ret = -ENOENT;
        } else {
+               if (!srcdev_name || !srcdev_name[0])
+                       return -EINVAL;
+
                ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
                                                           device);
        }