@@ -821,7 +821,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
821821 u64 bytenr , u64 num_bytes )
822822{
823823 struct btrfs_root * root = BTRFS_I (reloc_inode )-> root ;
824- struct btrfs_path * path ;
824+ BTRFS_PATH_AUTO_FREE ( path ) ;
825825 struct btrfs_file_extent_item * fi ;
826826 struct extent_buffer * leaf ;
827827 int ret ;
@@ -834,11 +834,9 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
834834 ret = btrfs_lookup_file_extent (NULL , root , path ,
835835 btrfs_ino (BTRFS_I (reloc_inode )), bytenr , 0 );
836836 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 ;
842840
843841 leaf = path -> nodes [0 ];
844842 fi = btrfs_item_ptr (leaf , path -> slots [0 ],
@@ -849,16 +847,11 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
849847 btrfs_file_extent_encryption (leaf , fi ) ||
850848 btrfs_file_extent_other_encoding (leaf , fi ));
851849
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 ;
856852
857853 * 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 ;
862855}
863856
864857/*
@@ -3158,7 +3151,7 @@ static int __add_tree_block(struct reloc_control *rc,
31583151 struct rb_root * blocks )
31593152{
31603153 struct btrfs_fs_info * fs_info = rc -> extent_root -> fs_info ;
3161- struct btrfs_path * path ;
3154+ BTRFS_PATH_AUTO_FREE ( path ) ;
31623155 struct btrfs_key key ;
31633156 int ret ;
31643157 bool skinny = btrfs_fs_incompat (fs_info , SKINNY_METADATA );
@@ -3186,7 +3179,7 @@ static int __add_tree_block(struct reloc_control *rc,
31863179 path -> skip_locking = 1 ;
31873180 ret = btrfs_search_slot (NULL , rc -> extent_root , & key , path , 0 , 0 );
31883181 if (ret < 0 )
3189- goto out ;
3182+ return ret ;
31903183
31913184 if (ret > 0 && skinny ) {
31923185 if (path -> slots [0 ]) {
@@ -3213,14 +3206,10 @@ static int __add_tree_block(struct reloc_control *rc,
32133206 "tree block extent item (%llu) is not found in extent tree" ,
32143207 bytenr );
32153208 WARN_ON (1 );
3216- ret = - EINVAL ;
3217- goto out ;
3209+ return - EINVAL ;
32183210 }
32193211
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 );
32243213}
32253214
32263215static 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)
35103499 struct rb_root blocks = RB_ROOT ;
35113500 struct btrfs_key key ;
35123501 struct btrfs_trans_handle * trans = NULL ;
3513- struct btrfs_path * path ;
3502+ BTRFS_PATH_AUTO_FREE ( path ) ;
35143503 struct btrfs_extent_item * ei ;
35153504 u64 flags ;
35163505 int ret ;
@@ -3679,14 +3668,13 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
36793668 if (ret < 0 && !err )
36803669 err = ret ;
36813670 btrfs_free_block_rsv (fs_info , rc -> block_rsv );
3682- btrfs_free_path (path );
36833671 return err ;
36843672}
36853673
36863674static int __insert_orphan_inode (struct btrfs_trans_handle * trans ,
36873675 struct btrfs_root * root , u64 objectid )
36883676{
3689- struct btrfs_path * path ;
3677+ BTRFS_PATH_AUTO_FREE ( path ) ;
36903678 struct btrfs_inode_item * item ;
36913679 struct extent_buffer * leaf ;
36923680 int ret ;
@@ -3697,7 +3685,7 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
36973685
36983686 ret = btrfs_insert_empty_inode (trans , root , path , objectid );
36993687 if (ret )
3700- goto out ;
3688+ return ret ;
37013689
37023690 leaf = path -> nodes [0 ];
37033691 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,
37073695 btrfs_set_inode_mode (leaf , item , S_IFREG | 0600 );
37083696 btrfs_set_inode_flags (leaf , item , BTRFS_INODE_NOCOMPRESS |
37093697 BTRFS_INODE_PREALLOC );
3710- out :
3711- btrfs_free_path (path );
3712- return ret ;
3698+ return 0 ;
37133699}
37143700
37153701static void delete_orphan_inode (struct btrfs_trans_handle * trans ,
37163702 struct btrfs_root * root , u64 objectid )
37173703{
3718- struct btrfs_path * path ;
3704+ BTRFS_PATH_AUTO_FREE ( path ) ;
37193705 struct btrfs_key key ;
37203706 int ret = 0 ;
37213707
@@ -3738,7 +3724,6 @@ static void delete_orphan_inode(struct btrfs_trans_handle *trans,
37383724out :
37393725 if (ret )
37403726 btrfs_abort_transaction (trans , ret );
3741- btrfs_free_path (path );
37423727}
37433728
37443729/*
0 commit comments