summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_rtalloc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-11-03 20:19:10 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-11-05 13:38:37 -0800
commitae897e0bed0f5461a6b1c3259c7d899759ba2a62 (patch)
tree31d1eba77b6f3d94003b4c24ebe7d77147f7d056 /fs/xfs/xfs_rtalloc.c
parente3088ae2dcae3c15d03d7970d4926c8095fd8c7c (diff)
downloadlinux-ae897e0bed0f5461a6b1c3259c7d899759ba2a62.tar.gz
linux-ae897e0bed0f5461a6b1c3259c7d899759ba2a62.tar.bz2
linux-ae897e0bed0f5461a6b1c3259c7d899759ba2a62.zip
xfs: support creating per-RTG files in growfs
To support adding new RT groups in growfs, we need to be able to create the per-RT group files. Add a new xfs_rtginode_create helper to create a given per-RTG file. Most of the code for that is shared, but the details of the actual file are abstracted out using a new create method in struct xfs_rtginode_ops. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r--fs/xfs/xfs_rtalloc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 3b3ce971a197..5c1df67b63d6 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -711,6 +711,29 @@ out_iolock:
return error;
}
+/* Ensure that the rtgroup metadata inode is loaded, creating it if neeeded. */
+static int
+xfs_rtginode_ensure(
+ struct xfs_rtgroup *rtg,
+ enum xfs_rtg_inodes type)
+{
+ struct xfs_trans *tp;
+ int error;
+
+ if (rtg->rtg_inodes[type])
+ return 0;
+
+ error = xfs_trans_alloc_empty(rtg_mount(rtg), &tp);
+ if (error)
+ return error;
+ error = xfs_rtginode_load(rtg, type, tp);
+ xfs_trans_cancel(tp);
+
+ if (error != -ENOENT)
+ return 0;
+ return xfs_rtginode_create(rtg, type, true);
+}
+
static int
xfs_growfs_rt_bmblock(
struct xfs_rtgroup *rtg,
@@ -927,12 +950,19 @@ 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, 0);
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_growfs_rt_alloc_blocks(rtg, nrblocks, rextsize, &bmblocks);
if (error)
goto out_rele;