Skip to content

Commit b3d1b15

Browse files
asjkdave
authored andcommitted
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>
1 parent 24fc572 commit b3d1b15

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎fs/btrfs/dev-replace.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
320320
return -EINVAL;
321321
}
322322

323-
if ((args->start.srcdevid == 0 && args->start.srcdev_name[0] == '\0') ||
324-
args->start.tgtdev_name[0] == '\0')
325-
return -EINVAL;
326-
327323
/* the disk copy procedure reuses the scrub code */
328324
mutex_lock(&fs_info->volume_mutex);
329325
ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,

‎fs/btrfs/volumes.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,9 @@ int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
21132113
if (!*device)
21142114
ret = -ENOENT;
21152115
} else {
2116+
if (!srcdev_name || !srcdev_name[0])
2117+
return -EINVAL;
2118+
21162119
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
21172120
device);
21182121
}

0 commit comments

Comments
 (0)