aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-01-20 02:11:42 -0500
committerChris Mason <clm@fb.com>2015-01-21 21:06:49 -0500
commitbe50a8ddaae1d07135fd7e1c7017c1611075a560 (patch)
tree2867a34bbb15f23f9fa8a659bc3147d6fba0f8cc /fs
parentb968fed1c3810a0a0d575cab8a72431fbc807615 (diff)
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: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/scrub.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index aac40aefa552..c3a98931980f 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -235,10 +235,7 @@ static void scrub_pending_bio_dec(struct scrub_ctx *sctx);
235static void scrub_pending_trans_workers_inc(struct scrub_ctx *sctx); 235static void scrub_pending_trans_workers_inc(struct scrub_ctx *sctx);
236static void scrub_pending_trans_workers_dec(struct scrub_ctx *sctx); 236static void scrub_pending_trans_workers_dec(struct scrub_ctx *sctx);
237static int scrub_handle_errored_block(struct scrub_block *sblock_to_check); 237static int scrub_handle_errored_block(struct scrub_block *sblock_to_check);
238static int scrub_setup_recheck_block(struct scrub_ctx *sctx, 238static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
239 struct btrfs_fs_info *fs_info,
240 struct scrub_block *original_sblock,
241 u64 length, u64 logical,
242 struct scrub_block *sblocks_for_recheck); 239 struct scrub_block *sblocks_for_recheck);
243static void scrub_recheck_block(struct btrfs_fs_info *fs_info, 240static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
244 struct scrub_block *sblock, int is_metadata, 241 struct scrub_block *sblock, int is_metadata,
@@ -960,8 +957,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
960 } 957 }
961 958
962 /* setup the context, map the logical blocks and alloc the pages */ 959 /* setup the context, map the logical blocks and alloc the pages */
963 ret = scrub_setup_recheck_block(sctx, fs_info, sblock_to_check, length, 960 ret = scrub_setup_recheck_block(sblock_to_check, sblocks_for_recheck);
964 logical, sblocks_for_recheck);
965 if (ret) { 961 if (ret) {
966 spin_lock(&sctx->stat_lock); 962 spin_lock(&sctx->stat_lock);
967 sctx->stat.read_errors++; 963 sctx->stat.read_errors++;
@@ -1301,19 +1297,20 @@ static inline void scrub_stripe_index_and_offset(u64 logical, u64 *raid_map,
1301 } 1297 }
1302} 1298}
1303 1299
1304static int scrub_setup_recheck_block(struct scrub_ctx *sctx, 1300static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
1305 struct btrfs_fs_info *fs_info,
1306 struct scrub_block *original_sblock,
1307 u64 length, u64 logical,
1308 struct scrub_block *sblocks_for_recheck) 1301 struct scrub_block *sblocks_for_recheck)
1309{ 1302{
1303 struct scrub_ctx *sctx = original_sblock->sctx;
1304 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info;
1305 u64 length = original_sblock->page_count * PAGE_SIZE;
1306 u64 logical = original_sblock->pagev[0]->logical;
1310 struct scrub_recover *recover; 1307 struct scrub_recover *recover;
1311 struct btrfs_bio *bbio; 1308 struct btrfs_bio *bbio;
1312 u64 sublen; 1309 u64 sublen;
1313 u64 mapped_length; 1310 u64 mapped_length;
1314 u64 stripe_offset; 1311 u64 stripe_offset;
1315 int stripe_index; 1312 int stripe_index;
1316 int page_index; 1313 int page_index = 0;
1317 int mirror_index; 1314 int mirror_index;
1318 int nmirrors; 1315 int nmirrors;
1319 int ret; 1316 int ret;
@@ -1324,7 +1321,6 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx,
1324 * the recheck procedure 1321 * the recheck procedure
1325 */ 1322 */
1326 1323
1327 page_index = 0;
1328 while (length > 0) { 1324 while (length > 0) {
1329 sublen = min_t(u64, length, PAGE_SIZE); 1325 sublen = min_t(u64, length, PAGE_SIZE);
1330 mapped_length = sublen; 1326 mapped_length = sublen;
@@ -1353,15 +1349,12 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx,
1353 1349
1354 BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO); 1350 BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO);
1355 1351
1356 nmirrors = scrub_nr_raid_mirrors(bbio); 1352 nmirrors = min(scrub_nr_raid_mirrors(bbio), BTRFS_MAX_MIRRORS);
1357 for (mirror_index = 0; mirror_index < nmirrors; 1353 for (mirror_index = 0; mirror_index < nmirrors;
1358 mirror_index++) { 1354 mirror_index++) {
1359 struct scrub_block *sblock; 1355 struct scrub_block *sblock;
1360 struct scrub_page *page; 1356 struct scrub_page *page;
1361 1357
1362 if (mirror_index >= BTRFS_MAX_MIRRORS)
1363 break;
1364
1365 sblock = sblocks_for_recheck + mirror_index; 1358 sblock = sblocks_for_recheck + mirror_index;
1366 sblock->sctx = sctx; 1359 sblock->sctx = sctx;
1367 page = kzalloc(sizeof(*page), GFP_NOFS); 1360 page = kzalloc(sizeof(*page), GFP_NOFS);