Commit 9fb2acc2 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: remove the need_raid_map parameter from btrfs_map_block()

The parameter @need_raid_map is mostly a legacy from the old days where
we don't yet have a solid definition on the @mirror_num, and only
check-integrity was using that parameter, while all other call sites
just pass 1 for that parameter.

Now since we have removed check-integrity functionality, we can also
remove the @need_raid_map parameter.

This change will also remove the ability to read P/Q stripe directly
when passing 0 as @need_raid_map.
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 732fab95
...@@ -656,7 +656,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) ...@@ -656,7 +656,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
btrfs_bio_counter_inc_blocked(fs_info); btrfs_bio_counter_inc_blocked(fs_info);
error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length, error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length,
&bioc, &smap, &mirror_num, 1); &bioc, &smap, &mirror_num);
if (error) { if (error) {
ret = errno_to_blk_status(error); ret = errno_to_blk_status(error);
goto fail; goto fail;
......
...@@ -896,7 +896,7 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx, ...@@ -896,7 +896,7 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
ASSERT(stripe->mirror_num >= 1); ASSERT(stripe->mirror_num >= 1);
ret = btrfs_map_block(fs_info, BTRFS_MAP_GET_READ_MIRRORS, ret = btrfs_map_block(fs_info, BTRFS_MAP_GET_READ_MIRRORS,
stripe->logical, &mapped_len, &bioc, stripe->logical, &mapped_len, &bioc,
NULL, NULL, 1); NULL, NULL);
/* /*
* If we failed, dev will be NULL, and later detailed reports * If we failed, dev will be NULL, and later detailed reports
* will just be skipped. * will just be skipped.
...@@ -1951,7 +1951,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx, ...@@ -1951,7 +1951,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
btrfs_bio_counter_inc_blocked(fs_info); btrfs_bio_counter_inc_blocked(fs_info);
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start, ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start,
&length, &bioc, NULL, NULL, 1); &length, &bioc, NULL, NULL);
if (ret < 0) { if (ret < 0) {
btrfs_put_bioc(bioc); btrfs_put_bioc(bioc);
btrfs_bio_counter_dec(fs_info); btrfs_bio_counter_dec(fs_info);
......
...@@ -6246,16 +6246,11 @@ static void set_io_stripe(struct btrfs_io_stripe *dst, const struct map_lookup * ...@@ -6246,16 +6246,11 @@ static void set_io_stripe(struct btrfs_io_stripe *dst, const struct map_lookup *
* For RAID6 profile, mirror > 2 means mark another * For RAID6 profile, mirror > 2 means mark another
* data/P stripe error and rebuild from the remaining * data/P stripe error and rebuild from the remaining
* stripes.. * stripes..
*
* @need_raid_map: (Used only for integrity checker) whether the map wants
* a full stripe map (including all data and P/Q stripes)
* for RAID56. Should always be 1 except integrity checker.
*/ */
int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
u64 logical, u64 *length, u64 logical, u64 *length,
struct btrfs_io_context **bioc_ret, struct btrfs_io_context **bioc_ret,
struct btrfs_io_stripe *smap, int *mirror_num_ret, struct btrfs_io_stripe *smap, int *mirror_num_ret)
int need_raid_map)
{ {
struct extent_map *em; struct extent_map *em;
struct map_lookup *map; struct map_lookup *map;
...@@ -6350,8 +6345,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6350,8 +6345,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
} }
} else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
if (need_raid_map && (op != BTRFS_MAP_READ || mirror_num > 1)) { if (op != BTRFS_MAP_READ || mirror_num > 1) {
/* /*
* Needs full stripe mapping.
*
* Push stripe_nr back to the start of the full stripe * Push stripe_nr back to the start of the full stripe
* For those cases needing a full stripe, @stripe_nr * For those cases needing a full stripe, @stripe_nr
* is the full stripe number. * is the full stripe number.
...@@ -6374,19 +6371,14 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6374,19 +6371,14 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
stripe_index = 0; stripe_index = 0;
stripe_offset = 0; stripe_offset = 0;
} else { } else {
/* ASSERT(mirror_num <= 1);
* Mirror #0 or #1 means the original data block. /* Just grab the data stripe directly. */
* Mirror #2 is RAID5 parity block.
* Mirror #3 is RAID6 Q block.
*/
stripe_index = stripe_nr % data_stripes; stripe_index = stripe_nr % data_stripes;
stripe_nr /= data_stripes; stripe_nr /= data_stripes;
if (mirror_num > 1)
stripe_index = data_stripes + mirror_num - 2;
/* We distribute the parity blocks across stripes */ /* We distribute the parity blocks across stripes */
stripe_index = (stripe_nr + stripe_index) % map->num_stripes; stripe_index = (stripe_nr + stripe_index) % map->num_stripes;
if (op == BTRFS_MAP_READ && mirror_num <= 1) if (op == BTRFS_MAP_READ && mirror_num < 1)
mirror_num = 1; mirror_num = 1;
} }
} else { } else {
...@@ -6448,7 +6440,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6448,7 +6440,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
* *
* It's still mostly the same as other profiles, just with extra rotation. * It's still mostly the same as other profiles, just with extra rotation.
*/ */
if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK && need_raid_map && if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK &&
(op != BTRFS_MAP_READ || mirror_num > 1)) { (op != BTRFS_MAP_READ || mirror_num > 1)) {
/* /*
* For RAID56 @stripe_nr is already the number of full stripes * For RAID56 @stripe_nr is already the number of full stripes
...@@ -8077,7 +8069,7 @@ int btrfs_map_repair_block(struct btrfs_fs_info *fs_info, ...@@ -8077,7 +8069,7 @@ int btrfs_map_repair_block(struct btrfs_fs_info *fs_info,
ASSERT(mirror_num > 0); ASSERT(mirror_num > 0);
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, logical, &map_length, ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, logical, &map_length,
&bioc, smap, &mirror_ret, true); &bioc, smap, &mirror_ret);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -605,8 +605,7 @@ void btrfs_put_bioc(struct btrfs_io_context *bioc); ...@@ -605,8 +605,7 @@ void btrfs_put_bioc(struct btrfs_io_context *bioc);
int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
u64 logical, u64 *length, u64 logical, u64 *length,
struct btrfs_io_context **bioc_ret, struct btrfs_io_context **bioc_ret,
struct btrfs_io_stripe *smap, int *mirror_num_ret, struct btrfs_io_stripe *smap, int *mirror_num_ret);
int need_raid_map);
int btrfs_map_repair_block(struct btrfs_fs_info *fs_info, int btrfs_map_repair_block(struct btrfs_fs_info *fs_info,
struct btrfs_io_stripe *smap, u64 logical, struct btrfs_io_stripe *smap, u64 logical,
u32 length, int mirror_num); u32 length, int mirror_num);
......
...@@ -1887,7 +1887,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical, ...@@ -1887,7 +1887,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
int i, ret; int i, ret;
ret = btrfs_map_block(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical, ret = btrfs_map_block(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical,
&mapped_length, &bioc, NULL, NULL, 1); &mapped_length, &bioc, NULL, NULL);
if (ret || !bioc || mapped_length < PAGE_SIZE) { if (ret || !bioc || mapped_length < PAGE_SIZE) {
ret = -EIO; ret = -EIO;
goto out_put_bioc; goto out_put_bioc;
......
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