blob: bf8f0c405e7d2cd8e037618a47abfcab64a728a2 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef __XFS_IALLOC_BTREE_H__
7#define __XFS_IALLOC_BTREE_H__
8
9/*
10 * Inode map on-disk structures
11 */
12
13struct xfs_buf;
14struct xfs_btree_cur;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015struct xfs_mount;
16
17/*
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110018 * Btree block header size depends on a superblock flag.
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110019 */
Christoph Hellwigee1a47a2013-04-21 14:53:46 -050020#define XFS_INOBT_BLOCK_LEN(mp) \
21 (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
22 XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110023
24/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 * Record, key, and pointer address macros for btree blocks.
Christoph Hellwig136341b2008-10-30 17:11:40 +110026 *
27 * (note that some of these may appear unused, but they are used in userspace)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 */
Christoph Hellwig136341b2008-10-30 17:11:40 +110029#define XFS_INOBT_REC_ADDR(mp, block, index) \
30 ((xfs_inobt_rec_t *) \
31 ((char *)(block) + \
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110032 XFS_INOBT_BLOCK_LEN(mp) + \
Christoph Hellwig136341b2008-10-30 17:11:40 +110033 (((index) - 1) * sizeof(xfs_inobt_rec_t))))
Eric Sandeen2c36dde2007-02-10 18:37:33 +110034
Christoph Hellwig136341b2008-10-30 17:11:40 +110035#define XFS_INOBT_KEY_ADDR(mp, block, index) \
36 ((xfs_inobt_key_t *) \
37 ((char *)(block) + \
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110038 XFS_INOBT_BLOCK_LEN(mp) + \
Christoph Hellwig136341b2008-10-30 17:11:40 +110039 ((index) - 1) * sizeof(xfs_inobt_key_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Christoph Hellwig136341b2008-10-30 17:11:40 +110041#define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
42 ((xfs_inobt_ptr_t *) \
43 ((char *)(block) + \
Christoph Hellwig7cc95a82008-10-30 17:14:34 +110044 XFS_INOBT_BLOCK_LEN(mp) + \
Christoph Hellwig136341b2008-10-30 17:11:40 +110045 (maxrecs) * sizeof(xfs_inobt_key_t) + \
46 ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Christoph Hellwig561f7d12008-10-30 16:53:59 +110048extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *,
Brian Foster57bd3db2014-04-24 16:00:50 +100049 struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t,
50 xfs_btnum_t);
Christoph Hellwig60197e82008-10-30 17:11:19 +110051extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
Christoph Hellwig561f7d12008-10-30 16:53:59 +110052
Brian Foster4148c342015-05-29 09:09:05 +100053/* ir_holemask to inode allocation bitmap conversion */
54uint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *);
55
Brian Foster56d11152015-05-29 09:18:32 +100056#if defined(DEBUG) || defined(XFS_WARN)
57int xfs_inobt_rec_check_count(struct xfs_mount *,
58 struct xfs_inobt_rec_incore *);
59#else
60#define xfs_inobt_rec_check_count(mp, rec) 0
61#endif /* DEBUG */
62
Christoph Hellwig76d771b2017-01-25 07:49:35 -080063int xfs_finobt_calc_reserves(struct xfs_mount *mp, xfs_agnumber_t agno,
64 xfs_extlen_t *ask, xfs_extlen_t *used);
Darrick J. Wong14861c42018-05-09 10:02:01 -070065extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
66 unsigned long long len);
Christoph Hellwig76d771b2017-01-25 07:49:35 -080067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#endif /* __XFS_IALLOC_BTREE_H__ */