@@ -308,8 +308,6 @@ void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
308308 ASSERT (found );
309309 spin_lock (& found -> lock );
310310 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 ;
313311 found -> disk_total += block_group -> length * factor ;
314312 found -> bytes_used += block_group -> used ;
315313 found -> disk_used += block_group -> used * factor ;
@@ -379,22 +377,6 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info,
379377 return avail ;
380378}
381379
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-
398380int btrfs_can_overcommit (struct btrfs_fs_info * fs_info ,
399381 struct btrfs_space_info * space_info , u64 bytes ,
400382 enum btrfs_reserve_flush_enum flush )
@@ -413,7 +395,7 @@ int btrfs_can_overcommit(struct btrfs_fs_info *fs_info,
413395 else
414396 avail = calc_available_free_space (fs_info , space_info , flush );
415397
416- if (used + bytes < writable_total_bytes ( fs_info , space_info ) + avail )
398+ if (used + bytes < space_info -> total_bytes + avail )
417399 return 1 ;
418400 return 0 ;
419401}
@@ -449,7 +431,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info,
449431 ticket = list_first_entry (head , struct reserve_ticket , list );
450432
451433 /* 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 ) ||
453435 btrfs_can_overcommit (fs_info , space_info , ticket -> bytes ,
454436 flush )) {
455437 btrfs_space_info_update_bytes_may_use (fs_info ,
@@ -829,7 +811,6 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
829811{
830812 u64 used ;
831813 u64 avail ;
832- u64 total ;
833814 u64 to_reclaim = space_info -> reclaim_size ;
834815
835816 lockdep_assert_held (& space_info -> lock );
@@ -844,9 +825,8 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
844825 * space. If that's the case add in our overage so we make sure to put
845826 * appropriate pressure on the flushing state machine.
846827 */
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 );
850830
851831 return to_reclaim ;
852832}
@@ -856,11 +836,10 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,
856836{
857837 u64 global_rsv_size = fs_info -> global_block_rsv .reserved ;
858838 u64 ordered , delalloc ;
859- u64 total = writable_total_bytes (fs_info , space_info );
860839 u64 thresh ;
861840 u64 used ;
862841
863- thresh = mult_perc (total , 90 );
842+ thresh = mult_perc (space_info -> total_bytes , 90 );
864843
865844 lockdep_assert_held (& space_info -> lock );
866845
@@ -923,8 +902,8 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,
923902 BTRFS_RESERVE_FLUSH_ALL );
924903 used = space_info -> bytes_used + space_info -> bytes_reserved +
925904 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 ;
928907 thresh >>= space_info -> clamp ;
929908
930909 used = space_info -> bytes_pinned ;
@@ -1651,7 +1630,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
16511630 * can_overcommit() to ensure we can overcommit to continue.
16521631 */
16531632 if (!pending_tickets &&
1654- ((used + orig_bytes <= writable_total_bytes ( fs_info , space_info ) ) ||
1633+ ((used + orig_bytes <= space_info -> total_bytes ) ||
16551634 btrfs_can_overcommit (fs_info , space_info , orig_bytes , flush ))) {
16561635 btrfs_space_info_update_bytes_may_use (fs_info , space_info ,
16571636 orig_bytes );
@@ -1665,8 +1644,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
16651644 */
16661645 if (ret && unlikely (flush == BTRFS_RESERVE_FLUSH_EMERGENCY )) {
16671646 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 ) {
16701648 btrfs_space_info_update_bytes_may_use (fs_info , space_info ,
16711649 orig_bytes );
16721650 ret = 0 ;
0 commit comments