For clarity how we are going to find the device, let's call it a device specifier, devspec for short. Also rename the arguments that are a leftover from previous function purpose.
Unified · Split
| @@ -322,7 +322,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, · 321 unmodified lines | |||
| 322 | 322 | ||
| 323 | /* the disk copy procedure reuses the scrub code */ | 323 | /* the disk copy procedure reuses the scrub code */ |
| 324 | mutex_lock(&fs_info->volume_mutex); | 324 | mutex_lock(&fs_info->volume_mutex); |
| 325 | ret = btrfs_find_device_by_user_input(root, args->start.srcdevid, | 325 | ret = btrfs_find_device_by_devspec(root, args->start.srcdevid, |
| 326 | args->start.srcdev_name, | 326 | args->start.srcdev_name, |
| 327 | &src_device); | 327 | &src_device); |
| 328 | if (ret) { | 328 | if (ret) { |
| @@ -1780,7 +1780,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path, u64 devid) · 1779 unmodified lines | |||
| 1780 | if (ret) | 1780 | if (ret) |
| 1781 | goto out; | 1781 | goto out; |
| 1782 | 1782 | ||
| 1783 | ret = btrfs_find_device_by_user_input(root, devid, device_path, | 1783 | ret = btrfs_find_device_by_devspec(root, devid, device_path, |
| 1784 | &device); | 1784 | &device); |
| 1785 | if (ret) | 1785 | if (ret) |
| 1786 | goto out; | 1786 | goto out; |
| @@ -2065,23 +2065,26 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, · 278 unmodified lines | |||
| 2065 | } | 2065 | } |
| 2066 | } | 2066 | } |
| 2067 | 2067 | ||
| 2068 | int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid, | 2068 | /* |
| 2069 | char *srcdev_name, | 2069 | * Lookup a device given by device id, or the path if the id is 0. |
| 2070 | */ | ||
| 2071 | int btrfs_find_device_by_devspec(struct btrfs_root *root, u64 devid, | ||
| 2072 | char *devpath, | ||
| 2070 | struct btrfs_device **device) | 2073 | struct btrfs_device **device) |
| 2071 | { | 2074 | { |
| 2072 | int ret; | 2075 | int ret; |
| 2073 | 2076 | ||
| 2074 | if (srcdevid) { | 2077 | if (devid) { |
| 2075 | ret = 0; | 2078 | ret = 0; |
| 2076 | *device = btrfs_find_device(root->fs_info, srcdevid, NULL, | 2079 | *device = btrfs_find_device(root->fs_info, devid, NULL, |
| 2077 | NULL); | 2080 | NULL); |
| 2078 | if (!*device) | 2081 | if (!*device) |
| 2079 | ret = -ENOENT; | 2082 | ret = -ENOENT; |
| 2080 | } else { | 2083 | } else { |
| 2081 | if (!srcdev_name || !srcdev_name[0]) | 2084 | if (!devpath || !devpath[0]) |
| 2082 | return -EINVAL; | 2085 | return -EINVAL; |
| 2083 | 2086 | ||
| 2084 | ret = btrfs_find_device_missing_or_by_path(root, srcdev_name, | 2087 | ret = btrfs_find_device_missing_or_by_path(root, devpath, |
| 2085 | device); | 2088 | device); |
| 2086 | } | 2089 | } |
| 2087 | return ret; | 2090 | return ret; |
| @@ -448,8 +448,8 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step); · 447 unmodified lines | |||
| 448 | int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, | 448 | int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, |
| 449 | char *device_path, | 449 | char *device_path, |
| 450 | struct btrfs_device **device); | 450 | struct btrfs_device **device); |
| 451 | int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid, | 451 | int btrfs_find_device_by_devspec(struct btrfs_root *root, u64 devid, |
| 452 | char *srcdev_name, | 452 | char *devpath, |
| 453 | struct btrfs_device **device); | 453 | struct btrfs_device **device); |
| 454 | struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info, | 454 | struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info, |
| 455 | const u64 *devid, | 455 | const u64 *devid, |