[PATCH 1/1] xfs: map xfile pages directly into xfs_buf

Darrick J. Wong
2023-12-31T22:35:24Z

Map the xfile pages directly into xfs_buf to reduce memory overhead.
It's silly to use memory to stage changes to shmem pages for ephemeral
btrees that don't care about transactionality.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
libxfs/xfs_btree_mem.h | 6 ++++++
libxfs/xfs_rmap_btree.c | 1 +
2 files changed, 7 insertions(+)

diff --git a/libxfs/xfs_btree_mem.h b/libxfs/xfs_btree_mem.h
index 1f961f3f554..cfb30cb1aab 100644
--- a/libxfs/xfs_btree_mem.h
+++ b/libxfs/xfs_btree_mem.h
@@ -17,8 +17,14 @@ struct xfbtree_config {

/* Owner of this btree. */
unsigned long long owner;
+
+ /* XFBTREE_* flags */
+ unsigned int flags;
};

+/* buffers should be directly mapped from memory */
+#define XFBTREE_DIRECT_MAP (1U << 0)
+
#ifdef CONFIG_XFS_BTREE_IN_XFILE
unsigned int xfs_btree_mem_head_nlevels(struct xfs_buf *head_bp);

diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c
index a378bd5daf8..7342623ed5e 100644
--- a/libxfs/xfs_rmap_btree.c
+++ b/libxfs/xfs_rmap_btree.c
@@ -670,6 +670,7 @@ xfs_rmapbt_mem_create(
.btree_ops = &xfs_rmapbt_mem_ops,
.target = target,
.owner = agno,
+ .flags = XFBTREE_DIRECT_MAP,
};

return xfbtree_create(mp, &cfg, xfbtreep);