From: Anand Jain Date: Sat, 13 Feb 2016 02:01:37 +0000 (+0800) Subject: btrfs: enhance btrfs_find_device_by_user_input() to check device path X-Git-Tag: next-20160301~106^2^2^2~10 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=da335ed6f002f12b4934d7466dddefd6247061e1;p=karo-tx-linux.git 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: Anand Jain Signed-off-by: David Sterba --- diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 12d941d9b0e8..3e2616d151d9 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -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, diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6d8b78ffb0a0..fede69134368 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2112,6 +2112,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); }