@@ -308,8 +308,6 @@ void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
308
308
ASSERT (found );
309
309
spin_lock (& found -> lock );
310
310
found -> total_bytes += block_group -> length ;
311
- if (test_bit (BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE , & block_group -> runtime_flags ))
312
- found -> active_total_bytes += block_group -> length ;
313
311
found -> disk_total += block_group -> length * factor ;
314
312
found -> bytes_used += block_group -> used ;
315
313
found -> disk_used += block_group -> used * factor ;
@@ -379,22 +377,6 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info,
379
377
return avail ;
380
378
}
381
379
382
- static inline u64 writable_total_bytes (struct btrfs_fs_info * fs_info ,
383
- struct btrfs_space_info * space_info )
384
- {
385
- /*
386
- * On regular filesystem, all total_bytes are always writable. On zoned
387
- * filesystem, there may be a limitation imposed by max_active_zones.
388
- * For metadata allocation, we cannot finish an existing active block
389
- * group to avoid a deadlock. Thus, we need to consider only the active
390
- * groups to be writable for metadata space.
391
- */
392
- if (!btrfs_is_zoned (fs_info ) || (space_info -> flags & BTRFS_BLOCK_GROUP_DATA ))
393
- return space_info -> total_bytes ;
394
-
395
- return space_info -> active_total_bytes ;
396
- }
397
-
398
380
int btrfs_can_overcommit (struct btrfs_fs_info * fs_info ,
399
381
struct btrfs_space_info * space_info , u64 bytes ,
400
382
enum btrfs_reserve_flush_enum flush )
@@ -413,7 +395,7 @@ int btrfs_can_overcommit(struct btrfs_fs_info *fs_info,
413
395
else
414
396
avail = calc_available_free_space (fs_info , space_info , flush );
415
397
416
- if (used + bytes < writable_total_bytes ( fs_info , space_info ) + avail )
398
+ if (used + bytes < space_info -> total_bytes + avail )
417
399
return 1 ;
418
400
return 0 ;
419
401
}
@@ -449,7 +431,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info,
449
431
ticket = list_first_entry (head , struct reserve_ticket , list );
450
432
451
433
/* Check and see if our ticket can be satisfied now. */
452
- if ((used + ticket -> bytes <= writable_total_bytes ( fs_info , space_info ) ) ||
434
+ if ((used + ticket -> bytes <= space_info -> total_bytes ) ||
453
435
btrfs_can_overcommit (fs_info , space_info , ticket -> bytes ,
454
436
flush )) {
455
437
btrfs_space_info_update_bytes_may_use (fs_info ,
@@ -829,7 +811,6 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
829
811
{
830
812
u64 used ;
831
813
u64 avail ;
832
- u64 total ;
833
814
u64 to_reclaim = space_info -> reclaim_size ;
834
815
835
816
lockdep_assert_held (& space_info -> lock );
@@ -844,9 +825,8 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
844
825
* space. If that's the case add in our overage so we make sure to put
845
826
* appropriate pressure on the flushing state machine.
846
827
*/
847
- total = writable_total_bytes (fs_info , space_info );
848
- if (total + avail < used )
849
- to_reclaim += used - (total + avail );
828
+ if (space_info -> total_bytes + avail < used )
829
+ to_reclaim += used - (space_info -> total_bytes + avail );
850
830
851
831
return to_reclaim ;
852
832
}
@@ -856,11 +836,10 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,
856
836
{
857
837
u64 global_rsv_size = fs_info -> global_block_rsv .reserved ;
858
838
u64 ordered , delalloc ;
859
- u64 total = writable_total_bytes (fs_info , space_info );
860
839
u64 thresh ;
861
840
u64 used ;
862
841
863
- thresh = mult_perc (total , 90 );
842
+ thresh = mult_perc (space_info -> total_bytes , 90 );
864
843
865
844
lockdep_assert_held (& space_info -> lock );
866
845
@@ -923,8 +902,8 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,
923
902
BTRFS_RESERVE_FLUSH_ALL );
924
903
used = space_info -> bytes_used + space_info -> bytes_reserved +
925
904
space_info -> bytes_readonly + global_rsv_size ;
926
- if (used < total )
927
- thresh += total - used ;
905
+ if (used < space_info -> total_bytes )
906
+ thresh += space_info -> total_bytes - used ;
928
907
thresh >>= space_info -> clamp ;
929
908
930
909
used = space_info -> bytes_pinned ;
@@ -1651,7 +1630,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
1651
1630
* can_overcommit() to ensure we can overcommit to continue.
1652
1631
*/
1653
1632
if (!pending_tickets &&
1654
- ((used + orig_bytes <= writable_total_bytes ( fs_info , space_info ) ) ||
1633
+ ((used + orig_bytes <= space_info -> total_bytes ) ||
1655
1634
btrfs_can_overcommit (fs_info , space_info , orig_bytes , flush ))) {
1656
1635
btrfs_space_info_update_bytes_may_use (fs_info , space_info ,
1657
1636
orig_bytes );
@@ -1665,8 +1644,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
1665
1644
*/
1666
1645
if (ret && unlikely (flush == BTRFS_RESERVE_FLUSH_EMERGENCY )) {
1667
1646
used = btrfs_space_info_used (space_info , false);
1668
- if (used + orig_bytes <=
1669
- writable_total_bytes (fs_info , space_info )) {
1647
+ if (used + orig_bytes <= space_info -> total_bytes ) {
1670
1648
btrfs_space_info_update_bytes_may_use (fs_info , space_info ,
1671
1649
orig_bytes );
1672
1650
ret = 0 ;
0 commit comments