Commit b3d1b153 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: enhance btrfs_find_device_by_user_input() to check device path

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: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 24fc572f
...@@ -320,10 +320,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root, ...@@ -320,10 +320,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
return -EINVAL; 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 */ /* the disk copy procedure reuses the scrub code */
mutex_lock(&fs_info->volume_mutex); mutex_lock(&fs_info->volume_mutex);
ret = btrfs_find_device_by_user_input(root, args->start.srcdevid, ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,
......
...@@ -2113,6 +2113,9 @@ int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid, ...@@ -2113,6 +2113,9 @@ int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
if (!*device) if (!*device)
ret = -ENOENT; ret = -ENOENT;
} else { } else {
if (!srcdev_name || !srcdev_name[0])
return -EINVAL;
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name, ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
device); device);
} }
......
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