]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: factor out xfs_zone_inc_written
authorCarlos Maiolino <cem@kernel.org>
Tue, 10 Mar 2026 17:36:48 +0000 (18:36 +0100)
committerCarlos Maiolino <cem@kernel.org>
Thu, 12 Mar 2026 07:49:36 +0000 (08:49 +0100)
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>
fs/xfs/xfs_zone_alloc.c

index e3d19b6dc64a88ecd6a281c3e63557b4b2b2e5f9..97149bfc2512487b652daff7960973deb0dc36a4 100644 (file)
@@ -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);