summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2016-02-13 03:01:37 +0100
committerDavid Sterba <dsterba@suse.com>2016-04-28 10:59:13 +0200
commitb3d1b1532ff9620ff5dba891a96f3e912005eb10 (patch)
tree50ca54581e2527399b16d4b7b6825a99ab5d617b /fs/btrfs
parentbtrfs: make use of btrfs_find_device_by_user_input() (diff)
downloadlinux-b3d1b1532ff9620ff5dba891a96f3e912005eb10.tar.xz
linux-b3d1b1532ff9620ff5dba891a96f3e912005eb10.zip
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 <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/dev-replace.c4
-rw-r--r--fs/btrfs/volumes.c3
2 files changed, 3 insertions, 4 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 7ad8ae994ca0..fdd2880707df 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 40bbe0a2715b..d74260567bea 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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);
}