]> err.no Git - linux-2.6/blob - fs/xfs/xfs_inum.h
[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[linux-2.6] / fs / xfs / xfs_inum.h
1 /*
2  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * Further, this software is distributed without any warranty that it is
13  * free of the rightful claim of any third person regarding infringement
14  * or the like.  Any license provided herein, whether implied or
15  * otherwise, applies only to this software file.  Patent licenses, if
16  * any, provided herein do not apply to combinations of this program with
17  * other software, or any other product whatsoever.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write the Free Software Foundation, Inc., 59
21  * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22  *
23  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24  * Mountain View, CA  94043, or:
25  *
26  * http://www.sgi.com
27  *
28  * For further information regarding this notice, see:
29  *
30  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31  */
32 #ifndef __XFS_INUM_H__
33 #define __XFS_INUM_H__
34
35 /*
36  * Inode number format:
37  * low inopblog bits - offset in block
38  * next agblklog bits - block number in ag
39  * next agno_log bits - ag number
40  * high agno_log-agblklog-inopblog bits - 0
41  */
42
43 typedef __uint32_t      xfs_agino_t;    /* within allocation grp inode number */
44
45 /*
46  * Useful inode bits for this kernel.
47  * Used in some places where having 64-bits in the 32-bit kernels
48  * costs too much.
49  */
50 #if XFS_BIG_INUMS
51 typedef xfs_ino_t       xfs_intino_t;
52 #else
53 typedef __uint32_t      xfs_intino_t;
54 #endif
55
56 #define NULLFSINO       ((xfs_ino_t)-1)
57 #define NULLAGINO       ((xfs_agino_t)-1)
58
59 struct xfs_mount;
60
61 #define XFS_INO_MASK(k)                 (__uint32_t)((1ULL << (k)) - 1)
62 #define XFS_INO_OFFSET_BITS(mp)         (mp)->m_sb.sb_inopblog
63 #define XFS_INO_AGBNO_BITS(mp)          (mp)->m_sb.sb_agblklog
64 #define XFS_INO_AGINO_BITS(mp)          (mp)->m_agino_log
65 #define XFS_INO_AGNO_BITS(mp)           (mp)->m_agno_log
66 #define XFS_INO_BITS(mp)                \
67         XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
68 #define XFS_INO_TO_AGNO(mp,i)           \
69         ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
70 #define XFS_INO_TO_AGINO(mp,i)          \
71         ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
72 #define XFS_INO_TO_AGBNO(mp,i)          \
73         (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
74                 XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
75 #define XFS_INO_TO_OFFSET(mp,i)         \
76         ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
77 #define XFS_INO_TO_FSB(mp,i)            \
78         XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
79 #define XFS_AGINO_TO_INO(mp,a,i)        \
80         (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
81 #define XFS_AGINO_TO_AGBNO(mp,i)        ((i) >> XFS_INO_OFFSET_BITS(mp))
82 #define XFS_AGINO_TO_OFFSET(mp,i)       \
83         ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
84 #define XFS_OFFBNO_TO_AGINO(mp,b,o)     \
85         ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
86
87 #if XFS_BIG_INUMS
88 #define XFS_MAXINUMBER          ((xfs_ino_t)((1ULL << 56) - 1ULL))
89 #define XFS_INO64_OFFSET        ((xfs_ino_t)(1ULL << 32))
90 #else
91 #define XFS_MAXINUMBER          ((xfs_ino_t)((1ULL << 32) - 1ULL))
92 #endif
93 #define XFS_MAXINUMBER_32       ((xfs_ino_t)((1ULL << 32) - 1ULL))
94
95 #endif  /* __XFS_INUM_H__ */