jfs_filsys.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:9k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *   Copyright (c) International Business Machines Corp., 2000-2001
  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. /* platform option (conditional compilation) */
  31. #define JFS_AIX 0x80000000 /* AIX support */
  32. /* POSIX name/directory  support */
  33. #define JFS_OS2 0x40000000 /* OS/2 support */
  34. /* case-insensitive name/directory support */
  35. #define JFS_DFS 0x20000000 /* DCE DFS LFS support */
  36. #define JFS_LINUX       0x10000000 /* Linux support */
  37. /* case-sensitive name/directory support */
  38. /* directory option */
  39. #define JFS_UNICODE 0x00000001 /* unicode name */
  40. /* commit option */
  41. #define JFS_COMMIT 0x00000f00 /* commit option mask */
  42. #define JFS_GROUPCOMMIT 0x00000100 /* group (of 1) commit */
  43. #define JFS_LAZYCOMMIT 0x00000200 /* lazy commit */
  44. #define JFS_TMPFS 0x00000400 /* temporary file system - 
  45.  * do not log/commit:
  46.  */
  47. /* log logical volume option */
  48. #define JFS_INLINELOG 0x00000800 /* inline log within file system */
  49. #define JFS_INLINEMOVE 0x00001000 /* inline log being moved */
  50. /* Secondary aggregate inode table */
  51. #define JFS_BAD_SAIT 0x00010000 /* current secondary ait is bad */
  52. /* sparse regular file support */
  53. #define JFS_SPARSE 0x00020000 /* sparse regular file */
  54. /* DASD Limits F226941 */
  55. #define JFS_DASD_ENABLED 0x00040000 /* DASD limits enabled */
  56. #define JFS_DASD_PRIME 0x00080000 /* Prime DASD usage on boot */
  57. /* big endian flag */
  58. #define JFS_SWAP_BYTES 0x00100000 /* running on big endian computer */
  59. /* Directory index */
  60. #define JFS_DIR_INDEX 0x00200000 /* Persistant index for */
  61. /* directory entries    */
  62. /*
  63.  * buffer cache configuration
  64.  */
  65. /* page size */
  66. #ifdef PSIZE
  67. #undef PSIZE
  68. #endif
  69. #define PSIZE 4096 /* page size (in byte) */
  70. #define L2PSIZE 12 /* log2(PSIZE) */
  71. #define POFFSET 4095 /* offset within page */
  72. /* buffer page size */
  73. #define BPSIZE PSIZE
  74. /*
  75.  * fs fundamental size
  76.  *
  77.  * PSIZE >= file system block size >= PBSIZE >= DISIZE
  78.  */
  79. #define PBSIZE 512 /* physical block size (in byte) */
  80. #define L2PBSIZE 9 /* log2(PBSIZE) */
  81. #define DISIZE 512 /* on-disk inode size (in byte) */
  82. #define L2DISIZE 9 /* log2(DISIZE) */
  83. #define IDATASIZE 256 /* inode inline data size */
  84. #define IXATTRSIZE 128 /* inode inline extended attribute size */
  85. #define XTPAGE_SIZE     4096
  86. #define log2_PAGESIZE     12
  87. #define IAG_SIZE        4096
  88. #define IAG_EXTENT_SIZE 4096
  89. #define INOSPERIAG 4096 /* number of disk inodes per iag */
  90. #define L2INOSPERIAG 12 /* l2 number of disk inodes per iag */
  91. #define INOSPEREXT 32 /* number of disk inode per extent */
  92. #define L2INOSPEREXT 5 /* l2 number of disk inode per extent */
  93. #define IXSIZE (DISIZE * INOSPEREXT) /* inode extent size */
  94. #define INOSPERPAGE 8 /* number of disk inodes per 4K page */
  95. #define L2INOSPERPAGE 3 /* log2(INOSPERPAGE) */
  96. #define IAGFREELIST_LWM 64
  97. #define INODE_EXTENT_SIZE IXSIZE /* inode extent size */
  98. #define NUM_INODE_PER_EXTENT INOSPEREXT
  99. #define NUM_INODE_PER_IAG INOSPERIAG
  100. #define MINBLOCKSIZE 512
  101. #define MAXBLOCKSIZE 4096
  102. #define MAXFILESIZE ((s64)1 << 52)
  103. #define JFS_LINK_MAX 65535 /* nlink_t is unsigned short */
  104. /* Minimum number of bytes supported for a JFS partition */
  105. #define MINJFS (0x1000000)
  106. #define MINJFSTEXT "16"
  107. /*
  108.  * file system block size -> physical block size
  109.  */
  110. #define LBOFFSET(x) ((x) & (PBSIZE - 1))
  111. #define LBNUMBER(x) ((x) >> L2PBSIZE)
  112. #define LBLK2PBLK(sb,b) ((b) << (sb->s_blocksize_bits - L2PBSIZE))
  113. #define PBLK2LBLK(sb,b) ((b) >> (sb->s_blocksize_bits - L2PBSIZE))
  114. /* size in byte -> last page number */
  115. #define SIZE2PN(size) ( ((s64)((size) - 1)) >> (L2PSIZE) )
  116. /* size in byte -> last file system block number */
  117. #define SIZE2BN(size, l2bsize) ( ((s64)((size) - 1)) >> (l2bsize) )
  118. /*
  119.  * fixed physical block address (physical block size = 512 byte)
  120.  *
  121.  * NOTE: since we can't guarantee a physical block size of 512 bytes the use of
  122.  *  these macros should be removed and the byte offset macros used instead.
  123.  */
  124. #define SUPER1_B 64 /* primary superblock */
  125. #define AIMAP_B (SUPER1_B + 8) /* 1st extent of aggregate inode map */
  126. #define AITBL_B (AIMAP_B + 16) /*
  127.  * 1st extent of aggregate inode table
  128.  */
  129. #define SUPER2_B (AITBL_B + 32) /* 2ndary superblock pbn */
  130. #define BMAP_B (SUPER2_B + 8) /* block allocation map */
  131. /*
  132.  * SIZE_OF_SUPER defines the total amount of space reserved on disk for the
  133.  * superblock.  This is not the same as the superblock structure, since all of
  134.  * this space is not currently being used.
  135.  */
  136. #define SIZE_OF_SUPER PSIZE
  137. /*
  138.  * SIZE_OF_AG_TABLE defines the amount of space reserved to hold the AG table
  139.  */
  140. #define SIZE_OF_AG_TABLE PSIZE
  141. /*
  142.  * SIZE_OF_MAP_PAGE defines the amount of disk space reserved for each page of
  143.  * the inode allocation map (to hold iag)
  144.  */
  145. #define SIZE_OF_MAP_PAGE PSIZE
  146. /*
  147.  * fixed byte offset address
  148.  */
  149. #define SUPER1_OFF 0x8000 /* primary superblock */
  150. #define AIMAP_OFF (SUPER1_OFF + SIZE_OF_SUPER)
  151. /*
  152.  * Control page of aggregate inode map
  153.  * followed by 1st extent of map
  154.  */
  155. #define AITBL_OFF (AIMAP_OFF + (SIZE_OF_MAP_PAGE << 1))
  156. /* 
  157.  * 1st extent of aggregate inode table
  158.  */
  159. #define SUPER2_OFF (AITBL_OFF + INODE_EXTENT_SIZE)
  160. /*
  161.  * secondary superblock
  162.  */
  163. #define BMAP_OFF (SUPER2_OFF + SIZE_OF_SUPER)
  164. /*
  165.  * block allocation map
  166.  */
  167. /*
  168.  * The following macro is used to indicate the number of reserved disk blocks at
  169.  * the front of an aggregate, in terms of physical blocks.  This value is
  170.  * currently defined to be 32K.  This turns out to be the same as the primary
  171.  * superblock's address, since it directly follows the reserved blocks.
  172.  */
  173. #define AGGR_RSVD_BLOCKS SUPER1_B
  174. /*
  175.  * The following macro is used to indicate the number of reserved bytes at the
  176.  * front of an aggregate.  This value is currently defined to be 32K.  This
  177.  * turns out to be the same as the primary superblock's byte offset, since it
  178.  * directly follows the reserved blocks.
  179.  */
  180. #define AGGR_RSVD_BYTES SUPER1_OFF
  181. /*
  182.  * The following macro defines the byte offset for the first inode extent in
  183.  * the aggregate inode table.  This allows us to find the self inode to find the
  184.  * rest of the table.  Currently this value is 44K.
  185.  */
  186. #define AGGR_INODE_TABLE_START AITBL_OFF
  187. /*
  188.  * fixed reserved inode number
  189.  */
  190. /* aggregate inode */
  191. #define AGGR_RESERVED_I 0 /* aggregate inode (reserved) */
  192. #define AGGREGATE_I 1 /* aggregate inode map inode */
  193. #define BMAP_I 2 /* aggregate block allocation map inode */
  194. #define LOG_I 3 /* aggregate inline log inode */
  195. #define BADBLOCK_I 4 /* aggregate bad block inode */
  196. #define FILESYSTEM_I 16 /* 1st/only fileset inode in ait:
  197.  * fileset inode map inode
  198.  */
  199. /* per fileset inode */
  200. #define FILESET_RSVD_I 0 /* fileset inode (reserved) */
  201. #define FILESET_EXT_I 1 /* fileset inode extension */
  202. #define ROOT_I 2 /* fileset root inode */
  203. #define ACL_I 3 /* fileset ACL inode */
  204. #define FILESET_OBJECT_I 4 /* the first fileset inode available for a file
  205.  * or directory or link...
  206.  */
  207. #define FIRST_FILESET_INO 16 /* the first aggregate inode which describes
  208.  * an inode.  (To fsck this is also the first
  209.  * inode in part 2 of the agg inode table.)
  210.  */
  211. /*
  212.  * directory configuration
  213.  */
  214. #define JFS_NAME_MAX 255
  215. #define JFS_PATH_MAX BPSIZE
  216. /*
  217.  * file system state (superblock state)
  218.  */
  219. #define FM_CLEAN 0x00000000 /* file system is unmounted and clean */
  220. #define FM_MOUNT 0x00000001 /* file system is mounted cleanly */
  221. #define FM_DIRTY 0x00000002 /* file system was not unmounted and clean 
  222.  * when mounted or 
  223.  * commit failure occurred while being mounted:
  224.  * fsck() must be run to repair 
  225.  */
  226. #define FM_LOGREDO 0x00000004 /* log based recovery (logredo()) failed:
  227.  * fsck() must be run to repair 
  228.  */
  229. #define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */
  230. #endif /* _H_JFS_FILSYS */