1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 #ifndef __XFS_REFCOUNT_BTREE_H__
7 #define __XFS_REFCOUNT_BTREE_H__
10 * Reference Count Btree on-disk structures
18 * Btree block header size
20 #define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
23 * Record, key, and pointer address macros for btree blocks.
25 * (note that some of these may appear unused, but they are used in userspace)
27 #define XFS_REFCOUNT_REC_ADDR(block, index) \
28 ((struct xfs_refcount_rec *) \
30 XFS_REFCOUNT_BLOCK_LEN + \
31 (((index) - 1) * sizeof(struct xfs_refcount_rec))))
33 #define XFS_REFCOUNT_KEY_ADDR(block, index) \
34 ((struct xfs_refcount_key *) \
36 XFS_REFCOUNT_BLOCK_LEN + \
37 ((index) - 1) * sizeof(struct xfs_refcount_key)))
39 #define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \
40 ((xfs_refcount_ptr_t *) \
42 XFS_REFCOUNT_BLOCK_LEN + \
43 (maxrecs) * sizeof(struct xfs_refcount_key) + \
44 ((index) - 1) * sizeof(xfs_refcount_ptr_t)))
46 extern struct xfs_btree_cur
*xfs_refcountbt_init_cursor(struct xfs_mount
*mp
,
47 struct xfs_trans
*tp
, struct xfs_buf
*agbp
,
49 extern int xfs_refcountbt_maxrecs(int blocklen
, bool leaf
);
50 extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount
*mp
);
52 extern xfs_extlen_t
xfs_refcountbt_calc_size(struct xfs_mount
*mp
,
53 unsigned long long len
);
54 extern xfs_extlen_t
xfs_refcountbt_max_size(struct xfs_mount
*mp
,
55 xfs_agblock_t agblocks
);
57 extern int xfs_refcountbt_calc_reserves(struct xfs_mount
*mp
,
58 struct xfs_trans
*tp
, xfs_agnumber_t agno
, xfs_extlen_t
*ask
,
61 #endif /* __XFS_REFCOUNT_BTREE_H__ */