From: Carlos Maiolino Date: Tue, 10 Mar 2026 17:36:48 +0000 (+0100) Subject: xfs: factor out xfs_zone_inc_written X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3bdc20b005c20ce1bf9b098d1ee2caa1d994141e;p=thirdparty%2Flinux.git 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 Reviewed-by: Christoph Hellwig Reviewed-by: Damien Le Moal Signed-off-by: Carlos Maiolino --- 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);