[RFC v1 2/4] xfs: Introduce xfs_rtginodes_ensure_all()

Nirjhar Roy (IBM)
2026-02-19T06:05:59Z

From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>

This is just a wrapper to load and initialize all the realtime metadata
inodes. This will be used in the later patches for realtime xfs shrink.
No functional changes.

Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
fs/xfs/libxfs/xfs_rtgroup.h | 2 ++
fs/xfs/xfs_rtalloc.c | 25 +++++++++++++++++++------
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_rtgroup.h b/fs/xfs/libxfs/xfs_rtgroup.h
index 73cace4d25c7..6cab338007a2 100644
--- a/fs/xfs/libxfs/xfs_rtgroup.h
+++ b/fs/xfs/libxfs/xfs_rtgroup.h
@@ -109,6 +109,8 @@ static inline struct xfs_inode *rtg_refcount(const struct xfs_rtgroup *rtg)
return rtg->rtg_inodes[XFS_RTGI_REFCOUNT];
}

+int xfs_rtginodes_ensure_all(struct xfs_rtgroup *rtg);
+
/* Passive rtgroup references */
static inline struct xfs_rtgroup *
xfs_rtgroup_get(
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index d484c0b5bea7..83bebddb9ea8 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1192,18 +1192,15 @@ xfs_growfs_rtg(
xfs_extlen_t bmblocks;
xfs_fileoff_t bmbno;
struct xfs_rtgroup *rtg;
- unsigned int i;
int error;

rtg = xfs_rtgroup_grab(mp, rgno);
if (!rtg)
return -EINVAL;

- for (i = 0; i < XFS_RTGI_MAX; i++) {
- error = xfs_rtginode_ensure(rtg, i);
- if (error)
- goto out_rele;
- }
+ error = xfs_rtginodes_ensure_all(rtg);
+ if (error)
+ goto out_rele;

if (xfs_has_zoned(mp)) {
error = xfs_growfs_rt_zoned(rtg, nrblocks);
@@ -1300,6 +1297,22 @@ xfs_growfs_check_rtgeom(
return -EINVAL;
}

+int
+xfs_rtginodes_ensure_all(struct xfs_rtgroup *rtg)
+{
+ int i = 0;
+ int error = 0;
+
+ ASSERT(rtg);
+
+ for (i = 0; i < XFS_RTGI_MAX; i++) {
+ error = xfs_rtginode_ensure(rtg, i);
+ if (error)
+ break;
+ }
+ return error;
+}
+
/*
* Compute the new number of rt groups and ensure that /rtgroups exists.
*
--
2.43.5