1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
6 #ifndef __XFS_IALLOC_BTREE_H__
7 #define __XFS_IALLOC_BTREE_H__
10 * Inode map on-disk structures
19 * Btree block header size depends on a superblock flag.
21 #define XFS_INOBT_BLOCK_LEN(mp) \
22 (xfs_has_crc(((mp))) ? \
23 XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
26 * Record, key, and pointer address macros for btree blocks.
28 * (note that some of these may appear unused, but they are used in userspace)
30 #define XFS_INOBT_REC_ADDR(mp, block, index) \
31 ((xfs_inobt_rec_t *) \
33 XFS_INOBT_BLOCK_LEN(mp) + \
34 (((index) - 1) * sizeof(xfs_inobt_rec_t))))
36 #define XFS_INOBT_KEY_ADDR(mp, block, index) \
37 ((xfs_inobt_key_t *) \
39 XFS_INOBT_BLOCK_LEN(mp) + \
40 ((index) - 1) * sizeof(xfs_inobt_key_t)))
42 #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
43 ((xfs_inobt_ptr_t *) \
45 XFS_INOBT_BLOCK_LEN(mp) + \
46 (maxrecs) * sizeof(xfs_inobt_key_t) + \
47 ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
49 extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_perag *pag,
50 struct xfs_trans *tp, struct xfs_buf *agbp, xfs_btnum_t btnum);
51 struct xfs_btree_cur *xfs_inobt_stage_cursor(struct xfs_perag *pag,
52 struct xbtree_afakeroot *afake, xfs_btnum_t btnum);
53 extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
55 /* ir_holemask to inode allocation bitmap conversion */
56 uint64_t xfs_inobt_irec_to_allocmask(const struct xfs_inobt_rec_incore *irec);
58 #if defined(DEBUG) || defined(XFS_WARN)
59 int xfs_inobt_rec_check_count(struct xfs_mount *,
60 struct xfs_inobt_rec_incore *);
62 #define xfs_inobt_rec_check_count(mp, rec) 0
65 int xfs_finobt_calc_reserves(struct xfs_perag *perag, struct xfs_trans *tp,
66 xfs_extlen_t *ask, xfs_extlen_t *used);
67 extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
68 unsigned long long len);
69 int xfs_inobt_cur(struct xfs_perag *pag, struct xfs_trans *tp,
70 xfs_btnum_t btnum, struct xfs_btree_cur **curpp,
71 struct xfs_buf **agi_bpp);
73 void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,
74 struct xfs_trans *tp, struct xfs_buf *agbp);
76 unsigned int xfs_iallocbt_maxlevels_ondisk(void);
78 int __init xfs_inobt_init_cur_cache(void);
79 void xfs_inobt_destroy_cur_cache(void);
81 #endif /* __XFS_IALLOC_BTREE_H__ */