blob: ba416f71c82472128b922bc25efbc0e5d70ea627 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0+
Darrick J. Wong1946b912016-10-03 09:11:18 -07002/*
3 * Copyright (C) 2016 Oracle. All Rights Reserved.
Darrick J. Wong1946b912016-10-03 09:11:18 -07004 * Author: Darrick J. Wong <darrick.wong@oracle.com>
Darrick J. Wong1946b912016-10-03 09:11:18 -07005 */
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,
Brian Fostered7ef8e2018-07-11 22:26:17 -070047 struct xfs_trans *tp, struct xfs_buf *agbp,
48 xfs_agnumber_t agno);
Eric Sandeena1f69412018-04-06 10:09:42 -070049extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf);
Darrick J. Wong1946b912016-10-03 09:11:18 -070050extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
51
Darrick J. Wong84d69612016-10-03 09:11:44 -070052extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
53 unsigned long long len);
Darrick J. Wong20e73b02017-01-03 18:39:33 -080054extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
55 xfs_agblock_t agblocks);
Darrick J. Wong84d69612016-10-03 09:11:44 -070056
57extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
Darrick J. Wongebcbef32018-07-29 22:37:08 -070058 struct xfs_trans *tp, xfs_agnumber_t agno, xfs_extlen_t *ask,
59 xfs_extlen_t *used);
Darrick J. Wong84d69612016-10-03 09:11:44 -070060
Darrick J. Wong1946b912016-10-03 09:11:18 -070061#endif /* __XFS_REFCOUNT_BTREE_H__ */