]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/xfs_refcount_btree.h
libxfs: fix xfs_trans_alloc reservation abuse
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_refcount_btree.h
CommitLineData
37b3b4d6 1// SPDX-License-Identifier: GPL-2.0+
d8079fe0
DW
2/*
3 * Copyright (C) 2016 Oracle. All Rights Reserved.
d8079fe0 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
d8079fe0
DW
5 */
6#ifndef __XFS_REFCOUNT_BTREE_H__
7#define __XFS_REFCOUNT_BTREE_H__
8
9/*
10 * Reference Count Btree on-disk structures
11 */
12
13struct xfs_buf;
14struct xfs_btree_cur;
15struct xfs_mount;
16
17/*
18 * Btree block header size
19 */
20#define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
21
22/*
23 * Record, key, and pointer address macros for btree blocks.
24 *
25 * (note that some of these may appear unused, but they are used in userspace)
26 */
27#define XFS_REFCOUNT_REC_ADDR(block, index) \
28 ((struct xfs_refcount_rec *) \
29 ((char *)(block) + \
30 XFS_REFCOUNT_BLOCK_LEN + \
31 (((index) - 1) * sizeof(struct xfs_refcount_rec))))
32
33#define XFS_REFCOUNT_KEY_ADDR(block, index) \
34 ((struct xfs_refcount_key *) \
35 ((char *)(block) + \
36 XFS_REFCOUNT_BLOCK_LEN + \
37 ((index) - 1) * sizeof(struct xfs_refcount_key)))
38
39#define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \
40 ((xfs_refcount_ptr_t *) \
41 ((char *)(block) + \
42 XFS_REFCOUNT_BLOCK_LEN + \
43 (maxrecs) * sizeof(struct xfs_refcount_key) + \
44 ((index) - 1) * sizeof(xfs_refcount_ptr_t)))
45
46extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp,
47 struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno,
48 struct xfs_defer_ops *dfops);
1421de38 49extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf);
d8079fe0
DW
50extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
51
02cc8b2a
DW
52extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
53 unsigned long long len);
f21c57ed
DW
54extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
55 xfs_agblock_t agblocks);
02cc8b2a
DW
56
57extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
58 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
59
d8079fe0 60#endif /* __XFS_REFCOUNT_BTREE_H__ */