btrfs: scrub: inline helper scrub_setup_wr_ctx
The helper scrub_setup_wr_ctx is used only once and fits into scrub_setup_ctx as it continues intialization, no need to keep it separate. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
@@ -289,9 +289,6 @@ static void scrub_remap_extent(struct btrfs_fs_info *fs_info,
|
|||||||
u64 *extent_physical,
|
u64 *extent_physical,
|
||||||
struct btrfs_device **extent_dev,
|
struct btrfs_device **extent_dev,
|
||||||
int *extent_mirror_num);
|
int *extent_mirror_num);
|
||||||
static int scrub_setup_wr_ctx(struct scrub_wr_ctx *wr_ctx,
|
|
||||||
struct btrfs_device *dev,
|
|
||||||
int is_dev_replace);
|
|
||||||
static void scrub_free_wr_ctx(struct scrub_wr_ctx *wr_ctx);
|
static void scrub_free_wr_ctx(struct scrub_wr_ctx *wr_ctx);
|
||||||
static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx,
|
static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx,
|
||||||
struct scrub_page *spage);
|
struct scrub_page *spage);
|
||||||
@@ -680,7 +677,6 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, int is_dev_replace)
|
|||||||
struct scrub_ctx *sctx;
|
struct scrub_ctx *sctx;
|
||||||
int i;
|
int i;
|
||||||
struct btrfs_fs_info *fs_info = dev->fs_info;
|
struct btrfs_fs_info *fs_info = dev->fs_info;
|
||||||
int ret;
|
|
||||||
|
|
||||||
sctx = kzalloc(sizeof(*sctx), GFP_KERNEL);
|
sctx = kzalloc(sizeof(*sctx), GFP_KERNEL);
|
||||||
if (!sctx)
|
if (!sctx)
|
||||||
@@ -722,12 +718,16 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, int is_dev_replace)
|
|||||||
spin_lock_init(&sctx->stat_lock);
|
spin_lock_init(&sctx->stat_lock);
|
||||||
init_waitqueue_head(&sctx->list_wait);
|
init_waitqueue_head(&sctx->list_wait);
|
||||||
|
|
||||||
ret = scrub_setup_wr_ctx(&sctx->wr_ctx,
|
WARN_ON(sctx->wr_ctx.wr_curr_bio != NULL);
|
||||||
fs_info->dev_replace.tgtdev, is_dev_replace);
|
mutex_init(&sctx->wr_ctx.wr_lock);
|
||||||
if (ret) {
|
sctx->wr_ctx.wr_curr_bio = NULL;
|
||||||
scrub_free_ctx(sctx);
|
if (is_dev_replace) {
|
||||||
return ERR_PTR(ret);
|
WARN_ON(!dev->bdev);
|
||||||
|
sctx->wr_ctx.pages_per_wr_bio = SCRUB_PAGES_PER_WR_BIO;
|
||||||
|
sctx->wr_ctx.tgtdev = dev;
|
||||||
|
atomic_set(&sctx->wr_ctx.flush_all_writes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sctx;
|
return sctx;
|
||||||
|
|
||||||
nomem:
|
nomem:
|
||||||
@@ -4337,24 +4337,6 @@ static void scrub_remap_extent(struct btrfs_fs_info *fs_info,
|
|||||||
btrfs_put_bbio(bbio);
|
btrfs_put_bbio(bbio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scrub_setup_wr_ctx(struct scrub_wr_ctx *wr_ctx,
|
|
||||||
struct btrfs_device *dev,
|
|
||||||
int is_dev_replace)
|
|
||||||
{
|
|
||||||
WARN_ON(wr_ctx->wr_curr_bio != NULL);
|
|
||||||
|
|
||||||
mutex_init(&wr_ctx->wr_lock);
|
|
||||||
wr_ctx->wr_curr_bio = NULL;
|
|
||||||
if (!is_dev_replace)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
WARN_ON(!dev->bdev);
|
|
||||||
wr_ctx->pages_per_wr_bio = SCRUB_PAGES_PER_WR_BIO;
|
|
||||||
wr_ctx->tgtdev = dev;
|
|
||||||
atomic_set(&wr_ctx->flush_all_writes, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void scrub_free_wr_ctx(struct scrub_wr_ctx *wr_ctx)
|
static void scrub_free_wr_ctx(struct scrub_wr_ctx *wr_ctx)
|
||||||
{
|
{
|
||||||
mutex_lock(&wr_ctx->wr_lock);
|
mutex_lock(&wr_ctx->wr_lock);
|
||||||
|
Reference in New Issue
Block a user