From: Sun YangKai <sunk67188@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Sun YangKai <sunk67188@gmail.com>
Subject: [PATCH 1/7] btrfs: change block group reclaim_mark to bool
Date: Wed, 31 Dec 2025 18:39:34 +0800 [thread overview]
Message-ID: <20251231111623.30136-2-sunk67188@gmail.com> (raw)
In-Reply-To: <20251231111623.30136-1-sunk67188@gmail.com>
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.
Now sizeof(struct btrfs_block_group) is 632->624.
Signed-off-by: Sun YangKai <sunk67188@gmail.com>
---
fs/btrfs/block-group.c | 2 +-
fs/btrfs/block-group.h | 7 ++++++-
fs/btrfs/space-info.c | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index e417aba4c4c7..1dcc5dccef05 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -3726,7 +3726,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;
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index 5f933455118c..3b3c61b3af2c 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -251,6 +251,12 @@ struct btrfs_block_group {
/* Protected by @free_space_lock. */
bool using_free_space_bitmaps_cached;
+ /*
+ * Mark 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'.
@@ -270,7 +276,6 @@ struct btrfs_block_group {
struct work_struct zone_finish_work;
struct extent_buffer *last_eb;
enum btrfs_block_group_size_class size_class;
- u64 reclaim_mark;
};
static inline u64 btrfs_block_group_end(const struct btrfs_block_group *block_group)
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 7b7b7255f7d8..41f1507f460f 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -2104,7 +2104,7 @@ static void do_reclaim_sweep(struct btrfs_space_info *space_info, int raid)
try_again = false;
reclaim = true;
}
- bg->reclaim_mark++;
+ bg->reclaim_mark = true;
spin_unlock(&bg->lock);
if (reclaim)
btrfs_mark_bg_to_reclaim(bg);
--
2.51.2
next prev parent reply other threads:[~2025-12-31 11:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 10:39 [PATCH 0/7] btrfs: fix periodic reclaim condition with some cleanup Sun YangKai
2025-12-31 10:39 ` Sun YangKai [this message]
2025-12-31 10:39 ` [PATCH 2/7] btrfs: reorder btrfs_block_group members to reduce struct size Sun YangKai
2025-12-31 10:39 ` [PATCH 3/7] btrfs: use proper types for btrfs_block_group fields Sun YangKai
2025-12-31 10:39 ` [PATCH 4/7] btrfs: consolidate reclaim readiness checks in btrfs_should_reclaim() Sun YangKai
2025-12-31 10:39 ` [PATCH 5/7] btrfs: use u8 for reclaim threshold type Sun YangKai
2025-12-31 10:39 ` [PATCH 6/7] btrfs: clarify reclaim sweep control flow Sun YangKai
2025-12-31 10:39 ` [PATCH 7/7] btrfs: fix periodic reclaim condition Sun YangKai
2026-01-01 0:20 ` Qu Wenruo
2026-01-01 11:44 ` Sun Yangkai
2026-01-01 0:13 ` [PATCH 0/7] btrfs: fix periodic reclaim condition with some cleanup Qu Wenruo
2026-01-01 11:54 ` Sun Yangkai
2026-01-01 21:14 ` Qu Wenruo
2026-01-03 11:17 ` Sun Yangkai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251231111623.30136-2-sunk67188@gmail.com \
--to=sunk67188@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox