]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/xfs/xfs_inum.h
xfs: move btree cursor into bmalloca
[mirror_ubuntu-bionic-kernel.git] / fs / xfs / xfs_inum.h
CommitLineData
1da177e4 1/*
7b718769
NS
2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
7b718769
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
7b718769
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
1da177e4 13 *
7b718769
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1da177e4
LT
17 */
18#ifndef __XFS_INUM_H__
19#define __XFS_INUM_H__
20
21/*
22 * Inode number format:
23 * low inopblog bits - offset in block
24 * next agblklog bits - block number in ag
25 * next agno_log bits - ag number
26 * high agno_log-agblklog-inopblog bits - 0
27 */
28
29typedef __uint32_t xfs_agino_t; /* within allocation grp inode number */
30
1da177e4
LT
31#define NULLFSINO ((xfs_ino_t)-1)
32#define NULLAGINO ((xfs_agino_t)-1)
33
34struct xfs_mount;
35
a844f451
NS
36#define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1)
37#define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
38#define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
39#define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log
40#define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
41#define XFS_INO_BITS(mp) \
42 XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
43#define XFS_INO_TO_AGNO(mp,i) \
1da177e4 44 ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
a844f451 45#define XFS_INO_TO_AGINO(mp,i) \
1da177e4 46 ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
a844f451 47#define XFS_INO_TO_AGBNO(mp,i) \
1da177e4 48 (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
a844f451
NS
49 XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
50#define XFS_INO_TO_OFFSET(mp,i) \
1da177e4 51 ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
a844f451 52#define XFS_INO_TO_FSB(mp,i) \
1da177e4 53 XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
1da177e4
LT
54#define XFS_AGINO_TO_INO(mp,a,i) \
55 (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
1da177e4 56#define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
1da177e4
LT
57#define XFS_AGINO_TO_OFFSET(mp,i) \
58 ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
1da177e4
LT
59#define XFS_OFFBNO_TO_AGINO(mp,b,o) \
60 ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
1da177e4
LT
61
62#if XFS_BIG_INUMS
63#define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
1da177e4
LT
64#else
65#define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL))
66#endif
67#define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
68
69#endif /* __XFS_INUM_H__ */