@@ -6277,17 +6277,16 @@ static void handle_ops_on_dev_replace(enum btrfs_map_op op,
62776277 bioc -> replace_nr_stripes = nr_extra_stripes ;
62786278}
62796279
6280- static u64 btrfs_max_io_len (struct btrfs_chunk_map * map , enum btrfs_map_op op ,
6281- u64 offset , u32 * stripe_nr , u64 * stripe_offset ,
6282- u64 * full_stripe_start )
6280+ static u64 btrfs_max_io_len (struct btrfs_chunk_map * map , u64 offset ,
6281+ struct btrfs_io_geometry * io_geom )
62836282{
62846283 /*
62856284 * Stripe_nr is the stripe where this block falls. stripe_offset is
62866285 * the offset of this block in its stripe.
62876286 */
6288- * stripe_offset = offset & BTRFS_STRIPE_LEN_MASK ;
6289- * stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT ;
6290- ASSERT (* stripe_offset < U32_MAX );
6287+ io_geom -> stripe_offset = offset & BTRFS_STRIPE_LEN_MASK ;
6288+ io_geom -> stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT ;
6289+ ASSERT (io_geom -> stripe_offset < U32_MAX );
62916290
62926291 if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK ) {
62936292 unsigned long full_stripe_len =
@@ -6302,26 +6301,25 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op,
63026301 * to go rounddown(), not round_down(), as nr_data_stripes is
63036302 * not ensured to be power of 2.
63046303 */
6305- * full_stripe_start =
6306- btrfs_stripe_nr_to_offset (
6307- rounddown (* stripe_nr , nr_data_stripes (map )));
6304+ io_geom -> raid56_full_stripe_start = btrfs_stripe_nr_to_offset (
6305+ rounddown (io_geom -> stripe_nr , nr_data_stripes (map )));
63086306
6309- ASSERT (* full_stripe_start + full_stripe_len > offset );
6310- ASSERT (* full_stripe_start <= offset );
6307+ ASSERT (io_geom -> raid56_full_stripe_start + full_stripe_len > offset );
6308+ ASSERT (io_geom -> raid56_full_stripe_start <= offset );
63116309 /*
63126310 * For writes to RAID56, allow to write a full stripe set, but
63136311 * no straddling of stripe sets.
63146312 */
6315- if (op == BTRFS_MAP_WRITE )
6316- return full_stripe_len - (offset - * full_stripe_start );
6313+ if (io_geom -> op == BTRFS_MAP_WRITE )
6314+ return full_stripe_len - (offset - io_geom -> raid56_full_stripe_start );
63176315 }
63186316
63196317 /*
63206318 * For other RAID types and for RAID56 reads, allow a single stripe (on
63216319 * a single disk).
63226320 */
63236321 if (map -> type & BTRFS_BLOCK_GROUP_STRIPE_MASK )
6324- return BTRFS_STRIPE_LEN - * stripe_offset ;
6322+ return BTRFS_STRIPE_LEN - io_geom -> stripe_offset ;
63256323 return U64_MAX ;
63266324}
63276325
@@ -6564,9 +6562,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
65646562
65656563 map_offset = logical - map -> start ;
65666564 io_geom .raid56_full_stripe_start = (u64 )- 1 ;
6567- max_len = btrfs_max_io_len (map , io_geom .op , map_offset , & io_geom .stripe_nr ,
6568- & io_geom .stripe_offset ,
6569- & io_geom .raid56_full_stripe_start );
6565+ max_len = btrfs_max_io_len (map , map_offset , & io_geom );
65706566 * length = min_t (u64 , map -> chunk_len - map_offset , max_len );
65716567
65726568 down_read (& dev_replace -> rwsem );
0 commit comments