1*0b61f8a4SDave Chinner // SPDX-License-Identifier: GPL-2.0+ 21946b91cSDarrick J. Wong /* 31946b91cSDarrick J. Wong * Copyright (C) 2016 Oracle. All Rights Reserved. 41946b91cSDarrick J. Wong * Author: Darrick J. Wong <darrick.wong@oracle.com> 51946b91cSDarrick J. Wong */ 61946b91cSDarrick J. Wong #ifndef __XFS_REFCOUNT_BTREE_H__ 71946b91cSDarrick J. Wong #define __XFS_REFCOUNT_BTREE_H__ 81946b91cSDarrick J. Wong 91946b91cSDarrick J. Wong /* 101946b91cSDarrick J. Wong * Reference Count Btree on-disk structures 111946b91cSDarrick J. Wong */ 121946b91cSDarrick J. Wong 131946b91cSDarrick J. Wong struct xfs_buf; 141946b91cSDarrick J. Wong struct xfs_btree_cur; 151946b91cSDarrick J. Wong struct xfs_mount; 161946b91cSDarrick J. Wong 171946b91cSDarrick J. Wong /* 181946b91cSDarrick J. Wong * Btree block header size 191946b91cSDarrick J. Wong */ 201946b91cSDarrick J. Wong #define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN 211946b91cSDarrick J. Wong 221946b91cSDarrick J. Wong /* 231946b91cSDarrick J. Wong * Record, key, and pointer address macros for btree blocks. 241946b91cSDarrick J. Wong * 251946b91cSDarrick J. Wong * (note that some of these may appear unused, but they are used in userspace) 261946b91cSDarrick J. Wong */ 271946b91cSDarrick J. Wong #define XFS_REFCOUNT_REC_ADDR(block, index) \ 281946b91cSDarrick J. Wong ((struct xfs_refcount_rec *) \ 291946b91cSDarrick J. Wong ((char *)(block) + \ 301946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 311946b91cSDarrick J. Wong (((index) - 1) * sizeof(struct xfs_refcount_rec)))) 321946b91cSDarrick J. Wong 331946b91cSDarrick J. Wong #define XFS_REFCOUNT_KEY_ADDR(block, index) \ 341946b91cSDarrick J. Wong ((struct xfs_refcount_key *) \ 351946b91cSDarrick J. Wong ((char *)(block) + \ 361946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 371946b91cSDarrick J. Wong ((index) - 1) * sizeof(struct xfs_refcount_key))) 381946b91cSDarrick J. Wong 391946b91cSDarrick J. Wong #define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \ 401946b91cSDarrick J. Wong ((xfs_refcount_ptr_t *) \ 411946b91cSDarrick J. Wong ((char *)(block) + \ 421946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 431946b91cSDarrick J. Wong (maxrecs) * sizeof(struct xfs_refcount_key) + \ 441946b91cSDarrick J. Wong ((index) - 1) * sizeof(xfs_refcount_ptr_t))) 451946b91cSDarrick J. Wong 461946b91cSDarrick J. Wong extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp, 471946b91cSDarrick J. Wong struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno, 481946b91cSDarrick J. Wong struct xfs_defer_ops *dfops); 49a1f69417SEric Sandeen extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf); 501946b91cSDarrick J. Wong extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp); 511946b91cSDarrick J. Wong 5284d69619SDarrick J. Wong extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp, 5384d69619SDarrick J. Wong unsigned long long len); 5420e73b00SDarrick J. Wong extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp, 5520e73b00SDarrick J. Wong xfs_agblock_t agblocks); 5684d69619SDarrick J. Wong 5784d69619SDarrick J. Wong extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp, 5884d69619SDarrick J. Wong xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 5984d69619SDarrick J. Wong 601946b91cSDarrick J. Wong #endif /* __XFS_REFCOUNT_BTREE_H__ */ 61