1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 2000,2005 Silicon Graphics, Inc. 4*4882a593Smuzhiyun * All Rights Reserved. 5*4882a593Smuzhiyun */ 6*4882a593Smuzhiyun #ifndef __XFS_ALLOC_BTREE_H__ 7*4882a593Smuzhiyun #define __XFS_ALLOC_BTREE_H__ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun /* 10*4882a593Smuzhiyun * Freespace on-disk structures 11*4882a593Smuzhiyun */ 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun struct xfs_buf; 14*4882a593Smuzhiyun struct xfs_btree_cur; 15*4882a593Smuzhiyun struct xfs_mount; 16*4882a593Smuzhiyun struct xbtree_afakeroot; 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* 19*4882a593Smuzhiyun * Btree block header size depends on a superblock flag. 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun #define XFS_ALLOC_BLOCK_LEN(mp) \ 22*4882a593Smuzhiyun (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 23*4882a593Smuzhiyun XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN) 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* 26*4882a593Smuzhiyun * Record, key, and pointer address macros for btree blocks. 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * (note that some of these may appear unused, but they are used in userspace) 29*4882a593Smuzhiyun */ 30*4882a593Smuzhiyun #define XFS_ALLOC_REC_ADDR(mp, block, index) \ 31*4882a593Smuzhiyun ((xfs_alloc_rec_t *) \ 32*4882a593Smuzhiyun ((char *)(block) + \ 33*4882a593Smuzhiyun XFS_ALLOC_BLOCK_LEN(mp) + \ 34*4882a593Smuzhiyun (((index) - 1) * sizeof(xfs_alloc_rec_t)))) 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ 37*4882a593Smuzhiyun ((xfs_alloc_key_t *) \ 38*4882a593Smuzhiyun ((char *)(block) + \ 39*4882a593Smuzhiyun XFS_ALLOC_BLOCK_LEN(mp) + \ 40*4882a593Smuzhiyun ((index) - 1) * sizeof(xfs_alloc_key_t))) 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ 43*4882a593Smuzhiyun ((xfs_alloc_ptr_t *) \ 44*4882a593Smuzhiyun ((char *)(block) + \ 45*4882a593Smuzhiyun XFS_ALLOC_BLOCK_LEN(mp) + \ 46*4882a593Smuzhiyun (maxrecs) * sizeof(xfs_alloc_key_t) + \ 47*4882a593Smuzhiyun ((index) - 1) * sizeof(xfs_alloc_ptr_t))) 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, 50*4882a593Smuzhiyun struct xfs_trans *, struct xfs_buf *, 51*4882a593Smuzhiyun xfs_agnumber_t, xfs_btnum_t); 52*4882a593Smuzhiyun struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp, 53*4882a593Smuzhiyun struct xbtree_afakeroot *afake, xfs_agnumber_t agno, 54*4882a593Smuzhiyun xfs_btnum_t btnum); 55*4882a593Smuzhiyun extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int); 56*4882a593Smuzhiyun extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp, 57*4882a593Smuzhiyun unsigned long long len); 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun void xfs_allocbt_commit_staged_btree(struct xfs_btree_cur *cur, 60*4882a593Smuzhiyun struct xfs_trans *tp, struct xfs_buf *agbp); 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun #endif /* __XFS_ALLOC_BTREE_H__ */ 63