Skip to content

Commit a16fb8c

Browse files
morbidrsakdave
authored andcommitted
btrfs: factor out block mapping for single profiles
Now that we have a container for the I/O geometry that has all the needed information for the block mappings of SINGLE profiles, factor out a helper calculating this information. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 089221d commit a16fb8c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6484,6 +6484,14 @@ static void map_blocks_raid56_read(struct btrfs_chunk_map *map,
64846484
io_geom->mirror_num = 1;
64856485
}
64866486

6487+
static void map_blocks_single(const struct btrfs_chunk_map *map,
6488+
struct btrfs_io_geometry *io_geom)
6489+
{
6490+
io_geom->stripe_index = io_geom->stripe_nr % map->num_stripes;
6491+
io_geom->stripe_nr /= map->num_stripes;
6492+
io_geom->mirror_num = io_geom->stripe_index + 1;
6493+
}
6494+
64876495
/*
64886496
* Map one logical range to one or more physical ranges.
64896497
*
@@ -6586,9 +6594,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
65866594
* device we have to walk to find the data, and stripe_index is
65876595
* the number of our device in the stripe array
65886596
*/
6589-
io_geom.stripe_index = io_geom.stripe_nr % map->num_stripes;
6590-
io_geom.stripe_nr /= map->num_stripes;
6591-
io_geom.mirror_num = io_geom.stripe_index + 1;
6597+
map_blocks_single(map, &io_geom);
65926598
}
65936599
if (io_geom.stripe_index >= map->num_stripes) {
65946600
btrfs_crit(fs_info,

0 commit comments

Comments
 (0)