xref: /linux/fs/xfs/xfs_buf_mem.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2023-2024 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  */
6 #ifndef __XFS_BUF_MEM_H__
7 #define __XFS_BUF_MEM_H__
8 
9 #define XMBUF_BLOCKSIZE			(PAGE_SIZE)
10 #define XMBUF_BLOCKSHIFT		(PAGE_SHIFT)
11 
12 #ifdef CONFIG_XFS_MEMORY_BUFS
13 static inline bool xfs_buftarg_is_mem(const struct xfs_buftarg *btp)
14 {
15 	return btp->bt_bdev == NULL;
16 }
17 
18 int xmbuf_alloc(struct xfs_mount *mp, const char *descr,
19 		struct xfs_buftarg **btpp);
20 void xmbuf_free(struct xfs_buftarg *btp);
21 
22 int xmbuf_map_page(struct xfs_buf *bp);
23 void xmbuf_unmap_page(struct xfs_buf *bp);
24 bool xmbuf_verify_daddr(struct xfs_buftarg *btp, xfs_daddr_t daddr);
25 void xmbuf_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
26 int xmbuf_finalize(struct xfs_buf *bp);
27 #else
28 # define xfs_buftarg_is_mem(...)	(false)
29 # define xmbuf_map_page(...)		(-ENOMEM)
30 # define xmbuf_unmap_page(...)		((void)0)
31 # define xmbuf_verify_daddr(...)	(false)
32 #endif /* CONFIG_XFS_MEMORY_BUFS */
33 
34 #endif /* __XFS_BUF_MEM_H__ */
35