[PATCH 02/17] libxfs: mark xmbuf_{un,}map_page static

Darrick J. Wong
2025-02-06T22:31:10Z

From: Christoph Hellwig <hch@lst.de>

Not used outside of buf_mem.c.

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>
---
libxfs/buf_mem.c | 97 +++++++++++++++++++++++++++---------------------------
libxfs/buf_mem.h | 3 --
2 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/libxfs/buf_mem.c b/libxfs/buf_mem.c
index 16cb038ba10e2a..77396fa95b4138 100644
--- a/libxfs/buf_mem.c
+++ b/libxfs/buf_mem.c
@@ -85,6 +85,55 @@ xmbuf_libinit(void)
xmbuf_max_mappings = 1024;
}

+/* Directly map a memfd page into the buffer cache. */
+static int
+xmbuf_map_page(
+ struct xfs_buf *bp)
+{
+ struct xfile *xfile = bp->b_target->bt_xfile;
+ void *p;
+ loff_t pos;
+
+ pos = xfile->partition_pos + BBTOB(xfs_buf_daddr(bp));
+ p = mmap(NULL, BBTOB(bp->b_length), PROT_READ | PROT_WRITE, MAP_SHARED,
+ xfile->fcb->fd, pos);
+ if (p == MAP_FAILED) {
+ if (errno == ENOMEM && !xmbuf_unmap_early) {
+#ifdef DEBUG
+ fprintf(stderr, "xmbuf could not make mappings!\n");
+#endif
+ xmbuf_unmap_early = true;
+ }
+ return errno;
+ }
+
+ if (!xmbuf_unmap_early &&
+ atomic_inc_return(&xmbuf_mappings) > xmbuf_max_mappings) {
+#ifdef DEBUG
+ fprintf(stderr, _("xmbuf hit too many mappings (%ld)!\n",
+ xmbuf_max_mappings);
+#endif
+ xmbuf_unmap_early = true;
+ }
+
+ bp->b_addr = p;
+ bp->b_flags |= LIBXFS_B_UPTODATE | LIBXFS_B_UNCHECKED;
+ bp->b_error = 0;
+ return 0;
+}
+
+/* Unmap a memfd page that was mapped into the buffer cache. */
+static void
+xmbuf_unmap_page(
+ struct xfs_buf *bp)
+{
+ if (!xmbuf_unmap_early)
+ atomic_dec(&xmbuf_mappings);
+ munmap(bp->b_addr, BBTOB(bp->b_length));
+ bp->b_addr = NULL;
+}
+
+
/* Allocate a new cache node (aka a xfs_buf) */
static struct cache_node *
xmbuf_cache_alloc(
@@ -280,54 +329,6 @@ xmbuf_free(
kfree(btp);
}

-/* Directly map a memfd page into the buffer cache. */
-int
-xmbuf_map_page(
- struct xfs_buf *bp)
-{
- struct xfile *xfile = bp->b_target->bt_xfile;
- void *p;
- loff_t pos;
-
- pos = xfile->partition_pos + BBTOB(xfs_buf_daddr(bp));
- p = mmap(NULL, BBTOB(bp->b_length), PROT_READ | PROT_WRITE, MAP_SHARED,
- xfile->fcb->fd, pos);
- if (p == MAP_FAILED) {
- if (errno == ENOMEM && !xmbuf_unmap_early) {
-#ifdef DEBUG
- fprintf(stderr, "xmbuf could not make mappings!\n");
-#endif
- xmbuf_unmap_early = true;
- }
- return errno;
- }
-
- if (!xmbuf_unmap_early &&
- atomic_inc_return(&xmbuf_mappings) > xmbuf_max_mappings) {
-#ifdef DEBUG
- fprintf(stderr, _("xmbuf hit too many mappings (%ld)!\n",
- xmbuf_max_mappings);
-#endif
- xmbuf_unmap_early = true;
- }
-
- bp->b_addr = p;
- bp->b_flags |= LIBXFS_B_UPTODATE | LIBXFS_B_UNCHECKED;
- bp->b_error = 0;
- return 0;
-}
-
-/* Unmap a memfd page that was mapped into the buffer cache. */
-void
-xmbuf_unmap_page(
- struct xfs_buf *bp)
-{
- if (!xmbuf_unmap_early)
- atomic_dec(&xmbuf_mappings);
- munmap(bp->b_addr, BBTOB(bp->b_length));
- bp->b_addr = NULL;
-}
-
/* Is this a valid daddr within the buftarg? */
bool
xmbuf_verify_daddr(
diff --git a/libxfs/buf_mem.h b/libxfs/buf_mem.h
index f19bc6fd700b9a..6e4b2d3503b853 100644
--- a/libxfs/buf_mem.h
+++ b/libxfs/buf_mem.h
@@ -20,9 +20,6 @@ int xmbuf_alloc(struct xfs_mount *mp, const char *descr,
unsigned long long maxpos, struct xfs_buftarg **btpp);
void xmbuf_free(struct xfs_buftarg *btp);

-int xmbuf_map_page(struct xfs_buf *bp);
-void xmbuf_unmap_page(struct xfs_buf *bp);
-
bool xmbuf_verify_daddr(struct xfs_buftarg *btp, xfs_daddr_t daddr);
void xmbuf_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
int xmbuf_finalize(struct xfs_buf *bp);