@@ -5125,7 +5125,7 @@ static void init_alloc_chunk_ctl_policy_regular(
51255125 /* We don't want a chunk larger than 10% of writable space */
51265126 ctl -> max_chunk_size = min (mult_perc (fs_devices -> total_rw_bytes , 10 ),
51275127 ctl -> max_chunk_size );
5128- ctl -> dev_extent_min = ctl -> dev_stripes << BTRFS_STRIPE_LEN_SHIFT ;
5128+ ctl -> dev_extent_min = btrfs_stripe_nr_to_offset ( ctl -> dev_stripes ) ;
51295129}
51305130
51315131static void init_alloc_chunk_ctl_policy_zoned (
@@ -5801,7 +5801,7 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
58015801 if (!WARN_ON (IS_ERR (em ))) {
58025802 map = em -> map_lookup ;
58035803 if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK )
5804- len = nr_data_stripes (map ) << BTRFS_STRIPE_LEN_SHIFT ;
5804+ len = btrfs_stripe_nr_to_offset ( nr_data_stripes (map )) ;
58055805 free_extent_map (em );
58065806 }
58075807 return len ;
@@ -5975,12 +5975,12 @@ struct btrfs_discard_stripe *btrfs_map_discard(struct btrfs_fs_info *fs_info,
59755975 stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT ;
59765976
59775977 /* stripe_offset is the offset of this block in its stripe */
5978- stripe_offset = offset - (( u64 ) stripe_nr << BTRFS_STRIPE_LEN_SHIFT );
5978+ stripe_offset = offset - btrfs_stripe_nr_to_offset ( stripe_nr );
59795979
59805980 stripe_nr_end = round_up (offset + length , BTRFS_STRIPE_LEN ) >>
59815981 BTRFS_STRIPE_LEN_SHIFT ;
59825982 stripe_cnt = stripe_nr_end - stripe_nr ;
5983- stripe_end_offset = (( u64 ) stripe_nr_end << BTRFS_STRIPE_LEN_SHIFT ) -
5983+ stripe_end_offset = btrfs_stripe_nr_to_offset ( stripe_nr_end ) -
59845984 (offset + length );
59855985 /*
59865986 * after this, stripe_nr is the number of stripes on this
@@ -6023,12 +6023,12 @@ struct btrfs_discard_stripe *btrfs_map_discard(struct btrfs_fs_info *fs_info,
60236023 for (i = 0 ; i < * num_stripes ; i ++ ) {
60246024 stripes [i ].physical =
60256025 map -> stripes [stripe_index ].physical +
6026- stripe_offset + (( u64 ) stripe_nr << BTRFS_STRIPE_LEN_SHIFT );
6026+ stripe_offset + btrfs_stripe_nr_to_offset ( stripe_nr );
60276027 stripes [i ].dev = map -> stripes [stripe_index ].dev ;
60286028
60296029 if (map -> type & (BTRFS_BLOCK_GROUP_RAID0 |
60306030 BTRFS_BLOCK_GROUP_RAID10 )) {
6031- stripes [i ].length = stripes_per_dev << BTRFS_STRIPE_LEN_SHIFT ;
6031+ stripes [i ].length = btrfs_stripe_nr_to_offset ( stripes_per_dev ) ;
60326032
60336033 if (i / sub_stripes < remaining_stripes )
60346034 stripes [i ].length += BTRFS_STRIPE_LEN ;
@@ -6183,8 +6183,8 @@ static u64 btrfs_max_io_len(struct map_lookup *map, enum btrfs_map_op op,
61836183 ASSERT (* stripe_offset < U32_MAX );
61846184
61856185 if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK ) {
6186- unsigned long full_stripe_len = nr_data_stripes ( map ) <<
6187- BTRFS_STRIPE_LEN_SHIFT ;
6186+ unsigned long full_stripe_len =
6187+ btrfs_stripe_nr_to_offset ( nr_data_stripes ( map )) ;
61886188
61896189 /*
61906190 * For full stripe start, we use previously calculated
@@ -6196,8 +6196,8 @@ static u64 btrfs_max_io_len(struct map_lookup *map, enum btrfs_map_op op,
61966196 * not ensured to be power of 2.
61976197 */
61986198 * full_stripe_start =
6199- ( u64 ) rounddown ( * stripe_nr , nr_data_stripes ( map )) <<
6200- BTRFS_STRIPE_LEN_SHIFT ;
6199+ btrfs_stripe_nr_to_offset (
6200+ rounddown ( * stripe_nr , nr_data_stripes ( map ))) ;
62016201
62026202 ASSERT (* full_stripe_start + full_stripe_len > offset );
62036203 ASSERT (* full_stripe_start <= offset );
@@ -6223,7 +6223,7 @@ static void set_io_stripe(struct btrfs_io_stripe *dst, const struct map_lookup *
62236223{
62246224 dst -> dev = map -> stripes [stripe_index ].dev ;
62256225 dst -> physical = map -> stripes [stripe_index ].physical +
6226- stripe_offset + (( u64 ) stripe_nr << BTRFS_STRIPE_LEN_SHIFT );
6226+ stripe_offset + btrfs_stripe_nr_to_offset ( stripe_nr );
62276227}
62286228
62296229int __btrfs_map_block (struct btrfs_fs_info * fs_info , enum btrfs_map_op op ,
@@ -6345,7 +6345,8 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
63456345 /* Return the length to the full stripe end */
63466346 * length = min (logical + * length ,
63476347 raid56_full_stripe_start + em -> start +
6348- (data_stripes << BTRFS_STRIPE_LEN_SHIFT )) - logical ;
6348+ btrfs_stripe_nr_to_offset (data_stripes )) -
6349+ logical ;
63496350 stripe_index = 0 ;
63506351 stripe_offset = 0 ;
63516352 } else {
@@ -6435,7 +6436,7 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
64356436 * modulo, to reduce one modulo call.
64366437 */
64376438 bioc -> full_stripe_logical = em -> start +
6438- (( stripe_nr * data_stripes ) << BTRFS_STRIPE_LEN_SHIFT );
6439+ btrfs_stripe_nr_to_offset ( stripe_nr * data_stripes );
64396440 for (i = 0 ; i < num_stripes ; i ++ )
64406441 set_io_stripe (& bioc -> stripes [i ], map ,
64416442 (i + stripe_nr ) % num_stripes ,
@@ -8032,7 +8033,7 @@ static void map_raid56_repair_block(struct btrfs_io_context *bioc,
80328033
80338034 for (i = 0 ; i < data_stripes ; i ++ ) {
80348035 u64 stripe_start = bioc -> full_stripe_logical +
8035- ( i << BTRFS_STRIPE_LEN_SHIFT );
8036+ btrfs_stripe_nr_to_offset ( i );
80368037
80378038 if (logical >= stripe_start &&
80388039 logical < stripe_start + BTRFS_STRIPE_LEN )
0 commit comments