@@ -2722,7 +2722,7 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
27222722
27232723 if (flags & BTRFS_EXTENT_FLAG_DATA ) {
27242724 if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK )
2725- blocksize = map -> stripe_len ;
2725+ blocksize = BTRFS_STRIPE_LEN ;
27262726 else
27272727 blocksize = sctx -> fs_info -> sectorsize ;
27282728 spin_lock (& sctx -> stat_lock );
@@ -2731,7 +2731,7 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
27312731 spin_unlock (& sctx -> stat_lock );
27322732 } else if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK ) {
27332733 if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK )
2734- blocksize = map -> stripe_len ;
2734+ blocksize = BTRFS_STRIPE_LEN ;
27352735 else
27362736 blocksize = sctx -> fs_info -> nodesize ;
27372737 spin_lock (& sctx -> stat_lock );
@@ -2920,9 +2920,9 @@ static int get_raid56_logic_offset(u64 physical, int num,
29202920
29212921 * offset = last_offset ;
29222922 for (i = 0 ; i < data_stripes ; i ++ ) {
2923- * offset = last_offset + i * map -> stripe_len ;
2923+ * offset = last_offset + ( i << BTRFS_STRIPE_LEN_SHIFT ) ;
29242924
2925- stripe_nr = div64_u64 ( * offset , map -> stripe_len ) ;
2925+ stripe_nr = * offset >> BTRFS_STRIPE_LEN_SHIFT ;
29262926 stripe_nr = div_u64 (stripe_nr , data_stripes );
29272927
29282928 /* Work out the disk rotation on this stripe-set */
@@ -2935,7 +2935,7 @@ static int get_raid56_logic_offset(u64 physical, int num,
29352935 if (stripe_index < num )
29362936 j ++ ;
29372937 }
2938- * offset = last_offset + j * map -> stripe_len ;
2938+ * offset = last_offset + ( j << BTRFS_STRIPE_LEN_SHIFT ) ;
29392939 return 1 ;
29402940}
29412941
@@ -3205,7 +3205,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
32053205 /* Path must not be populated */
32063206 ASSERT (!path -> nodes [0 ]);
32073207
3208- while (cur_logical < logical + map -> stripe_len ) {
3208+ while (cur_logical < logical + BTRFS_STRIPE_LEN ) {
32093209 struct btrfs_io_context * bioc = NULL ;
32103210 struct btrfs_device * extent_dev ;
32113211 u64 extent_start ;
@@ -3217,7 +3217,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
32173217 u64 extent_mirror_num ;
32183218
32193219 ret = find_first_extent_item (extent_root , path , cur_logical ,
3220- logical + map -> stripe_len - cur_logical );
3220+ logical + BTRFS_STRIPE_LEN - cur_logical );
32213221 /* No more extent item in this data stripe */
32223222 if (ret > 0 ) {
32233223 ret = 0 ;
@@ -3231,7 +3231,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
32313231 /* Metadata should not cross stripe boundaries */
32323232 if ((extent_flags & BTRFS_EXTENT_FLAG_TREE_BLOCK ) &&
32333233 does_range_cross_boundary (extent_start , extent_size ,
3234- logical , map -> stripe_len )) {
3234+ logical , BTRFS_STRIPE_LEN )) {
32353235 btrfs_err (fs_info ,
32363236 "scrub: tree block %llu spanning stripes, ignored. logical=%llu" ,
32373237 extent_start , logical );
@@ -3247,7 +3247,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
32473247
32483248 /* Truncate the range inside this data stripe */
32493249 extent_size = min (extent_start + extent_size ,
3250- logical + map -> stripe_len ) - cur_logical ;
3250+ logical + BTRFS_STRIPE_LEN ) - cur_logical ;
32513251 extent_start = cur_logical ;
32523252 ASSERT (extent_size <= U32_MAX );
32533253
@@ -3320,8 +3320,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
33203320 path -> search_commit_root = 1 ;
33213321 path -> skip_locking = 1 ;
33223322
3323- ASSERT (map -> stripe_len <= U32_MAX );
3324- nsectors = map -> stripe_len >> fs_info -> sectorsize_bits ;
3323+ nsectors = BTRFS_STRIPE_LEN >> fs_info -> sectorsize_bits ;
33253324 ASSERT (nsectors <= BITS_PER_LONG );
33263325 sparity = kzalloc (sizeof (struct scrub_parity ), GFP_NOFS );
33273326 if (!sparity ) {
@@ -3332,8 +3331,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
33323331 return - ENOMEM ;
33333332 }
33343333
3335- ASSERT (map -> stripe_len <= U32_MAX );
3336- sparity -> stripe_len = map -> stripe_len ;
3334+ sparity -> stripe_len = BTRFS_STRIPE_LEN ;
33373335 sparity -> nsectors = nsectors ;
33383336 sparity -> sctx = sctx ;
33393337 sparity -> scrub_dev = sdev ;
@@ -3344,7 +3342,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
33443342
33453343 ret = 0 ;
33463344 for (cur_logical = logic_start ; cur_logical < logic_end ;
3347- cur_logical += map -> stripe_len ) {
3345+ cur_logical += BTRFS_STRIPE_LEN ) {
33483346 ret = scrub_raid56_data_stripe_for_parity (sctx , sparity , map ,
33493347 sdev , path , cur_logical );
33503348 if (ret < 0 )
@@ -3536,7 +3534,7 @@ static u64 simple_stripe_full_stripe_len(const struct map_lookup *map)
35363534 ASSERT (map -> type & (BTRFS_BLOCK_GROUP_RAID0 |
35373535 BTRFS_BLOCK_GROUP_RAID10 ));
35383536
3539- return map -> num_stripes / map -> sub_stripes * map -> stripe_len ;
3537+ return ( map -> num_stripes / map -> sub_stripes ) << BTRFS_STRIPE_LEN_SHIFT ;
35403538}
35413539
35423540/* Get the logical bytenr for the stripe */
@@ -3552,7 +3550,8 @@ static u64 simple_stripe_get_logical(struct map_lookup *map,
35523550 * (stripe_index / sub_stripes) gives how many data stripes we need to
35533551 * skip.
35543552 */
3555- return (stripe_index / map -> sub_stripes ) * map -> stripe_len + bg -> start ;
3553+ return ((stripe_index / map -> sub_stripes ) << BTRFS_STRIPE_LEN_SHIFT ) +
3554+ bg -> start ;
35563555}
35573556
35583557/* Get the mirror number for the stripe */
@@ -3589,14 +3588,14 @@ static int scrub_simple_stripe(struct scrub_ctx *sctx,
35893588 * this stripe.
35903589 */
35913590 ret = scrub_simple_mirror (sctx , extent_root , csum_root , bg , map ,
3592- cur_logical , map -> stripe_len , device ,
3591+ cur_logical , BTRFS_STRIPE_LEN , device ,
35933592 cur_physical , mirror_num );
35943593 if (ret )
35953594 return ret ;
35963595 /* Skip to next stripe which belongs to the target device */
35973596 cur_logical += logical_increment ;
35983597 /* For physical offset, we just go to next stripe */
3599- cur_physical += map -> stripe_len ;
3598+ cur_physical += BTRFS_STRIPE_LEN ;
36003599 }
36013600 return ret ;
36023601}
@@ -3690,7 +3689,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
36903689 if (profile & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10 )) {
36913690 ret = scrub_simple_stripe (sctx , root , csum_root , bg , map ,
36923691 scrub_dev , stripe_index );
3693- offset = map -> stripe_len * (stripe_index / map -> sub_stripes );
3692+ offset = (stripe_index / map -> sub_stripes ) << BTRFS_STRIPE_LEN_SHIFT ;
36943693 goto out ;
36953694 }
36963695
@@ -3705,7 +3704,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
37053704
37063705 /* Initialize @offset in case we need to go to out: label */
37073706 get_raid56_logic_offset (physical , stripe_index , map , & offset , NULL );
3708- increment = map -> stripe_len * nr_data_stripes (map );
3707+ increment = nr_data_stripes (map ) << BTRFS_STRIPE_LEN_SHIFT ;
37093708
37103709 /*
37113710 * Due to the rotation, for RAID56 it's better to iterate each stripe
@@ -3736,13 +3735,13 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
37363735 * is still based on @mirror_num.
37373736 */
37383737 ret = scrub_simple_mirror (sctx , root , csum_root , bg , map ,
3739- logical , map -> stripe_len ,
3738+ logical , BTRFS_STRIPE_LEN ,
37403739 scrub_dev , physical , 1 );
37413740 if (ret < 0 )
37423741 goto out ;
37433742next :
37443743 logical += increment ;
3745- physical += map -> stripe_len ;
3744+ physical += BTRFS_STRIPE_LEN ;
37463745 spin_lock (& sctx -> stat_lock );
37473746 if (stop_loop )
37483747 sctx -> stat .last_physical =
0 commit comments