Skip to content

Commit

Permalink
btrfs: enhance btrfs_find_device_by_user_input() to check device path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anand Jain authored and David Sterba committed Apr 28, 2016
1 parent 24fc572 commit b3d1b15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions fs/btrfs/dev-replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b3d1b15

Please sign in to comment.