@@ -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(
@@ -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);