Skip to content

Commit e15acc2

Browse files
naotakdave
authored andcommitted
btrfs: zoned: drop space_info->active_total_bytes
The space_info->active_total_bytes is no longer necessary as we now count the region of newly allocated block group as zone_unusable. Drop its usage. Fixes: 6a921de ("btrfs: zoned: introduce space_info->active_total_bytes") CC: [email protected] # 6.1+ Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fa2068d commit e15acc2

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

fs/btrfs/block-group.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,14 +1175,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
11751175
< block_group->zone_unusable);
11761176
WARN_ON(block_group->space_info->disk_total
11771177
< block_group->length * factor);
1178-
WARN_ON(test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
1179-
&block_group->runtime_flags) &&
1180-
block_group->space_info->active_total_bytes
1181-
< block_group->length);
11821178
}
11831179
block_group->space_info->total_bytes -= block_group->length;
1184-
if (test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &block_group->runtime_flags))
1185-
block_group->space_info->active_total_bytes -= block_group->length;
11861180
block_group->space_info->bytes_readonly -=
11871181
(block_group->length - block_group->zone_unusable);
11881182
block_group->space_info->bytes_zone_unusable -=

fs/btrfs/space-info.c

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
398380
int 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;

fs/btrfs/space-info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ struct btrfs_space_info {
9696
u64 bytes_may_use; /* number of bytes that may be used for
9797
delalloc/allocations */
9898
u64 bytes_readonly; /* total bytes that are read only */
99-
/* Total bytes in the space, but only accounts active block groups. */
100-
u64 active_total_bytes;
10199
u64 bytes_zone_unusable; /* total bytes that are unusable until
102100
resetting the device zone */
103101

fs/btrfs/zoned.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,10 +2316,6 @@ int btrfs_zoned_activate_one_bg(struct btrfs_fs_info *fs_info,
23162316
if (!btrfs_is_zoned(fs_info) || (space_info->flags & BTRFS_BLOCK_GROUP_DATA))
23172317
return 0;
23182318

2319-
/* No more block groups to activate */
2320-
if (space_info->active_total_bytes == space_info->total_bytes)
2321-
return 0;
2322-
23232319
for (;;) {
23242320
int ret;
23252321
bool need_finish = false;

0 commit comments

Comments
 (0)