summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_rtalloc.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-11-03 20:19:06 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-11-05 13:38:35 -0800
commit65b1231b8cea7fbe7362dceecfda76026d335536 (patch)
tree84d303e772c642bba0d6b058567a9424586b88c3 /fs/xfs/xfs_rtalloc.c
parentc29237a65c8dbfade3c032763b66d495b8e8cb7a (diff)
xfs: support caching rtgroup metadata inodes
Create the necessary per-rtgroup infrastructure that we need to load metadata inodes into memory. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r--fs/xfs/xfs_rtalloc.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 917c1a5e8f31..962253136864 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -28,6 +28,7 @@
#include "xfs_da_format.h"
#include "xfs_metafile.h"
#include "xfs_rtgroup.h"
+#include "xfs_error.h"
/*
* Return whether there are any free extents in the size range given
@@ -652,6 +653,16 @@ xfs_rtallocate_extent_size(
return -ENOSPC;
}
+static void
+xfs_rtunmount_rtg(
+ struct xfs_rtgroup *rtg)
+{
+ int i;
+
+ for (i = 0; i < XFS_RTGI_MAX; i++)
+ xfs_rtginode_irele(&rtg->rtg_inodes[i]);
+}
+
static int
xfs_alloc_rsum_cache(
struct xfs_mount *mp,
@@ -1127,6 +1138,43 @@ out_unlock:
return error;
}
+static void
+xfs_rtgroup_unmount_inodes(
+ struct xfs_mount *mp)
+{
+ struct xfs_rtgroup *rtg = NULL;
+
+ while ((rtg = xfs_rtgroup_next(mp, rtg)))
+ xfs_rtunmount_rtg(rtg);
+ xfs_rtginode_irele(&mp->m_rtdirip);
+}
+
+static int
+xfs_rtmount_rtg(
+ struct xfs_mount *mp,
+ struct xfs_trans *tp,
+ struct xfs_rtgroup *rtg)
+{
+ int error, i;
+
+ rtg->rtg_extents = xfs_rtgroup_extents(mp, rtg_rgno(rtg));
+
+ for (i = 0; i < XFS_RTGI_MAX; i++) {
+ error = xfs_rtginode_load(rtg, i, tp);
+ if (error)
+ return error;
+
+ if (rtg->rtg_inodes[i]) {
+ error = xfs_rtmount_iread_extents(tp,
+ rtg->rtg_inodes[i], 0);
+ if (error)
+ return error;
+ }
+ }
+
+ return 0;
+}
+
/*
* Get the bitmap and summary inodes and the summary cache into the mount
* structure at mount time.
@@ -1168,15 +1216,28 @@ xfs_rtmount_inodes(
if (error)
goto out_rele_summary;
- while ((rtg = xfs_rtgroup_next(mp, rtg)))
- rtg->rtg_extents = xfs_rtgroup_extents(mp, rtg_rgno(rtg));
+ if (xfs_has_rtgroups(mp) && mp->m_sb.sb_rgcount > 0) {
+ error = xfs_rtginode_load_parent(tp);
+ if (error)
+ goto out_rele_summary;
+ }
+
+ while ((rtg = xfs_rtgroup_next(mp, rtg))) {
+ error = xfs_rtmount_rtg(mp, tp, rtg);
+ if (error) {
+ xfs_rtgroup_rele(rtg);
+ goto out_rele_inodes;
+ }
+ }
error = xfs_alloc_rsum_cache(mp, sbp->sb_rbmblocks);
if (error)
- goto out_rele_summary;
+ goto out_rele_inodes;
xfs_trans_cancel(tp);
return 0;
+out_rele_inodes:
+ xfs_rtgroup_unmount_inodes(mp);
out_rele_summary:
xfs_irele(mp->m_rsumip);
out_rele_bitmap:
@@ -1191,6 +1252,8 @@ xfs_rtunmount_inodes(
struct xfs_mount *mp)
{
kvfree(mp->m_rsum_cache);
+
+ xfs_rtgroup_unmount_inodes(mp);
if (mp->m_rbmip)
xfs_irele(mp->m_rbmip);
if (mp->m_rsumip)