@@ -598,7 +598,7 @@ static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans,
598598static noinline int remove_extent_data_ref (struct btrfs_trans_handle * trans ,
599599 struct btrfs_root * root ,
600600 struct btrfs_path * path ,
601- int refs_to_drop , int * last_ref )
601+ int refs_to_drop )
602602{
603603 struct btrfs_key key ;
604604 struct btrfs_extent_data_ref * ref1 = NULL ;
@@ -631,7 +631,6 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
631631
632632 if (num_refs == 0 ) {
633633 ret = btrfs_del_item (trans , root , path );
634- * last_ref = 1 ;
635634 } else {
636635 if (key .type == BTRFS_EXTENT_DATA_REF_KEY )
637636 btrfs_set_extent_data_ref_count (leaf , ref1 , num_refs );
@@ -1072,8 +1071,7 @@ static noinline_for_stack
10721071void update_inline_extent_backref (struct btrfs_path * path ,
10731072 struct btrfs_extent_inline_ref * iref ,
10741073 int refs_to_mod ,
1075- struct btrfs_delayed_extent_op * extent_op ,
1076- int * last_ref )
1074+ struct btrfs_delayed_extent_op * extent_op )
10771075{
10781076 struct extent_buffer * leaf = path -> nodes [0 ];
10791077 struct btrfs_extent_item * ei ;
@@ -1121,7 +1119,6 @@ void update_inline_extent_backref(struct btrfs_path *path,
11211119 else
11221120 btrfs_set_shared_data_ref_count (leaf , sref , refs );
11231121 } else {
1124- * last_ref = 1 ;
11251122 size = btrfs_extent_inline_ref_size (type );
11261123 item_size = btrfs_item_size (leaf , path -> slots [0 ]);
11271124 ptr = (unsigned long )iref ;
@@ -1166,8 +1163,7 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans,
11661163 }
11671164 return - EUCLEAN ;
11681165 }
1169- update_inline_extent_backref (path , iref , refs_to_add ,
1170- extent_op , NULL );
1166+ update_inline_extent_backref (path , iref , refs_to_add , extent_op );
11711167 } else if (ret == - ENOENT ) {
11721168 setup_inline_extent_backref (trans -> fs_info , path , iref , parent ,
11731169 root_objectid , owner , offset ,
@@ -1181,21 +1177,17 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
11811177 struct btrfs_root * root ,
11821178 struct btrfs_path * path ,
11831179 struct btrfs_extent_inline_ref * iref ,
1184- int refs_to_drop , int is_data , int * last_ref )
1180+ int refs_to_drop , int is_data )
11851181{
11861182 int ret = 0 ;
11871183
11881184 BUG_ON (!is_data && refs_to_drop != 1 );
1189- if (iref ) {
1190- update_inline_extent_backref (path , iref , - refs_to_drop , NULL ,
1191- last_ref );
1192- } else if (is_data ) {
1193- ret = remove_extent_data_ref (trans , root , path , refs_to_drop ,
1194- last_ref );
1195- } else {
1196- * last_ref = 1 ;
1185+ if (iref )
1186+ update_inline_extent_backref (path , iref , - refs_to_drop , NULL );
1187+ else if (is_data )
1188+ ret = remove_extent_data_ref (trans , root , path , refs_to_drop );
1189+ else
11971190 ret = btrfs_del_item (trans , root , path );
1198- }
11991191 return ret ;
12001192}
12011193
@@ -2942,7 +2934,6 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
29422934 u64 refs ;
29432935 u64 bytenr = node -> bytenr ;
29442936 u64 num_bytes = node -> num_bytes ;
2945- int last_ref = 0 ;
29462937 bool skinny_metadata = btrfs_fs_incompat (info , SKINNY_METADATA );
29472938
29482939 extent_root = btrfs_extent_root (info , bytenr );
@@ -3009,8 +3000,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
30093000 }
30103001 /* Must be SHARED_* item, remove the backref first */
30113002 ret = remove_extent_backref (trans , extent_root , path ,
3012- NULL , refs_to_drop , is_data ,
3013- & last_ref );
3003+ NULL , refs_to_drop , is_data );
30143004 if (ret ) {
30153005 btrfs_abort_transaction (trans , ret );
30163006 goto out ;
@@ -3135,8 +3125,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
31353125 }
31363126 if (found_extent ) {
31373127 ret = remove_extent_backref (trans , extent_root , path ,
3138- iref , refs_to_drop , is_data ,
3139- & last_ref );
3128+ iref , refs_to_drop , is_data );
31403129 if (ret ) {
31413130 btrfs_abort_transaction (trans , ret );
31423131 goto out ;
@@ -3181,7 +3170,6 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
31813170 }
31823171 }
31833172
3184- last_ref = 1 ;
31853173 ret = btrfs_del_items (trans , extent_root , path , path -> slots [0 ],
31863174 num_to_del );
31873175 if (ret ) {
0 commit comments