Commit | Line | Data |
---|---|---|
508578f2 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 | 2 | /* |
7b718769 NS |
3 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
1da177e4 LT |
5 | */ |
6 | #ifndef __XFS_ALLOC_BTREE_H__ | |
7 | #define __XFS_ALLOC_BTREE_H__ | |
8 | ||
9 | /* | |
10 | * Freespace on-disk structures | |
11 | */ | |
12 | ||
13 | struct xfs_buf; | |
14 | struct xfs_btree_cur; | |
1da177e4 | 15 | struct xfs_mount; |
be9fb17d | 16 | struct xfs_perag; |
e6eb33d9 | 17 | struct xbtree_afakeroot; |
1da177e4 | 18 | |
7cc95a82 CH |
19 | /* |
20 | * Btree block header size depends on a superblock flag. | |
7cc95a82 | 21 | */ |
ee1a47ab | 22 | #define XFS_ALLOC_BLOCK_LEN(mp) \ |
38c26bfd | 23 | (xfs_has_crc(((mp))) ? \ |
ee1a47ab | 24 | XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN) |
7cc95a82 | 25 | |
1da177e4 LT |
26 | /* |
27 | * Record, key, and pointer address macros for btree blocks. | |
136341b4 CH |
28 | * |
29 | * (note that some of these may appear unused, but they are used in userspace) | |
1da177e4 | 30 | */ |
136341b4 CH |
31 | #define XFS_ALLOC_REC_ADDR(mp, block, index) \ |
32 | ((xfs_alloc_rec_t *) \ | |
33 | ((char *)(block) + \ | |
7cc95a82 | 34 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
136341b4 | 35 | (((index) - 1) * sizeof(xfs_alloc_rec_t)))) |
1da177e4 | 36 | |
136341b4 CH |
37 | #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ |
38 | ((xfs_alloc_key_t *) \ | |
39 | ((char *)(block) + \ | |
7cc95a82 | 40 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
136341b4 | 41 | ((index) - 1) * sizeof(xfs_alloc_key_t))) |
1da177e4 | 42 | |
136341b4 CH |
43 | #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ |
44 | ((xfs_alloc_ptr_t *) \ | |
45 | ((char *)(block) + \ | |
7cc95a82 | 46 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
136341b4 CH |
47 | (maxrecs) * sizeof(xfs_alloc_key_t) + \ |
48 | ((index) - 1) * sizeof(xfs_alloc_ptr_t))) | |
561f7d17 | 49 | |
1c8b9fd2 | 50 | struct xfs_btree_cur *xfs_bnobt_init_cursor(struct xfs_mount *mp, |
289d38d2 | 51 | struct xfs_trans *tp, struct xfs_buf *bp, |
1c8b9fd2 CH |
52 | struct xfs_perag *pag); |
53 | struct xfs_btree_cur *xfs_cntbt_init_cursor(struct xfs_mount *mp, | |
54 | struct xfs_trans *tp, struct xfs_buf *bp, | |
55 | struct xfs_perag *pag); | |
411a7125 DW |
56 | unsigned int xfs_allocbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen, |
57 | bool leaf); | |
14861c47 DW |
58 | extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp, |
59 | unsigned long long len); | |
561f7d17 | 60 | |
e6eb33d9 DW |
61 | void xfs_allocbt_commit_staged_btree(struct xfs_btree_cur *cur, |
62 | struct xfs_trans *tp, struct xfs_buf *agbp); | |
63 | ||
0ed5f735 DW |
64 | unsigned int xfs_allocbt_maxlevels_ondisk(void); |
65 | ||
9fa47bdc DW |
66 | int __init xfs_allocbt_init_cur_cache(void); |
67 | void xfs_allocbt_destroy_cur_cache(void); | |
68 | ||
1da177e4 | 69 | #endif /* __XFS_ALLOC_BTREE_H__ */ |