@@ -2722,7 +2722,7 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
2722
2722
2723
2723
if (flags & BTRFS_EXTENT_FLAG_DATA ) {
2724
2724
if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK )
2725
- blocksize = map -> stripe_len ;
2725
+ blocksize = BTRFS_STRIPE_LEN ;
2726
2726
else
2727
2727
blocksize = sctx -> fs_info -> sectorsize ;
2728
2728
spin_lock (& sctx -> stat_lock );
@@ -2731,7 +2731,7 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
2731
2731
spin_unlock (& sctx -> stat_lock );
2732
2732
} else if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK ) {
2733
2733
if (map -> type & BTRFS_BLOCK_GROUP_RAID56_MASK )
2734
- blocksize = map -> stripe_len ;
2734
+ blocksize = BTRFS_STRIPE_LEN ;
2735
2735
else
2736
2736
blocksize = sctx -> fs_info -> nodesize ;
2737
2737
spin_lock (& sctx -> stat_lock );
@@ -2920,9 +2920,9 @@ static int get_raid56_logic_offset(u64 physical, int num,
2920
2920
2921
2921
* offset = last_offset ;
2922
2922
for (i = 0 ; i < data_stripes ; i ++ ) {
2923
- * offset = last_offset + i * map -> stripe_len ;
2923
+ * offset = last_offset + ( i << BTRFS_STRIPE_LEN_SHIFT ) ;
2924
2924
2925
- stripe_nr = div64_u64 ( * offset , map -> stripe_len ) ;
2925
+ stripe_nr = * offset >> BTRFS_STRIPE_LEN_SHIFT ;
2926
2926
stripe_nr = div_u64 (stripe_nr , data_stripes );
2927
2927
2928
2928
/* Work out the disk rotation on this stripe-set */
@@ -2935,7 +2935,7 @@ static int get_raid56_logic_offset(u64 physical, int num,
2935
2935
if (stripe_index < num )
2936
2936
j ++ ;
2937
2937
}
2938
- * offset = last_offset + j * map -> stripe_len ;
2938
+ * offset = last_offset + ( j << BTRFS_STRIPE_LEN_SHIFT ) ;
2939
2939
return 1 ;
2940
2940
}
2941
2941
@@ -3205,7 +3205,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
3205
3205
/* Path must not be populated */
3206
3206
ASSERT (!path -> nodes [0 ]);
3207
3207
3208
- while (cur_logical < logical + map -> stripe_len ) {
3208
+ while (cur_logical < logical + BTRFS_STRIPE_LEN ) {
3209
3209
struct btrfs_io_context * bioc = NULL ;
3210
3210
struct btrfs_device * extent_dev ;
3211
3211
u64 extent_start ;
@@ -3217,7 +3217,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
3217
3217
u64 extent_mirror_num ;
3218
3218
3219
3219
ret = find_first_extent_item (extent_root , path , cur_logical ,
3220
- logical + map -> stripe_len - cur_logical );
3220
+ logical + BTRFS_STRIPE_LEN - cur_logical );
3221
3221
/* No more extent item in this data stripe */
3222
3222
if (ret > 0 ) {
3223
3223
ret = 0 ;
@@ -3231,7 +3231,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
3231
3231
/* Metadata should not cross stripe boundaries */
3232
3232
if ((extent_flags & BTRFS_EXTENT_FLAG_TREE_BLOCK ) &&
3233
3233
does_range_cross_boundary (extent_start , extent_size ,
3234
- logical , map -> stripe_len )) {
3234
+ logical , BTRFS_STRIPE_LEN )) {
3235
3235
btrfs_err (fs_info ,
3236
3236
"scrub: tree block %llu spanning stripes, ignored. logical=%llu" ,
3237
3237
extent_start , logical );
@@ -3247,7 +3247,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
3247
3247
3248
3248
/* Truncate the range inside this data stripe */
3249
3249
extent_size = min (extent_start + extent_size ,
3250
- logical + map -> stripe_len ) - cur_logical ;
3250
+ logical + BTRFS_STRIPE_LEN ) - cur_logical ;
3251
3251
extent_start = cur_logical ;
3252
3252
ASSERT (extent_size <= U32_MAX );
3253
3253
@@ -3320,8 +3320,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
3320
3320
path -> search_commit_root = 1 ;
3321
3321
path -> skip_locking = 1 ;
3322
3322
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 ;
3325
3324
ASSERT (nsectors <= BITS_PER_LONG );
3326
3325
sparity = kzalloc (sizeof (struct scrub_parity ), GFP_NOFS );
3327
3326
if (!sparity ) {
@@ -3332,8 +3331,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
3332
3331
return - ENOMEM ;
3333
3332
}
3334
3333
3335
- ASSERT (map -> stripe_len <= U32_MAX );
3336
- sparity -> stripe_len = map -> stripe_len ;
3334
+ sparity -> stripe_len = BTRFS_STRIPE_LEN ;
3337
3335
sparity -> nsectors = nsectors ;
3338
3336
sparity -> sctx = sctx ;
3339
3337
sparity -> scrub_dev = sdev ;
@@ -3344,7 +3342,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
3344
3342
3345
3343
ret = 0 ;
3346
3344
for (cur_logical = logic_start ; cur_logical < logic_end ;
3347
- cur_logical += map -> stripe_len ) {
3345
+ cur_logical += BTRFS_STRIPE_LEN ) {
3348
3346
ret = scrub_raid56_data_stripe_for_parity (sctx , sparity , map ,
3349
3347
sdev , path , cur_logical );
3350
3348
if (ret < 0 )
@@ -3536,7 +3534,7 @@ static u64 simple_stripe_full_stripe_len(const struct map_lookup *map)
3536
3534
ASSERT (map -> type & (BTRFS_BLOCK_GROUP_RAID0 |
3537
3535
BTRFS_BLOCK_GROUP_RAID10 ));
3538
3536
3539
- return map -> num_stripes / map -> sub_stripes * map -> stripe_len ;
3537
+ return ( map -> num_stripes / map -> sub_stripes ) << BTRFS_STRIPE_LEN_SHIFT ;
3540
3538
}
3541
3539
3542
3540
/* Get the logical bytenr for the stripe */
@@ -3552,7 +3550,8 @@ static u64 simple_stripe_get_logical(struct map_lookup *map,
3552
3550
* (stripe_index / sub_stripes) gives how many data stripes we need to
3553
3551
* skip.
3554
3552
*/
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 ;
3556
3555
}
3557
3556
3558
3557
/* Get the mirror number for the stripe */
@@ -3589,14 +3588,14 @@ static int scrub_simple_stripe(struct scrub_ctx *sctx,
3589
3588
* this stripe.
3590
3589
*/
3591
3590
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 ,
3593
3592
cur_physical , mirror_num );
3594
3593
if (ret )
3595
3594
return ret ;
3596
3595
/* Skip to next stripe which belongs to the target device */
3597
3596
cur_logical += logical_increment ;
3598
3597
/* For physical offset, we just go to next stripe */
3599
- cur_physical += map -> stripe_len ;
3598
+ cur_physical += BTRFS_STRIPE_LEN ;
3600
3599
}
3601
3600
return ret ;
3602
3601
}
@@ -3690,7 +3689,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3690
3689
if (profile & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10 )) {
3691
3690
ret = scrub_simple_stripe (sctx , root , csum_root , bg , map ,
3692
3691
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 ;
3694
3693
goto out ;
3695
3694
}
3696
3695
@@ -3705,7 +3704,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3705
3704
3706
3705
/* Initialize @offset in case we need to go to out: label */
3707
3706
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 ;
3709
3708
3710
3709
/*
3711
3710
* 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,
3736
3735
* is still based on @mirror_num.
3737
3736
*/
3738
3737
ret = scrub_simple_mirror (sctx , root , csum_root , bg , map ,
3739
- logical , map -> stripe_len ,
3738
+ logical , BTRFS_STRIPE_LEN ,
3740
3739
scrub_dev , physical , 1 );
3741
3740
if (ret < 0 )
3742
3741
goto out ;
3743
3742
next :
3744
3743
logical += increment ;
3745
- physical += map -> stripe_len ;
3744
+ physical += BTRFS_STRIPE_LEN ;
3746
3745
spin_lock (& sctx -> stat_lock );
3747
3746
if (stop_loop )
3748
3747
sctx -> stat .last_physical =
0 commit comments