18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2000,2005 Silicon Graphics, Inc. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __XFS_IALLOC_BTREE_H__ 78c2ecf20Sopenharmony_ci#define __XFS_IALLOC_BTREE_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* 108c2ecf20Sopenharmony_ci * Inode map on-disk structures 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct xfs_buf; 148c2ecf20Sopenharmony_cistruct xfs_btree_cur; 158c2ecf20Sopenharmony_cistruct xfs_mount; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* 188c2ecf20Sopenharmony_ci * Btree block header size depends on a superblock flag. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#define XFS_INOBT_BLOCK_LEN(mp) \ 218c2ecf20Sopenharmony_ci (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 228c2ecf20Sopenharmony_ci XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * Record, key, and pointer address macros for btree blocks. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * (note that some of these may appear unused, but they are used in userspace) 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define XFS_INOBT_REC_ADDR(mp, block, index) \ 308c2ecf20Sopenharmony_ci ((xfs_inobt_rec_t *) \ 318c2ecf20Sopenharmony_ci ((char *)(block) + \ 328c2ecf20Sopenharmony_ci XFS_INOBT_BLOCK_LEN(mp) + \ 338c2ecf20Sopenharmony_ci (((index) - 1) * sizeof(xfs_inobt_rec_t)))) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define XFS_INOBT_KEY_ADDR(mp, block, index) \ 368c2ecf20Sopenharmony_ci ((xfs_inobt_key_t *) \ 378c2ecf20Sopenharmony_ci ((char *)(block) + \ 388c2ecf20Sopenharmony_ci XFS_INOBT_BLOCK_LEN(mp) + \ 398c2ecf20Sopenharmony_ci ((index) - 1) * sizeof(xfs_inobt_key_t))) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \ 428c2ecf20Sopenharmony_ci ((xfs_inobt_ptr_t *) \ 438c2ecf20Sopenharmony_ci ((char *)(block) + \ 448c2ecf20Sopenharmony_ci XFS_INOBT_BLOCK_LEN(mp) + \ 458c2ecf20Sopenharmony_ci (maxrecs) * sizeof(xfs_inobt_key_t) + \ 468c2ecf20Sopenharmony_ci ((index) - 1) * sizeof(xfs_inobt_ptr_t))) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciextern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *, 498c2ecf20Sopenharmony_ci struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t, 508c2ecf20Sopenharmony_ci xfs_btnum_t); 518c2ecf20Sopenharmony_cistruct xfs_btree_cur *xfs_inobt_stage_cursor(struct xfs_mount *mp, 528c2ecf20Sopenharmony_ci struct xbtree_afakeroot *afake, xfs_agnumber_t agno, 538c2ecf20Sopenharmony_ci xfs_btnum_t btnum); 548c2ecf20Sopenharmony_ciextern int xfs_inobt_maxrecs(struct xfs_mount *, int, int); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* ir_holemask to inode allocation bitmap conversion */ 578c2ecf20Sopenharmony_ciuint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#if defined(DEBUG) || defined(XFS_WARN) 608c2ecf20Sopenharmony_ciint xfs_inobt_rec_check_count(struct xfs_mount *, 618c2ecf20Sopenharmony_ci struct xfs_inobt_rec_incore *); 628c2ecf20Sopenharmony_ci#else 638c2ecf20Sopenharmony_ci#define xfs_inobt_rec_check_count(mp, rec) 0 648c2ecf20Sopenharmony_ci#endif /* DEBUG */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciint xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp, 678c2ecf20Sopenharmony_ci xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used); 688c2ecf20Sopenharmony_ciextern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp, 698c2ecf20Sopenharmony_ci unsigned long long len); 708c2ecf20Sopenharmony_ciint xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp, 718c2ecf20Sopenharmony_ci xfs_agnumber_t agno, xfs_btnum_t btnum, 728c2ecf20Sopenharmony_ci struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_civoid xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur, 758c2ecf20Sopenharmony_ci struct xfs_trans *tp, struct xfs_buf *agbp); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#endif /* __XFS_IALLOC_BTREE_H__ */ 78