Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 29 | typedef __uint32_t xfs_agino_t; /* within allocation grp inode number */ |
| 30 | |
| 31 | /* |
| 32 | * Useful inode bits for this kernel. |
| 33 | * Used in some places where having 64-bits in the 32-bit kernels |
| 34 | * costs too much. |
| 35 | */ |
| 36 | #if XFS_BIG_INUMS |
| 37 | typedef xfs_ino_t xfs_intino_t; |
| 38 | #else |
| 39 | typedef __uint32_t xfs_intino_t; |
| 40 | #endif |
| 41 | |
| 42 | #define NULLFSINO ((xfs_ino_t)-1) |
| 43 | #define NULLAGINO ((xfs_agino_t)-1) |
| 44 | |
| 45 | struct xfs_mount; |
| 46 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 47 | #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) |
| 48 | #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog |
| 49 | #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog |
| 50 | #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log |
| 51 | #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log |
| 52 | #define XFS_INO_BITS(mp) \ |
| 53 | XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) |
| 54 | #define XFS_INO_TO_AGNO(mp,i) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 56 | #define XFS_INO_TO_AGINO(mp,i) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 58 | #define XFS_INO_TO_AGBNO(mp,i) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 60 | XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) |
| 61 | #define XFS_INO_TO_OFFSET(mp,i) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 63 | #define XFS_INO_TO_FSB(mp,i) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define XFS_AGINO_TO_INO(mp,a,i) \ |
| 66 | (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #define XFS_AGINO_TO_OFFSET(mp,i) \ |
| 69 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ |
| 71 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | #if XFS_BIG_INUMS |
| 74 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #else |
| 76 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL)) |
| 77 | #endif |
| 78 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) |
| 79 | |
| 80 | #endif /* __XFS_INUM_H__ */ |