Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Oracle. All Rights Reserved. |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_REFCOUNT_BTREE_H__ |
| 7 | #define __XFS_REFCOUNT_BTREE_H__ |
| 8 | |
| 9 | /* |
| 10 | * Reference Count Btree on-disk structures |
| 11 | */ |
| 12 | |
| 13 | struct xfs_buf; |
| 14 | struct xfs_btree_cur; |
| 15 | struct 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 | |
| 46 | extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp, |
Brian Foster | ed7ef8e | 2018-07-11 22:26:17 -0700 | [diff] [blame] | 47 | struct xfs_trans *tp, struct xfs_buf *agbp, |
| 48 | xfs_agnumber_t agno); |
Eric Sandeen | a1f6941 | 2018-04-06 10:09:42 -0700 | [diff] [blame] | 49 | extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf); |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 50 | extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp); |
| 51 | |
Darrick J. Wong | 84d6961 | 2016-10-03 09:11:44 -0700 | [diff] [blame] | 52 | extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp, |
| 53 | unsigned long long len); |
Darrick J. Wong | 20e73b0 | 2017-01-03 18:39:33 -0800 | [diff] [blame] | 54 | extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp, |
| 55 | xfs_agblock_t agblocks); |
Darrick J. Wong | 84d6961 | 2016-10-03 09:11:44 -0700 | [diff] [blame] | 56 | |
| 57 | extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp, |
Darrick J. Wong | ebcbef3 | 2018-07-29 22:37:08 -0700 | [diff] [blame] | 58 | struct xfs_trans *tp, xfs_agnumber_t agno, xfs_extlen_t *ask, |
| 59 | xfs_extlen_t *used); |
Darrick J. Wong | 84d6961 | 2016-10-03 09:11:44 -0700 | [diff] [blame] | 60 | |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 61 | #endif /* __XFS_REFCOUNT_BTREE_H__ */ |