From: Christoph Hellwig Date: Mon, 24 Feb 2025 18:21:41 +0000 (-0800) Subject: libxfs: mark xmbuf_{un,}map_page static X-Git-Tag: v6.14.0~160 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c1963d498ad2612203d83fd7f2d1fb88a4a63eb2;p=thirdparty%2Fxfsprogs-dev.git libxfs: mark xmbuf_{un,}map_page static Not used outside of buf_mem.c. Signed-off-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: "Darrick J. Wong" --- diff --git a/libxfs/buf_mem.c b/libxfs/buf_mem.c index 16cb038b..77396fa9 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 f19bc6fd..6e4b2d35 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);