@@ -2885,7 +2885,6 @@ static void scrub_parity_put(struct scrub_parity *sparity)
2885
2885
static noinline_for_stack int scrub_raid56_parity (struct scrub_ctx * sctx ,
2886
2886
struct map_lookup * map ,
2887
2887
struct btrfs_device * sdev ,
2888
- struct btrfs_path * path ,
2889
2888
u64 logic_start ,
2890
2889
u64 logic_end )
2891
2890
{
@@ -2894,6 +2893,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
2894
2893
struct btrfs_root * csum_root ;
2895
2894
struct btrfs_extent_item * extent ;
2896
2895
struct btrfs_io_context * bioc = NULL ;
2896
+ struct btrfs_path * path ;
2897
2897
u64 flags ;
2898
2898
int ret ;
2899
2899
int slot ;
@@ -2912,6 +2912,16 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
2912
2912
int extent_mirror_num ;
2913
2913
int stop_loop = 0 ;
2914
2914
2915
+ path = btrfs_alloc_path ();
2916
+ if (!path ) {
2917
+ spin_lock (& sctx -> stat_lock );
2918
+ sctx -> stat .malloc_errors ++ ;
2919
+ spin_unlock (& sctx -> stat_lock );
2920
+ return - ENOMEM ;
2921
+ }
2922
+ path -> search_commit_root = 1 ;
2923
+ path -> skip_locking = 1 ;
2924
+
2915
2925
ASSERT (map -> stripe_len <= U32_MAX );
2916
2926
nsectors = map -> stripe_len >> fs_info -> sectorsize_bits ;
2917
2927
bitmap_len = scrub_calc_parity_bitmap_len (nsectors );
@@ -2921,6 +2931,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
2921
2931
spin_lock (& sctx -> stat_lock );
2922
2932
sctx -> stat .malloc_errors ++ ;
2923
2933
spin_unlock (& sctx -> stat_lock );
2934
+ btrfs_free_path (path );
2924
2935
return - ENOMEM ;
2925
2936
}
2926
2937
@@ -3110,7 +3121,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
3110
3121
scrub_wr_submit (sctx );
3111
3122
mutex_unlock (& sctx -> wr_lock );
3112
3123
3113
- btrfs_release_path (path );
3124
+ btrfs_free_path (path );
3114
3125
return ret < 0 ? ret : 0 ;
3115
3126
}
3116
3127
@@ -3160,7 +3171,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3160
3171
int num , u64 base , u64 length ,
3161
3172
struct btrfs_block_group * cache )
3162
3173
{
3163
- struct btrfs_path * path , * ppath ;
3174
+ struct btrfs_path * path ;
3164
3175
struct btrfs_fs_info * fs_info = sctx -> fs_info ;
3165
3176
struct btrfs_root * root ;
3166
3177
struct btrfs_root * csum_root ;
@@ -3222,12 +3233,6 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3222
3233
if (!path )
3223
3234
return - ENOMEM ;
3224
3235
3225
- ppath = btrfs_alloc_path ();
3226
- if (!ppath ) {
3227
- btrfs_free_path (path );
3228
- return - ENOMEM ;
3229
- }
3230
-
3231
3236
/*
3232
3237
* work on commit root. The related disk blocks are static as
3233
3238
* long as COW is applied. This means, it is save to rewrite
@@ -3236,8 +3241,6 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3236
3241
path -> search_commit_root = 1 ;
3237
3242
path -> skip_locking = 1 ;
3238
3243
3239
- ppath -> search_commit_root = 1 ;
3240
- ppath -> skip_locking = 1 ;
3241
3244
/*
3242
3245
* trigger the readahead for extent tree csum tree and wait for
3243
3246
* completion. During readahead, the scrub is officially paused
@@ -3340,7 +3343,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3340
3343
stripe_logical += base ;
3341
3344
stripe_end = stripe_logical + increment ;
3342
3345
ret = scrub_raid56_parity (sctx , map , scrub_dev ,
3343
- ppath , stripe_logical ,
3346
+ stripe_logical ,
3344
3347
stripe_end );
3345
3348
if (ret )
3346
3349
goto out ;
@@ -3511,7 +3514,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3511
3514
stripe_end = stripe_logical +
3512
3515
increment ;
3513
3516
ret = scrub_raid56_parity (sctx ,
3514
- map , scrub_dev , ppath ,
3517
+ map , scrub_dev ,
3515
3518
stripe_logical ,
3516
3519
stripe_end );
3517
3520
if (ret )
@@ -3558,7 +3561,6 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3558
3561
3559
3562
blk_finish_plug (& plug );
3560
3563
btrfs_free_path (path );
3561
- btrfs_free_path (ppath );
3562
3564
3563
3565
if (sctx -> is_dev_replace && ret >= 0 ) {
3564
3566
int ret2 ;
0 commit comments