jfs_filsys.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2003
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  12. * the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _H_JFS_FILSYS
  19. #define _H_JFS_FILSYS
  20. /*
  21. * jfs_filsys.h
  22. *
  23. * file system (implementation-dependent) constants
  24. *
  25. * refer to <limits.h> for system wide implementation-dependent constants
  26. */
  27. /*
  28. * file system option (superblock flag)
  29. */
  30. /* directory option */
  31. #define JFS_UNICODE 0x00000001 /* unicode name */
  32. /* mount time flags for error handling */
  33. #define JFS_ERR_REMOUNT_RO 0x00000002 /* remount read-only */
  34. #define JFS_ERR_CONTINUE 0x00000004 /* continue */
  35. #define JFS_ERR_PANIC 0x00000008 /* panic */
  36. /* Quota support */
  37. #define JFS_USRQUOTA 0x00000010
  38. #define JFS_GRPQUOTA 0x00000020
  39. /* mount time flag to disable journaling to disk */
  40. #define JFS_NOINTEGRITY 0x00000040
  41. /* mount time flag to enable TRIM to ssd disks */
  42. #define JFS_DISCARD 0x00000080
  43. /* commit option */
  44. #define JFS_COMMIT 0x00000f00 /* commit option mask */
  45. #define JFS_GROUPCOMMIT 0x00000100 /* group (of 1) commit */
  46. #define JFS_LAZYCOMMIT 0x00000200 /* lazy commit */
  47. #define JFS_TMPFS 0x00000400 /* temporary file system -
  48. * do not log/commit:
  49. * Never implemented
  50. */
  51. /* log logical volume option */
  52. #define JFS_INLINELOG 0x00000800 /* inline log within file system */
  53. #define JFS_INLINEMOVE 0x00001000 /* inline log being moved */
  54. /* Secondary aggregate inode table */
  55. #define JFS_BAD_SAIT 0x00010000 /* current secondary ait is bad */
  56. /* sparse regular file support */
  57. #define JFS_SPARSE 0x00020000 /* sparse regular file */
  58. /* DASD Limits F226941 */
  59. #define JFS_DASD_ENABLED 0x00040000 /* DASD limits enabled */
  60. #define JFS_DASD_PRIME 0x00080000 /* Prime DASD usage on boot */
  61. /* big endian flag */
  62. #define JFS_SWAP_BYTES 0x00100000 /* running on big endian computer */
  63. /* Directory index */
  64. #define JFS_DIR_INDEX 0x00200000 /* Persistent index for */
  65. /* platform options */
  66. #define JFS_LINUX 0x10000000 /* Linux support */
  67. #define JFS_DFS 0x20000000 /* DCE DFS LFS support */
  68. /* Never implemented */
  69. #define JFS_OS2 0x40000000 /* OS/2 support */
  70. /* case-insensitive name/directory support */
  71. #define JFS_AIX 0x80000000 /* AIX support */
  72. /*
  73. * buffer cache configuration
  74. */
  75. /* page size */
  76. #ifdef PSIZE
  77. #undef PSIZE
  78. #endif
  79. #define PSIZE 4096 /* page size (in byte) */
  80. #define L2PSIZE 12 /* log2(PSIZE) */
  81. #define POFFSET 4095 /* offset within page */
  82. /* buffer page size */
  83. #define BPSIZE PSIZE
  84. /*
  85. * fs fundamental size
  86. *
  87. * PSIZE >= file system block size >= PBSIZE >= DISIZE
  88. */
  89. #define PBSIZE 512 /* physical block size (in byte) */
  90. #define L2PBSIZE 9 /* log2(PBSIZE) */
  91. #define DISIZE 512 /* on-disk inode size (in byte) */
  92. #define L2DISIZE 9 /* log2(DISIZE) */
  93. #define IDATASIZE 256 /* inode inline data size */
  94. #define IXATTRSIZE 128 /* inode inline extended attribute size */
  95. #define XTPAGE_SIZE 4096
  96. #define log2_PAGESIZE 12
  97. #define IAG_SIZE 4096
  98. #define IAG_EXTENT_SIZE 4096
  99. #define INOSPERIAG 4096 /* number of disk inodes per iag */
  100. #define L2INOSPERIAG 12 /* l2 number of disk inodes per iag */
  101. #define INOSPEREXT 32 /* number of disk inode per extent */
  102. #define L2INOSPEREXT 5 /* l2 number of disk inode per extent */
  103. #define IXSIZE (DISIZE * INOSPEREXT) /* inode extent size */
  104. #define INOSPERPAGE 8 /* number of disk inodes per 4K page */
  105. #define L2INOSPERPAGE 3 /* log2(INOSPERPAGE) */
  106. #define IAGFREELIST_LWM 64
  107. #define INODE_EXTENT_SIZE IXSIZE /* inode extent size */
  108. #define NUM_INODE_PER_EXTENT INOSPEREXT
  109. #define NUM_INODE_PER_IAG INOSPERIAG
  110. #define MINBLOCKSIZE 512
  111. #define MAXBLOCKSIZE 4096
  112. #define MAXFILESIZE ((s64)1 << 52)
  113. #define JFS_LINK_MAX 0xffffffff
  114. /* Minimum number of bytes supported for a JFS partition */
  115. #define MINJFS (0x1000000)
  116. #define MINJFSTEXT "16"
  117. /*
  118. * file system block size -> physical block size
  119. */
  120. #define LBOFFSET(x) ((x) & (PBSIZE - 1))
  121. #define LBNUMBER(x) ((x) >> L2PBSIZE)
  122. #define LBLK2PBLK(sb,b) ((b) << (sb->s_blocksize_bits - L2PBSIZE))
  123. #define PBLK2LBLK(sb,b) ((b) >> (sb->s_blocksize_bits - L2PBSIZE))
  124. /* size in byte -> last page number */
  125. #define SIZE2PN(size) ( ((s64)((size) - 1)) >> (L2PSIZE) )
  126. /* size in byte -> last file system block number */
  127. #define SIZE2BN(size, l2bsize) ( ((s64)((size) - 1)) >> (l2bsize) )
  128. /*
  129. * fixed physical block address (physical block size = 512 byte)
  130. *
  131. * NOTE: since we can't guarantee a physical block size of 512 bytes the use of
  132. * these macros should be removed and the byte offset macros used instead.
  133. */
  134. #define SUPER1_B 64 /* primary superblock */
  135. #define AIMAP_B (SUPER1_B + 8) /* 1st extent of aggregate inode map */
  136. #define AITBL_B (AIMAP_B + 16) /*
  137. * 1st extent of aggregate inode table
  138. */
  139. #define SUPER2_B (AITBL_B + 32) /* 2ndary superblock pbn */
  140. #define BMAP_B (SUPER2_B + 8) /* block allocation map */
  141. /*
  142. * SIZE_OF_SUPER defines the total amount of space reserved on disk for the
  143. * superblock. This is not the same as the superblock structure, since all of
  144. * this space is not currently being used.
  145. */
  146. #define SIZE_OF_SUPER PSIZE
  147. /*
  148. * SIZE_OF_AG_TABLE defines the amount of space reserved to hold the AG table
  149. */
  150. #define SIZE_OF_AG_TABLE PSIZE
  151. /*
  152. * SIZE_OF_MAP_PAGE defines the amount of disk space reserved for each page of
  153. * the inode allocation map (to hold iag)
  154. */
  155. #define SIZE_OF_MAP_PAGE PSIZE
  156. /*
  157. * fixed byte offset address
  158. */
  159. #define SUPER1_OFF 0x8000 /* primary superblock */
  160. #define AIMAP_OFF (SUPER1_OFF + SIZE_OF_SUPER)
  161. /*
  162. * Control page of aggregate inode map
  163. * followed by 1st extent of map
  164. */
  165. #define AITBL_OFF (AIMAP_OFF + (SIZE_OF_MAP_PAGE << 1))
  166. /*
  167. * 1st extent of aggregate inode table
  168. */
  169. #define SUPER2_OFF (AITBL_OFF + INODE_EXTENT_SIZE)
  170. /*
  171. * secondary superblock
  172. */
  173. #define BMAP_OFF (SUPER2_OFF + SIZE_OF_SUPER)
  174. /*
  175. * block allocation map
  176. */
  177. /*
  178. * The following macro is used to indicate the number of reserved disk blocks at
  179. * the front of an aggregate, in terms of physical blocks. This value is
  180. * currently defined to be 32K. This turns out to be the same as the primary
  181. * superblock's address, since it directly follows the reserved blocks.
  182. */
  183. #define AGGR_RSVD_BLOCKS SUPER1_B
  184. /*
  185. * The following macro is used to indicate the number of reserved bytes at the
  186. * front of an aggregate. This value is currently defined to be 32K. This
  187. * turns out to be the same as the primary superblock's byte offset, since it
  188. * directly follows the reserved blocks.
  189. */
  190. #define AGGR_RSVD_BYTES SUPER1_OFF
  191. /*
  192. * The following macro defines the byte offset for the first inode extent in
  193. * the aggregate inode table. This allows us to find the self inode to find the
  194. * rest of the table. Currently this value is 44K.
  195. */
  196. #define AGGR_INODE_TABLE_START AITBL_OFF
  197. /*
  198. * fixed reserved inode number
  199. */
  200. /* aggregate inode */
  201. #define AGGR_RESERVED_I 0 /* aggregate inode (reserved) */
  202. #define AGGREGATE_I 1 /* aggregate inode map inode */
  203. #define BMAP_I 2 /* aggregate block allocation map inode */
  204. #define LOG_I 3 /* aggregate inline log inode */
  205. #define BADBLOCK_I 4 /* aggregate bad block inode */
  206. #define FILESYSTEM_I 16 /* 1st/only fileset inode in ait:
  207. * fileset inode map inode
  208. */
  209. /* per fileset inode */
  210. #define FILESET_RSVD_I 0 /* fileset inode (reserved) */
  211. #define FILESET_EXT_I 1 /* fileset inode extension */
  212. #define ROOT_I 2 /* fileset root inode */
  213. #define ACL_I 3 /* fileset ACL inode */
  214. #define FILESET_OBJECT_I 4 /* the first fileset inode available for a file
  215. * or directory or link...
  216. */
  217. #define FIRST_FILESET_INO 16 /* the first aggregate inode which describes
  218. * an inode. (To fsck this is also the first
  219. * inode in part 2 of the agg inode table.)
  220. */
  221. /*
  222. * directory configuration
  223. */
  224. #define JFS_NAME_MAX 255
  225. #define JFS_PATH_MAX BPSIZE
  226. /*
  227. * file system state (superblock state)
  228. */
  229. #define FM_CLEAN 0x00000000 /* file system is unmounted and clean */
  230. #define FM_MOUNT 0x00000001 /* file system is mounted cleanly */
  231. #define FM_DIRTY 0x00000002 /* file system was not unmounted and clean
  232. * when mounted or
  233. * commit failure occurred while being mounted:
  234. * fsck() must be run to repair
  235. */
  236. #define FM_LOGREDO 0x00000004 /* log based recovery (logredo()) failed:
  237. * fsck() must be run to repair
  238. */
  239. #define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */
  240. #endif /* _H_JFS_FILSYS */