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: v4.1.12-106.0.20170720_1900~74 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5aaf417aec21d71ae179877b0d61c8e9f8e8a40c;p=users%2Fjedix%2Flinux-maple.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 Orabug: 26287586 (Cherry picked from commit b3d1b1532ff9620ff5dba891a96f3e912005eb10) Signed-off-by: Shan Hai Reviewed-by: Somasundaram Krishnasamy --- diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 9fb82a038b54..6405353f518f 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -321,10 +321,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; - /* * Here we commit the transaction to make sure commit_total_bytes * of all the devices are updated. diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 43e190a5a8ca..a03956cf7baa 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1950,6 +1950,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); }