]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
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)
committerShan Hai <shan.hai@oracle.com>
Thu, 13 Jul 2017 05:20:32 +0000 (13:20 +0800)
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>
Orabug: 26287586

(Cherry picked from commit b3d1b1532ff9620ff5dba891a96f3e912005eb10)

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Reviewed-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
fs/btrfs/dev-replace.c
fs/btrfs/volumes.c

index 9fb82a038b54f4b825db5eca91c548b21a7c4f6c..6405353f518f3ad86121a4ddea21c77fe8a44bb0 100644 (file)
@@ -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.
index 43e190a5a8cacc89eb6a3e3701f90e85cbace12d..a03956cf7baa4ec4a874fb3db7d0072e9d402819 100644 (file)
@@ -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);
        }