Commit be50a8dd authored by Zhao Lei's avatar Zhao Lei Committed by Chris Mason

Btrfs: Simplify scrub_setup_recheck_block()'s argument

scrub_setup_recheck_block() have many arguments but most of them
can be get from one of them, we can remove them to make code clean.
Some other cleanup for that function also included in this patch.
Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent b968fed1
...@@ -235,10 +235,7 @@ static void scrub_pending_bio_dec(struct scrub_ctx *sctx); ...@@ -235,10 +235,7 @@ static void scrub_pending_bio_dec(struct scrub_ctx *sctx);
static void scrub_pending_trans_workers_inc(struct scrub_ctx *sctx); static void scrub_pending_trans_workers_inc(struct scrub_ctx *sctx);
static void scrub_pending_trans_workers_dec(struct scrub_ctx *sctx); static void scrub_pending_trans_workers_dec(struct scrub_ctx *sctx);
static int scrub_handle_errored_block(struct scrub_block *sblock_to_check); static int scrub_handle_errored_block(struct scrub_block *sblock_to_check);
static int scrub_setup_recheck_block(struct scrub_ctx *sctx, static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
struct btrfs_fs_info *fs_info,
struct scrub_block *original_sblock,
u64 length, u64 logical,
struct scrub_block *sblocks_for_recheck); struct scrub_block *sblocks_for_recheck);
static void scrub_recheck_block(struct btrfs_fs_info *fs_info, static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
struct scrub_block *sblock, int is_metadata, struct scrub_block *sblock, int is_metadata,
...@@ -960,8 +957,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check) ...@@ -960,8 +957,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
} }
/* setup the context, map the logical blocks and alloc the pages */ /* setup the context, map the logical blocks and alloc the pages */
ret = scrub_setup_recheck_block(sctx, fs_info, sblock_to_check, length, ret = scrub_setup_recheck_block(sblock_to_check, sblocks_for_recheck);
logical, sblocks_for_recheck);
if (ret) { if (ret) {
spin_lock(&sctx->stat_lock); spin_lock(&sctx->stat_lock);
sctx->stat.read_errors++; sctx->stat.read_errors++;
...@@ -1301,19 +1297,20 @@ static inline void scrub_stripe_index_and_offset(u64 logical, u64 *raid_map, ...@@ -1301,19 +1297,20 @@ static inline void scrub_stripe_index_and_offset(u64 logical, u64 *raid_map,
} }
} }
static int scrub_setup_recheck_block(struct scrub_ctx *sctx, static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
struct btrfs_fs_info *fs_info,
struct scrub_block *original_sblock,
u64 length, u64 logical,
struct scrub_block *sblocks_for_recheck) struct scrub_block *sblocks_for_recheck)
{ {
struct scrub_ctx *sctx = original_sblock->sctx;
struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info;
u64 length = original_sblock->page_count * PAGE_SIZE;
u64 logical = original_sblock->pagev[0]->logical;
struct scrub_recover *recover; struct scrub_recover *recover;
struct btrfs_bio *bbio; struct btrfs_bio *bbio;
u64 sublen; u64 sublen;
u64 mapped_length; u64 mapped_length;
u64 stripe_offset; u64 stripe_offset;
int stripe_index; int stripe_index;
int page_index; int page_index = 0;
int mirror_index; int mirror_index;
int nmirrors; int nmirrors;
int ret; int ret;
...@@ -1324,7 +1321,6 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx, ...@@ -1324,7 +1321,6 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx,
* the recheck procedure * the recheck procedure
*/ */
page_index = 0;
while (length > 0) { while (length > 0) {
sublen = min_t(u64, length, PAGE_SIZE); sublen = min_t(u64, length, PAGE_SIZE);
mapped_length = sublen; mapped_length = sublen;
...@@ -1353,15 +1349,12 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx, ...@@ -1353,15 +1349,12 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx,
BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO); BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO);
nmirrors = scrub_nr_raid_mirrors(bbio); nmirrors = min(scrub_nr_raid_mirrors(bbio), BTRFS_MAX_MIRRORS);
for (mirror_index = 0; mirror_index < nmirrors; for (mirror_index = 0; mirror_index < nmirrors;
mirror_index++) { mirror_index++) {
struct scrub_block *sblock; struct scrub_block *sblock;
struct scrub_page *page; struct scrub_page *page;
if (mirror_index >= BTRFS_MAX_MIRRORS)
break;
sblock = sblocks_for_recheck + mirror_index; sblock = sblocks_for_recheck + mirror_index;
sblock->sctx = sctx; sblock->sctx = sctx;
page = kzalloc(sizeof(*page), GFP_NOFS); page = kzalloc(sizeof(*page), GFP_NOFS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment