summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Maiolino <cem@kernel.org>2026-03-10 20:36:48 +0300
committerCarlos Maiolino <cem@kernel.org>2026-03-12 10:49:36 +0300
commit3bdc20b005c20ce1bf9b098d1ee2caa1d994141e (patch)
tree168f9e8345f4fd16af9ebd463d3163dc60e63d6f
parent02a5d8993b09fe9a6754e57d0e25399baffe9a06 (diff)
downloadlinux-3bdc20b005c20ce1bf9b098d1ee2caa1d994141e.tar.xz
xfs: factor out xfs_zone_inc_written
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> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--fs/xfs/xfs_zone_alloc.c20
1 files 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);