Skip to content

Commit 24e0474

Browse files
asjkdave
authored andcommitted
btrfs: create helper btrfs_find_device_by_user_input()
The patch renames btrfs_dev_replace_find_srcdev() to btrfs_find_device_by_user_input() and moves it to volumes.c, so that delete device can use it. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent bd45ffb commit 24e0474

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

fs/btrfs/dev-replace.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree(
4444
struct btrfs_fs_info *fs_info,
4545
struct btrfs_device *srcdev,
4646
struct btrfs_device *tgtdev);
47-
static int btrfs_dev_replace_find_srcdev(struct btrfs_root *root, u64 srcdevid,
48-
char *srcdev_name,
49-
struct btrfs_device **device);
5047
static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info);
5148
static int btrfs_dev_replace_kthread(void *data);
5249
static int btrfs_dev_replace_continue_on_mount(struct btrfs_fs_info *fs_info);
@@ -329,7 +326,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
329326

330327
/* the disk copy procedure reuses the scrub code */
331328
mutex_lock(&fs_info->volume_mutex);
332-
ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid,
329+
ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,
333330
args->start.srcdev_name,
334331
&src_device);
335332
if (ret) {
@@ -626,25 +623,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree(
626623
write_unlock(&em_tree->lock);
627624
}
628625

629-
static int btrfs_dev_replace_find_srcdev(struct btrfs_root *root, u64 srcdevid,
630-
char *srcdev_name,
631-
struct btrfs_device **device)
632-
{
633-
int ret;
634-
635-
if (srcdevid) {
636-
ret = 0;
637-
*device = btrfs_find_device(root->fs_info, srcdevid, NULL,
638-
NULL);
639-
if (!*device)
640-
ret = -ENOENT;
641-
} else {
642-
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
643-
device);
644-
}
645-
return ret;
646-
}
647-
648626
void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
649627
struct btrfs_ioctl_dev_replace_args *args)
650628
{

fs/btrfs/volumes.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,25 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_root *root,
21262126
}
21272127
}
21282128

2129+
int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
2130+
char *srcdev_name,
2131+
struct btrfs_device **device)
2132+
{
2133+
int ret;
2134+
2135+
if (srcdevid) {
2136+
ret = 0;
2137+
*device = btrfs_find_device(root->fs_info, srcdevid, NULL,
2138+
NULL);
2139+
if (!*device)
2140+
ret = -ENOENT;
2141+
} else {
2142+
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
2143+
device);
2144+
}
2145+
return ret;
2146+
}
2147+
21292148
/*
21302149
* does all the dirty work required for changing file system's UUID.
21312150
*/

fs/btrfs/volumes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step);
448448
int btrfs_find_device_missing_or_by_path(struct btrfs_root *root,
449449
char *device_path,
450450
struct btrfs_device **device);
451+
int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
452+
char *srcdev_name,
453+
struct btrfs_device **device);
451454
struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
452455
const u64 *devid,
453456
const u8 *uuid);

0 commit comments

Comments
 (0)