btrfs: change block group reclaim_mark to bool

The reclaim_mark field in struct btrfs_block_group was a u64 that was
incremented when marking block groups for reclaim during sweeping, but
the actual counter value was never used - only the zero/non-zero state
mattered for determining if a block group needed reclaim.

Convert it to a bool to properly reflect its usage and reduce memory
footprint by 8 bytes. Update assignments to use true/false instead of
increment and zero.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Sun YangKai <sunk67188@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Sun YangKai 2026-06-24 12:02:27 +08:00 committed by David Sterba
parent 77038da5a9
commit c5ac19b985
3 changed files with 5 additions and 3 deletions

View File

@ -3922,7 +3922,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
old_val += num_bytes;
cache->used = old_val;
cache->reserved -= num_bytes;
cache->reclaim_mark = 0;
cache->reclaim_mark = false;
space_info->bytes_reserved -= num_bytes;
space_info->bytes_used += num_bytes;
space_info->disk_used += num_bytes * factor;

View File

@ -263,6 +263,9 @@ struct btrfs_block_group {
enum btrfs_block_group_size_class size_class:8;
/* If set, this blockgroup is not used for allocation between two reclaim sweeps. */
bool reclaim_mark;
/*
* Number of extents in this block group used for swap files.
* All accesses protected by the spinlock 'lock'.
@ -281,7 +284,6 @@ struct btrfs_block_group {
struct list_head active_bg_list;
struct work_struct zone_finish_work;
struct extent_buffer *last_eb;
u64 reclaim_mark;
};
static inline u64 btrfs_block_group_end(const struct btrfs_block_group *block_group)

View File

@ -2156,7 +2156,7 @@ static bool do_reclaim_sweep(struct btrfs_space_info *space_info, int raid)
will_reclaim = true;
reclaim = true;
}
bg->reclaim_mark++;
bg->reclaim_mark = true;
spin_unlock(&bg->lock);
if (reclaim)
btrfs_mark_bg_to_reclaim(bg);