Merge branch 'work.d_name' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / fs / xfs / libxfs / xfs_alloc_btree.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4  * All Rights Reserved.
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;
15 struct xfs_mount;
16 struct xbtree_afakeroot;
17
18 /*
19  * Btree block header size depends on a superblock flag.
20  */
21 #define XFS_ALLOC_BLOCK_LEN(mp) \
22         (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
23                 XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
24
25 /*
26  * Record, key, and pointer address macros for btree blocks.
27  *
28  * (note that some of these may appear unused, but they are used in userspace)
29  */
30 #define XFS_ALLOC_REC_ADDR(mp, block, index) \
31         ((xfs_alloc_rec_t *) \
32                 ((char *)(block) + \
33                  XFS_ALLOC_BLOCK_LEN(mp) + \
34                  (((index) - 1) * sizeof(xfs_alloc_rec_t))))
35
36 #define XFS_ALLOC_KEY_ADDR(mp, block, index) \
37         ((xfs_alloc_key_t *) \
38                 ((char *)(block) + \
39                  XFS_ALLOC_BLOCK_LEN(mp) + \
40                  ((index) - 1) * sizeof(xfs_alloc_key_t)))
41
42 #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
43         ((xfs_alloc_ptr_t *) \
44                 ((char *)(block) + \
45                  XFS_ALLOC_BLOCK_LEN(mp) + \
46                  (maxrecs) * sizeof(xfs_alloc_key_t) + \
47                  ((index) - 1) * sizeof(xfs_alloc_ptr_t)))
48
49 extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
50                 struct xfs_trans *, struct xfs_buf *,
51                 xfs_agnumber_t, xfs_btnum_t);
52 struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp,
53                 struct xbtree_afakeroot *afake, xfs_agnumber_t agno,
54                 xfs_btnum_t btnum);
55 extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
56 extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
57                 unsigned long long len);
58
59 void xfs_allocbt_commit_staged_btree(struct xfs_btree_cur *cur,
60                 struct xfs_trans *tp, struct xfs_buf *agbp);
61
62 #endif  /* __XFS_ALLOC_BTREE_H__ */