提交 24e0474b 编写于 作者: A Anand Jain 提交者: David Sterba

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: NAnand Jain <anand.jain@oracle.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 bd45ffbc
...@@ -44,9 +44,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree( ...@@ -44,9 +44,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree(
struct btrfs_fs_info *fs_info, struct btrfs_fs_info *fs_info,
struct btrfs_device *srcdev, struct btrfs_device *srcdev,
struct btrfs_device *tgtdev); struct btrfs_device *tgtdev);
static int btrfs_dev_replace_find_srcdev(struct btrfs_root *root, u64 srcdevid,
char *srcdev_name,
struct btrfs_device **device);
static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info); static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info);
static int btrfs_dev_replace_kthread(void *data); static int btrfs_dev_replace_kthread(void *data);
static int btrfs_dev_replace_continue_on_mount(struct btrfs_fs_info *fs_info); 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, ...@@ -329,7 +326,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
/* the disk copy procedure reuses the scrub code */ /* the disk copy procedure reuses the scrub code */
mutex_lock(&fs_info->volume_mutex); mutex_lock(&fs_info->volume_mutex);
ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid, ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,
args->start.srcdev_name, args->start.srcdev_name,
&src_device); &src_device);
if (ret) { if (ret) {
...@@ -626,25 +623,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree( ...@@ -626,25 +623,6 @@ static void btrfs_dev_replace_update_device_in_mapping_tree(
write_unlock(&em_tree->lock); write_unlock(&em_tree->lock);
} }
static int btrfs_dev_replace_find_srcdev(struct btrfs_root *root, u64 srcdevid,
char *srcdev_name,
struct btrfs_device **device)
{
int ret;
if (srcdevid) {
ret = 0;
*device = btrfs_find_device(root->fs_info, srcdevid, NULL,
NULL);
if (!*device)
ret = -ENOENT;
} else {
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
device);
}
return ret;
}
void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info, void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_dev_replace_args *args) struct btrfs_ioctl_dev_replace_args *args)
{ {
......
...@@ -2126,6 +2126,25 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, ...@@ -2126,6 +2126,25 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_root *root,
} }
} }
int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
char *srcdev_name,
struct btrfs_device **device)
{
int ret;
if (srcdevid) {
ret = 0;
*device = btrfs_find_device(root->fs_info, srcdevid, NULL,
NULL);
if (!*device)
ret = -ENOENT;
} else {
ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
device);
}
return ret;
}
/* /*
* does all the dirty work required for changing file system's UUID. * does all the dirty work required for changing file system's UUID.
*/ */
......
...@@ -448,6 +448,9 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step); ...@@ -448,6 +448,9 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step);
int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, int btrfs_find_device_missing_or_by_path(struct btrfs_root *root,
char *device_path, char *device_path,
struct btrfs_device **device); struct btrfs_device **device);
int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
char *srcdev_name,
struct btrfs_device **device);
struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info, struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
const u64 *devid, const u64 *devid,
const u8 *uuid); const u8 *uuid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册