From: cem@kernel.org
To: linux-xfs@vger.kernel.org
Cc: hch@lst.de, dlemoal@kernel.org
Subject: [PATCH v2 3/4] xfs: factor out xfs_zone_inc_written
Date: Tue, 10 Mar 2026 18:36:48 +0100 [thread overview]
Message-ID: <20260310173709.457047-4-cem@kernel.org> (raw)
In-Reply-To: <20260310173709.457047-1-cem@kernel.org>
From: Carlos Maiolino <cem@kernel.org>
Move the written blocks increment and full zone check into a new helper.
Also add an assert to ensure rmap lock is held here.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
v2: add RwB tags, no changes
fs/xfs/xfs_zone_alloc.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index e3d19b6dc64a..97149bfc2512 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -189,6 +189,18 @@ xfs_open_zone_mark_full(
xfs_zone_account_reclaimable(rtg, rtg_blocks(rtg) - used);
}
+static inline void
+xfs_zone_inc_written(
+ struct xfs_open_zone *oz,
+ xfs_filblks_t len)
+{
+ xfs_assert_ilocked(rtg_rmap(oz->oz_rtg), XFS_ILOCK_EXCL);
+
+ oz->oz_written += len;
+ if (oz->oz_written == rtg_blocks(oz->oz_rtg))
+ xfs_open_zone_mark_full(oz);
+}
+
static void
xfs_zone_record_blocks(
struct xfs_trans *tp,
@@ -206,9 +218,7 @@ xfs_zone_record_blocks(
xfs_rtgroup_trans_join(tp, rtg, XFS_RTGLOCK_RMAP);
rmapip->i_used_blocks += len;
ASSERT(rmapip->i_used_blocks <= rtg_blocks(rtg));
- oz->oz_written += len;
- if (oz->oz_written == rtg_blocks(rtg))
- xfs_open_zone_mark_full(oz);
+ xfs_zone_inc_written(oz, len);
xfs_trans_log_inode(tp, rmapip, XFS_ILOG_CORE);
}
@@ -227,9 +237,7 @@ xfs_zone_skip_blocks(
trace_xfs_zone_skip_blocks(oz, 0, len);
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
- oz->oz_written += len;
- if (oz->oz_written == rtg_blocks(rtg))
- xfs_open_zone_mark_full(oz);
+ xfs_zone_inc_written(oz, len);
xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP);
xfs_add_frextents(rtg_mount(rtg), len);
--
2.53.0
next prev parent reply other threads:[~2026-03-10 17:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 17:36 [PATCH v2 0/4] Zoned device cleanups cem
2026-03-10 17:36 ` [PATCH v2 1/4] xfs: factor out isize updates from xfs_dio_write_end_io cem
2026-03-11 7:03 ` Damien Le Moal
2026-03-12 6:52 ` Christoph Hellwig
2026-03-10 17:36 ` [PATCH v2 2/4] xfs: factor out xfs_dio_write_zoned_end_io cem
2026-03-11 7:03 ` Damien Le Moal
2026-03-10 17:36 ` cem [this message]
2026-03-10 17:36 ` [PATCH v2 4/4] xfs: opencode xfs_zone_record_blocks cem
2026-03-18 8:14 ` Christoph Hellwig
2026-03-18 8:33 ` Carlos Maiolino
2026-03-12 8:37 ` [PATCH v2 0/4] Zoned device cleanups Carlos Maiolino
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=20260310173709.457047-4-cem@kernel.org \
--to=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@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