xfs_inum.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. * Inode number format:
  36. * low inopblog bits - offset in block
  37. * next agblklog bits - block number in ag
  38. * next agno_log bits - ag number
  39. * high agno_log-agblklog-inopblog bits - 0
  40. */
  41. typedef __uint32_t xfs_agino_t; /* within allocation grp inode number */
  42. /*
  43. * Useful inode bits for this kernel.
  44. * Used in some places where having 64-bits in the 32-bit kernels
  45. * costs too much.
  46. */
  47. #if XFS_BIG_INUMS
  48. typedef xfs_ino_t xfs_intino_t;
  49. #else
  50. typedef __uint32_t xfs_intino_t;
  51. #endif
  52. #define NULLFSINO ((xfs_ino_t)-1)
  53. #define NULLAGINO ((xfs_agino_t)-1)
  54. struct xfs_mount;
  55. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_MASK)
  56. __uint32_t xfs_ino_mask(int k);
  57. #define XFS_INO_MASK(k) xfs_ino_mask(k)
  58. #else
  59. #define XFS_INO_MASK(k) ((__uint32_t)((1ULL << (k)) - 1))
  60. #endif
  61. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_OFFSET_BITS)
  62. int xfs_ino_offset_bits(struct xfs_mount *mp);
  63. #define XFS_INO_OFFSET_BITS(mp) xfs_ino_offset_bits(mp)
  64. #else
  65. #define XFS_INO_OFFSET_BITS(mp) ((mp)->m_sb.sb_inopblog)
  66. #endif
  67. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGBNO_BITS)
  68. int xfs_ino_agbno_bits(struct xfs_mount *mp);
  69. #define XFS_INO_AGBNO_BITS(mp) xfs_ino_agbno_bits(mp)
  70. #else
  71. #define XFS_INO_AGBNO_BITS(mp) ((mp)->m_sb.sb_agblklog)
  72. #endif
  73. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGINO_BITS)
  74. int xfs_ino_agino_bits(struct xfs_mount *mp);
  75. #define XFS_INO_AGINO_BITS(mp) xfs_ino_agino_bits(mp)
  76. #else
  77. #define XFS_INO_AGINO_BITS(mp) ((mp)->m_agino_log)
  78. #endif
  79. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGNO_BITS)
  80. int xfs_ino_agno_bits(struct xfs_mount *mp);
  81. #define XFS_INO_AGNO_BITS(mp) xfs_ino_agno_bits(mp)
  82. #else
  83. #define XFS_INO_AGNO_BITS(mp) ((mp)->m_agno_log)
  84. #endif
  85. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_BITS)
  86. int xfs_ino_bits(struct xfs_mount *mp);
  87. #define XFS_INO_BITS(mp) xfs_ino_bits(mp)
  88. #else
  89. #define XFS_INO_BITS(mp) (XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp))
  90. #endif
  91. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGNO)
  92. xfs_agnumber_t xfs_ino_to_agno(struct xfs_mount *mp, xfs_ino_t i);
  93. #define XFS_INO_TO_AGNO(mp,i) xfs_ino_to_agno(mp,i)
  94. #else
  95. #define XFS_INO_TO_AGNO(mp,i) \
  96. ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
  97. #endif
  98. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGINO)
  99. xfs_agino_t xfs_ino_to_agino(struct xfs_mount *mp, xfs_ino_t i);
  100. #define XFS_INO_TO_AGINO(mp,i) xfs_ino_to_agino(mp,i)
  101. #else
  102. #define XFS_INO_TO_AGINO(mp,i) \
  103. ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
  104. #endif
  105. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGBNO)
  106. xfs_agblock_t xfs_ino_to_agbno(struct xfs_mount *mp, xfs_ino_t i);
  107. #define XFS_INO_TO_AGBNO(mp,i) xfs_ino_to_agbno(mp,i)
  108. #else
  109. #define XFS_INO_TO_AGBNO(mp,i) \
  110. (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
  111. XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
  112. #endif
  113. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_OFFSET)
  114. int xfs_ino_to_offset(struct xfs_mount *mp, xfs_ino_t i);
  115. #define XFS_INO_TO_OFFSET(mp,i) xfs_ino_to_offset(mp,i)
  116. #else
  117. #define XFS_INO_TO_OFFSET(mp,i) \
  118. ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  119. #endif
  120. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_FSB)
  121. xfs_fsblock_t xfs_ino_to_fsb(struct xfs_mount *mp, xfs_ino_t i);
  122. #define XFS_INO_TO_FSB(mp,i) xfs_ino_to_fsb(mp,i)
  123. #else
  124. #define XFS_INO_TO_FSB(mp,i) \
  125. XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
  126. #endif
  127. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_INO)
  128. xfs_ino_t
  129. xfs_agino_to_ino(struct xfs_mount *mp, xfs_agnumber_t a, xfs_agino_t i);
  130. #define XFS_AGINO_TO_INO(mp,a,i) xfs_agino_to_ino(mp,a,i)
  131. #else
  132. #define XFS_AGINO_TO_INO(mp,a,i) \
  133. (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
  134. #endif
  135. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_AGBNO)
  136. xfs_agblock_t xfs_agino_to_agbno(struct xfs_mount *mp, xfs_agino_t i);
  137. #define XFS_AGINO_TO_AGBNO(mp,i) xfs_agino_to_agbno(mp,i)
  138. #else
  139. #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
  140. #endif
  141. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_OFFSET)
  142. int xfs_agino_to_offset(struct xfs_mount *mp, xfs_agino_t i);
  143. #define XFS_AGINO_TO_OFFSET(mp,i) xfs_agino_to_offset(mp,i)
  144. #else
  145. #define XFS_AGINO_TO_OFFSET(mp,i) \
  146. ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  147. #endif
  148. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_OFFBNO_TO_AGINO)
  149. xfs_agino_t xfs_offbno_to_agino(struct xfs_mount *mp, xfs_agblock_t b, int o);
  150. #define XFS_OFFBNO_TO_AGINO(mp,b,o) xfs_offbno_to_agino(mp,b,o)
  151. #else
  152. #define XFS_OFFBNO_TO_AGINO(mp,b,o) \
  153. ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
  154. #endif
  155. #if XFS_BIG_INUMS
  156. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
  157. #define XFS_INO64_OFFSET ((xfs_ino_t)(1ULL << 32))
  158. #else
  159. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL))
  160. #endif
  161. #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
  162. #endif /* __XFS_INUM_H__ */