@@ -821,7 +821,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
821
821
u64 bytenr , u64 num_bytes )
822
822
{
823
823
struct btrfs_root * root = BTRFS_I (reloc_inode )-> root ;
824
- struct btrfs_path * path ;
824
+ BTRFS_PATH_AUTO_FREE ( path ) ;
825
825
struct btrfs_file_extent_item * fi ;
826
826
struct extent_buffer * leaf ;
827
827
int ret ;
@@ -834,11 +834,9 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
834
834
ret = btrfs_lookup_file_extent (NULL , root , path ,
835
835
btrfs_ino (BTRFS_I (reloc_inode )), bytenr , 0 );
836
836
if (ret < 0 )
837
- goto out ;
838
- if (ret > 0 ) {
839
- ret = - ENOENT ;
840
- goto out ;
841
- }
837
+ return ret ;
838
+ if (ret > 0 )
839
+ return - ENOENT ;
842
840
843
841
leaf = path -> nodes [0 ];
844
842
fi = btrfs_item_ptr (leaf , path -> slots [0 ],
@@ -849,16 +847,11 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
849
847
btrfs_file_extent_encryption (leaf , fi ) ||
850
848
btrfs_file_extent_other_encoding (leaf , fi ));
851
849
852
- if (num_bytes != btrfs_file_extent_disk_num_bytes (leaf , fi )) {
853
- ret = - EINVAL ;
854
- goto out ;
855
- }
850
+ if (num_bytes != btrfs_file_extent_disk_num_bytes (leaf , fi ))
851
+ return - EINVAL ;
856
852
857
853
* new_bytenr = btrfs_file_extent_disk_bytenr (leaf , fi );
858
- ret = 0 ;
859
- out :
860
- btrfs_free_path (path );
861
- return ret ;
854
+ return 0 ;
862
855
}
863
856
864
857
/*
@@ -3158,7 +3151,7 @@ static int __add_tree_block(struct reloc_control *rc,
3158
3151
struct rb_root * blocks )
3159
3152
{
3160
3153
struct btrfs_fs_info * fs_info = rc -> extent_root -> fs_info ;
3161
- struct btrfs_path * path ;
3154
+ BTRFS_PATH_AUTO_FREE ( path ) ;
3162
3155
struct btrfs_key key ;
3163
3156
int ret ;
3164
3157
bool skinny = btrfs_fs_incompat (fs_info , SKINNY_METADATA );
@@ -3186,7 +3179,7 @@ static int __add_tree_block(struct reloc_control *rc,
3186
3179
path -> skip_locking = 1 ;
3187
3180
ret = btrfs_search_slot (NULL , rc -> extent_root , & key , path , 0 , 0 );
3188
3181
if (ret < 0 )
3189
- goto out ;
3182
+ return ret ;
3190
3183
3191
3184
if (ret > 0 && skinny ) {
3192
3185
if (path -> slots [0 ]) {
@@ -3213,14 +3206,10 @@ static int __add_tree_block(struct reloc_control *rc,
3213
3206
"tree block extent item (%llu) is not found in extent tree" ,
3214
3207
bytenr );
3215
3208
WARN_ON (1 );
3216
- ret = - EINVAL ;
3217
- goto out ;
3209
+ return - EINVAL ;
3218
3210
}
3219
3211
3220
- ret = add_tree_block (rc , & key , path , blocks );
3221
- out :
3222
- btrfs_free_path (path );
3223
- return ret ;
3212
+ return add_tree_block (rc , & key , path , blocks );
3224
3213
}
3225
3214
3226
3215
static int delete_block_group_cache (struct btrfs_block_group * block_group ,
@@ -3510,7 +3499,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3510
3499
struct rb_root blocks = RB_ROOT ;
3511
3500
struct btrfs_key key ;
3512
3501
struct btrfs_trans_handle * trans = NULL ;
3513
- struct btrfs_path * path ;
3502
+ BTRFS_PATH_AUTO_FREE ( path ) ;
3514
3503
struct btrfs_extent_item * ei ;
3515
3504
u64 flags ;
3516
3505
int ret ;
@@ -3679,14 +3668,13 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3679
3668
if (ret < 0 && !err )
3680
3669
err = ret ;
3681
3670
btrfs_free_block_rsv (fs_info , rc -> block_rsv );
3682
- btrfs_free_path (path );
3683
3671
return err ;
3684
3672
}
3685
3673
3686
3674
static int __insert_orphan_inode (struct btrfs_trans_handle * trans ,
3687
3675
struct btrfs_root * root , u64 objectid )
3688
3676
{
3689
- struct btrfs_path * path ;
3677
+ BTRFS_PATH_AUTO_FREE ( path ) ;
3690
3678
struct btrfs_inode_item * item ;
3691
3679
struct extent_buffer * leaf ;
3692
3680
int ret ;
@@ -3697,7 +3685,7 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
3697
3685
3698
3686
ret = btrfs_insert_empty_inode (trans , root , path , objectid );
3699
3687
if (ret )
3700
- goto out ;
3688
+ return ret ;
3701
3689
3702
3690
leaf = path -> nodes [0 ];
3703
3691
item = btrfs_item_ptr (leaf , path -> slots [0 ], struct btrfs_inode_item );
@@ -3707,15 +3695,13 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
3707
3695
btrfs_set_inode_mode (leaf , item , S_IFREG | 0600 );
3708
3696
btrfs_set_inode_flags (leaf , item , BTRFS_INODE_NOCOMPRESS |
3709
3697
BTRFS_INODE_PREALLOC );
3710
- out :
3711
- btrfs_free_path (path );
3712
- return ret ;
3698
+ return 0 ;
3713
3699
}
3714
3700
3715
3701
static void delete_orphan_inode (struct btrfs_trans_handle * trans ,
3716
3702
struct btrfs_root * root , u64 objectid )
3717
3703
{
3718
- struct btrfs_path * path ;
3704
+ BTRFS_PATH_AUTO_FREE ( path ) ;
3719
3705
struct btrfs_key key ;
3720
3706
int ret = 0 ;
3721
3707
@@ -3738,7 +3724,6 @@ static void delete_orphan_inode(struct btrfs_trans_handle *trans,
3738
3724
out :
3739
3725
if (ret )
3740
3726
btrfs_abort_transaction (trans , ret );
3741
- btrfs_free_path (path );
3742
3727
}
3743
3728
3744
3729
/*
0 commit comments