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