1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2014 Red Hat, Inc.
6 #ifndef __XFS_RMAP_BTREE_H__
7 #define __XFS_RMAP_BTREE_H__
13 /* rmaps only exist on crc enabled filesystems */
14 #define XFS_RMAP_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
17 * Record, key, and pointer address macros for btree blocks.
19 * (note that some of these may appear unused, but they are used in userspace)
21 #define XFS_RMAP_REC_ADDR(block, index) \
22 ((struct xfs_rmap_rec *) \
23 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
24 (((index) - 1) * sizeof(struct xfs_rmap_rec))))
26 #define XFS_RMAP_KEY_ADDR(block, index) \
27 ((struct xfs_rmap_key *) \
28 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
29 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
31 #define XFS_RMAP_HIGH_KEY_ADDR(block, index) \
32 ((struct xfs_rmap_key *) \
33 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
34 sizeof(struct xfs_rmap_key) + \
35 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
37 #define XFS_RMAP_PTR_ADDR(block, index, maxrecs) \
39 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
40 (maxrecs) * 2 * sizeof(struct xfs_rmap_key) + \
41 ((index) - 1) * sizeof(xfs_rmap_ptr_t)))
43 struct xfs_btree_cur
*xfs_rmapbt_init_cursor(struct xfs_mount
*mp
,
44 struct xfs_trans
*tp
, struct xfs_buf
*bp
,
46 int xfs_rmapbt_maxrecs(int blocklen
, int leaf
);
47 extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount
*mp
);
49 extern xfs_extlen_t
xfs_rmapbt_calc_size(struct xfs_mount
*mp
,
50 unsigned long long len
);
51 extern xfs_extlen_t
xfs_rmapbt_max_size(struct xfs_mount
*mp
,
52 xfs_agblock_t agblocks
);
54 extern int xfs_rmapbt_calc_reserves(struct xfs_mount
*mp
, struct xfs_trans
*tp
,
55 xfs_agnumber_t agno
, xfs_extlen_t
*ask
, xfs_extlen_t
*used
);
57 #endif /* __XFS_RMAP_BTREE_H__ */