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