xref: /linux/fs/xfs/libxfs/xfs_ialloc_btree.h (revision 84be0ffc9043f7c56044294eb775a2200452c76d)
1*84be0ffcSDave Chinner /*
2*84be0ffcSDave Chinner  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3*84be0ffcSDave Chinner  * All Rights Reserved.
4*84be0ffcSDave Chinner  *
5*84be0ffcSDave Chinner  * This program is free software; you can redistribute it and/or
6*84be0ffcSDave Chinner  * modify it under the terms of the GNU General Public License as
7*84be0ffcSDave Chinner  * published by the Free Software Foundation.
8*84be0ffcSDave Chinner  *
9*84be0ffcSDave Chinner  * This program is distributed in the hope that it would be useful,
10*84be0ffcSDave Chinner  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*84be0ffcSDave Chinner  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*84be0ffcSDave Chinner  * GNU General Public License for more details.
13*84be0ffcSDave Chinner  *
14*84be0ffcSDave Chinner  * You should have received a copy of the GNU General Public License
15*84be0ffcSDave Chinner  * along with this program; if not, write the Free Software Foundation,
16*84be0ffcSDave Chinner  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17*84be0ffcSDave Chinner  */
18*84be0ffcSDave Chinner #ifndef __XFS_IALLOC_BTREE_H__
19*84be0ffcSDave Chinner #define	__XFS_IALLOC_BTREE_H__
20*84be0ffcSDave Chinner 
21*84be0ffcSDave Chinner /*
22*84be0ffcSDave Chinner  * Inode map on-disk structures
23*84be0ffcSDave Chinner  */
24*84be0ffcSDave Chinner 
25*84be0ffcSDave Chinner struct xfs_buf;
26*84be0ffcSDave Chinner struct xfs_btree_cur;
27*84be0ffcSDave Chinner struct xfs_mount;
28*84be0ffcSDave Chinner 
29*84be0ffcSDave Chinner /*
30*84be0ffcSDave Chinner  * Btree block header size depends on a superblock flag.
31*84be0ffcSDave Chinner  */
32*84be0ffcSDave Chinner #define XFS_INOBT_BLOCK_LEN(mp) \
33*84be0ffcSDave Chinner 	(xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
34*84be0ffcSDave Chinner 		XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
35*84be0ffcSDave Chinner 
36*84be0ffcSDave Chinner /*
37*84be0ffcSDave Chinner  * Record, key, and pointer address macros for btree blocks.
38*84be0ffcSDave Chinner  *
39*84be0ffcSDave Chinner  * (note that some of these may appear unused, but they are used in userspace)
40*84be0ffcSDave Chinner  */
41*84be0ffcSDave Chinner #define XFS_INOBT_REC_ADDR(mp, block, index) \
42*84be0ffcSDave Chinner 	((xfs_inobt_rec_t *) \
43*84be0ffcSDave Chinner 		((char *)(block) + \
44*84be0ffcSDave Chinner 		 XFS_INOBT_BLOCK_LEN(mp) + \
45*84be0ffcSDave Chinner 		 (((index) - 1) * sizeof(xfs_inobt_rec_t))))
46*84be0ffcSDave Chinner 
47*84be0ffcSDave Chinner #define XFS_INOBT_KEY_ADDR(mp, block, index) \
48*84be0ffcSDave Chinner 	((xfs_inobt_key_t *) \
49*84be0ffcSDave Chinner 		((char *)(block) + \
50*84be0ffcSDave Chinner 		 XFS_INOBT_BLOCK_LEN(mp) + \
51*84be0ffcSDave Chinner 		 ((index) - 1) * sizeof(xfs_inobt_key_t)))
52*84be0ffcSDave Chinner 
53*84be0ffcSDave Chinner #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
54*84be0ffcSDave Chinner 	((xfs_inobt_ptr_t *) \
55*84be0ffcSDave Chinner 		((char *)(block) + \
56*84be0ffcSDave Chinner 		 XFS_INOBT_BLOCK_LEN(mp) + \
57*84be0ffcSDave Chinner 		 (maxrecs) * sizeof(xfs_inobt_key_t) + \
58*84be0ffcSDave Chinner 		 ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
59*84be0ffcSDave Chinner 
60*84be0ffcSDave Chinner extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *,
61*84be0ffcSDave Chinner 		struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t,
62*84be0ffcSDave Chinner 		xfs_btnum_t);
63*84be0ffcSDave Chinner extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
64*84be0ffcSDave Chinner 
65*84be0ffcSDave Chinner #endif	/* __XFS_IALLOC_BTREE_H__ */
66