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