Commit e94dfb7a authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba

btrfs: pass btrfs_io_geometry into btrfs_max_io_len

Instead of passing three individual members of 'struct btrfs_io_geometry'
into btrfs_max_io_len(), pass a pointer to btrfs_io_geometry.
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6edf6822
...@@ -6277,17 +6277,16 @@ static void handle_ops_on_dev_replace(enum btrfs_map_op op, ...@@ -6277,17 +6277,16 @@ static void handle_ops_on_dev_replace(enum btrfs_map_op op,
bioc->replace_nr_stripes = nr_extra_stripes; bioc->replace_nr_stripes = nr_extra_stripes;
} }
static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, u64 offset,
u64 offset, u32 *stripe_nr, u64 *stripe_offset, struct btrfs_io_geometry *io_geom)
u64 *full_stripe_start)
{ {
/* /*
* Stripe_nr is the stripe where this block falls. stripe_offset is * Stripe_nr is the stripe where this block falls. stripe_offset is
* the offset of this block in its stripe. * the offset of this block in its stripe.
*/ */
*stripe_offset = offset & BTRFS_STRIPE_LEN_MASK; io_geom->stripe_offset = offset & BTRFS_STRIPE_LEN_MASK;
*stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT; io_geom->stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT;
ASSERT(*stripe_offset < U32_MAX); ASSERT(io_geom->stripe_offset < U32_MAX);
if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
unsigned long full_stripe_len = unsigned long full_stripe_len =
...@@ -6302,18 +6301,17 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, ...@@ -6302,18 +6301,17 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op,
* to go rounddown(), not round_down(), as nr_data_stripes is * to go rounddown(), not round_down(), as nr_data_stripes is
* not ensured to be power of 2. * not ensured to be power of 2.
*/ */
*full_stripe_start = io_geom->raid56_full_stripe_start = btrfs_stripe_nr_to_offset(
btrfs_stripe_nr_to_offset( rounddown(io_geom->stripe_nr, nr_data_stripes(map)));
rounddown(*stripe_nr, nr_data_stripes(map)));
ASSERT(*full_stripe_start + full_stripe_len > offset); ASSERT(io_geom->raid56_full_stripe_start + full_stripe_len > offset);
ASSERT(*full_stripe_start <= offset); ASSERT(io_geom->raid56_full_stripe_start <= offset);
/* /*
* For writes to RAID56, allow to write a full stripe set, but * For writes to RAID56, allow to write a full stripe set, but
* no straddling of stripe sets. * no straddling of stripe sets.
*/ */
if (op == BTRFS_MAP_WRITE) if (io_geom->op == BTRFS_MAP_WRITE)
return full_stripe_len - (offset - *full_stripe_start); return full_stripe_len - (offset - io_geom->raid56_full_stripe_start);
} }
/* /*
...@@ -6321,7 +6319,7 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, ...@@ -6321,7 +6319,7 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op,
* a single disk). * a single disk).
*/ */
if (map->type & BTRFS_BLOCK_GROUP_STRIPE_MASK) if (map->type & BTRFS_BLOCK_GROUP_STRIPE_MASK)
return BTRFS_STRIPE_LEN - *stripe_offset; return BTRFS_STRIPE_LEN - io_geom->stripe_offset;
return U64_MAX; return U64_MAX;
} }
...@@ -6564,9 +6562,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6564,9 +6562,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
map_offset = logical - map->start; map_offset = logical - map->start;
io_geom.raid56_full_stripe_start = (u64)-1; io_geom.raid56_full_stripe_start = (u64)-1;
max_len = btrfs_max_io_len(map, io_geom.op, map_offset, &io_geom.stripe_nr, max_len = btrfs_max_io_len(map, map_offset, &io_geom);
&io_geom.stripe_offset,
&io_geom.raid56_full_stripe_start);
*length = min_t(u64, map->chunk_len - map_offset, max_len); *length = min_t(u64, map->chunk_len - map_offset, max_len);
down_read(&dev_replace->rwsem); down_read(&dev_replace->rwsem);
......
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