Commit | Line | Data |
---|---|---|
ccd979bd MF |
1 | /* -*- mode: c; c-basic-offset: 8; -*- |
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | |
3 | * | |
4 | * ocfs2_fs.h | |
5 | * | |
6 | * On-disk structures for OCFS2. | |
7 | * | |
8 | * Copyright (C) 2002, 2004 Oracle. All rights reserved. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU General Public | |
12 | * License, version 2, as published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public | |
20 | * License along with this program; if not, write to the | |
21 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 | * Boston, MA 021110-1307, USA. | |
23 | */ | |
24 | ||
25 | #ifndef _OCFS2_FS_H | |
26 | #define _OCFS2_FS_H | |
27 | ||
28 | /* Version */ | |
29 | #define OCFS2_MAJOR_REV_LEVEL 0 | |
30 | #define OCFS2_MINOR_REV_LEVEL 90 | |
31 | ||
32 | /* | |
33 | * An OCFS2 volume starts this way: | |
34 | * Sector 0: Valid ocfs1_vol_disk_hdr that cleanly fails to mount OCFS. | |
35 | * Sector 1: Valid ocfs1_vol_label that cleanly fails to mount OCFS. | |
36 | * Block OCFS2_SUPER_BLOCK_BLKNO: OCFS2 superblock. | |
37 | * | |
38 | * All other structures are found from the superblock information. | |
39 | * | |
40 | * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a | |
41 | * blocksize of 2K, it is 4096 bytes into disk. | |
42 | */ | |
43 | #define OCFS2_SUPER_BLOCK_BLKNO 2 | |
44 | ||
45 | /* | |
46 | * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could | |
47 | * grow if needed. | |
48 | */ | |
49 | #define OCFS2_MIN_CLUSTERSIZE 4096 | |
50 | #define OCFS2_MAX_CLUSTERSIZE 1048576 | |
51 | ||
52 | /* | |
53 | * Blocks cannot be bigger than clusters, so the maximum blocksize is the | |
54 | * minimum cluster size. | |
55 | */ | |
56 | #define OCFS2_MIN_BLOCKSIZE 512 | |
57 | #define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE | |
58 | ||
59 | /* Filesystem magic number */ | |
60 | #define OCFS2_SUPER_MAGIC 0x7461636f | |
61 | ||
62 | /* Object signatures */ | |
63 | #define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2" | |
64 | #define OCFS2_INODE_SIGNATURE "INODE01" | |
65 | #define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01" | |
66 | #define OCFS2_GROUP_DESC_SIGNATURE "GROUP01" | |
5a7bc8eb | 67 | #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01" |
ccd979bd MF |
68 | |
69 | /* Compatibility flags */ | |
70 | #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ | |
71 | ( OCFS2_SB(sb)->s_feature_compat & (mask) ) | |
72 | #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \ | |
73 | ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) ) | |
74 | #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \ | |
75 | ( OCFS2_SB(sb)->s_feature_incompat & (mask) ) | |
76 | #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \ | |
77 | OCFS2_SB(sb)->s_feature_compat |= (mask) | |
78 | #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \ | |
79 | OCFS2_SB(sb)->s_feature_ro_compat |= (mask) | |
80 | #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \ | |
81 | OCFS2_SB(sb)->s_feature_incompat |= (mask) | |
82 | #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \ | |
83 | OCFS2_SB(sb)->s_feature_compat &= ~(mask) | |
84 | #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ | |
85 | OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask) | |
86 | #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ | |
87 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) | |
88 | ||
a9772189 JB |
89 | #define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \ |
90 | | OCFS2_FEATURE_COMPAT_JBD2_SB) | |
dcd0538f | 91 | #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \ |
15b1e36b | 92 | | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \ |
386a2ef8 | 93 | | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \ |
b61817e1 | 94 | | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ |
8154da3d TY |
95 | | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \ |
96 | | OCFS2_FEATURE_INCOMPAT_XATTR) | |
19ece546 JK |
97 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ |
98 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | |
99 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | |
ccd979bd MF |
100 | |
101 | /* | |
102 | * Heartbeat-only devices are missing journals and other files. The | |
103 | * filesystem driver can't load them, but the library can. Never put | |
104 | * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*. | |
105 | */ | |
106 | #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 | |
107 | ||
8903901d MF |
108 | /* |
109 | * tunefs sets this incompat flag before starting the resize and clears it | |
110 | * at the end. This flag protects users from inadvertently mounting the fs | |
111 | * after an aborted run without fsck-ing. | |
112 | */ | |
113 | #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004 | |
ccd979bd | 114 | |
c271c5c2 SM |
115 | /* Used to denote a non-clustered volume */ |
116 | #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008 | |
117 | ||
8903901d MF |
118 | /* Support for sparse allocation in b-trees */ |
119 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 | |
120 | ||
92e91ce2 MF |
121 | /* |
122 | * Tunefs sets this incompat flag before starting an operation which | |
123 | * would require cleanup on abort. This is done to protect users from | |
124 | * inadvertently mounting the fs after an aborted run without | |
125 | * fsck-ing. | |
126 | * | |
127 | * s_tunefs_flags on the super block describes precisely which | |
128 | * operations were in progress. | |
129 | */ | |
130 | #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020 | |
131 | ||
15b1e36b MF |
132 | /* Support for data packed into inode blocks */ |
133 | #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040 | |
134 | ||
b61817e1 JB |
135 | /* |
136 | * Support for alternate, userspace cluster stacks. If set, the superblock | |
137 | * field s_cluster_info contains a tag for the alternate stack in use as | |
138 | * well as the name of the cluster being joined. | |
139 | * mount.ocfs2 must pass in a matching stack name. | |
140 | * | |
141 | * If not set, the classic stack will be used. This is compatbile with | |
142 | * all older versions. | |
143 | */ | |
144 | #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080 | |
145 | ||
8154da3d TY |
146 | /* Support for the extended slot map */ |
147 | #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100 | |
148 | ||
149 | /* Support for extended attributes */ | |
150 | #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200 | |
151 | ||
50af94b1 MF |
152 | /* |
153 | * backup superblock flag is used to indicate that this volume | |
154 | * has backup superblocks. | |
155 | */ | |
156 | #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001 | |
157 | ||
a9772189 JB |
158 | /* |
159 | * The filesystem will correctly handle journal feature bits. | |
160 | */ | |
161 | #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002 | |
162 | ||
328d5752 MF |
163 | /* |
164 | * Unwritten extents support. | |
165 | */ | |
166 | #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001 | |
167 | ||
1a224ad1 JK |
168 | /* |
169 | * Maintain quota information for this filesystem | |
170 | */ | |
171 | #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002 | |
172 | #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004 | |
173 | ||
50af94b1 MF |
174 | /* The byte offset of the first backup block will be 1G. |
175 | * The following will be 4G, 16G, 64G, 256G and 1T. | |
176 | */ | |
177 | #define OCFS2_BACKUP_SB_START 1 << 30 | |
178 | ||
179 | /* the max backup superblock nums */ | |
180 | #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6 | |
181 | ||
92e91ce2 MF |
182 | /* |
183 | * Flags on ocfs2_super_block.s_tunefs_flags | |
184 | */ | |
185 | #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */ | |
186 | ||
ccd979bd MF |
187 | /* |
188 | * Flags on ocfs2_dinode.i_flags | |
189 | */ | |
190 | #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ | |
191 | #define OCFS2_UNUSED2_FL (0x00000002) | |
192 | #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */ | |
193 | #define OCFS2_UNUSED3_FL (0x00000008) | |
194 | /* System inode flags */ | |
195 | #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */ | |
196 | #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */ | |
197 | #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */ | |
198 | #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */ | |
199 | #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */ | |
200 | #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */ | |
201 | #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */ | |
202 | #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */ | |
1a224ad1 | 203 | #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */ |
ccd979bd | 204 | |
15b1e36b MF |
205 | /* |
206 | * Flags on ocfs2_dinode.i_dyn_features | |
207 | * | |
208 | * These can change much more often than i_flags. When adding flags, | |
209 | * keep in mind that i_dyn_features is only 16 bits wide. | |
210 | */ | |
211 | #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */ | |
212 | #define OCFS2_HAS_XATTR_FL (0x0002) | |
213 | #define OCFS2_INLINE_XATTR_FL (0x0004) | |
214 | #define OCFS2_INDEXED_DIR_FL (0x0008) | |
215 | ||
ca4d147e HP |
216 | /* Inode attributes, keep in sync with EXT2 */ |
217 | #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */ | |
218 | #define OCFS2_UNRM_FL (0x00000002) /* Undelete */ | |
219 | #define OCFS2_COMPR_FL (0x00000004) /* Compress file */ | |
220 | #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */ | |
221 | #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */ | |
222 | #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */ | |
223 | #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */ | |
224 | #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */ | |
225 | #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */ | |
226 | ||
227 | #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */ | |
228 | #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */ | |
229 | ||
e48edee2 MF |
230 | /* |
231 | * Extent record flags (e_node.leaf.flags) | |
232 | */ | |
233 | #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but | |
234 | * unwritten */ | |
235 | ||
ca4d147e HP |
236 | /* |
237 | * ioctl commands | |
238 | */ | |
239 | #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long) | |
240 | #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long) | |
586d232b MF |
241 | #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int) |
242 | #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int) | |
ca4d147e | 243 | |
b2580103 MF |
244 | /* |
245 | * Space reservation / allocation / free ioctls and argument structure | |
246 | * are designed to be compatible with XFS. | |
247 | * | |
248 | * ALLOCSP* and FREESP* are not and will never be supported, but are | |
249 | * included here for completeness. | |
250 | */ | |
251 | struct ocfs2_space_resv { | |
252 | __s16 l_type; | |
253 | __s16 l_whence; | |
254 | __s64 l_start; | |
255 | __s64 l_len; /* len == 0 means until end of file */ | |
256 | __s32 l_sysid; | |
257 | __u32 l_pid; | |
258 | __s32 l_pad[4]; /* reserve area */ | |
259 | }; | |
260 | ||
261 | #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv) | |
262 | #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv) | |
263 | #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv) | |
264 | #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv) | |
265 | #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv) | |
266 | #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv) | |
267 | #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv) | |
268 | #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv) | |
269 | ||
7909f2bf TM |
270 | /* Used to pass group descriptor data when online resize is done */ |
271 | struct ocfs2_new_group_input { | |
272 | __u64 group; /* Group descriptor's blkno. */ | |
273 | __u32 clusters; /* Total number of clusters in this group */ | |
274 | __u32 frees; /* Total free clusters in this group */ | |
275 | __u16 chain; /* Chain for this group */ | |
276 | __u16 reserved1; | |
277 | __u32 reserved2; | |
278 | }; | |
279 | ||
d659072f | 280 | #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int) |
7909f2bf TM |
281 | #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input) |
282 | #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input) | |
d659072f | 283 | |
ccd979bd MF |
284 | /* |
285 | * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) | |
286 | */ | |
287 | #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */ | |
288 | ||
289 | /* | |
290 | * superblock s_state flags | |
291 | */ | |
292 | #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */ | |
293 | ||
294 | /* Limit of space in ocfs2_dir_entry */ | |
295 | #define OCFS2_MAX_FILENAME_LEN 255 | |
296 | ||
297 | /* Maximum slots on an ocfs2 file system */ | |
298 | #define OCFS2_MAX_SLOTS 255 | |
299 | ||
300 | /* Slot map indicator for an empty slot */ | |
301 | #define OCFS2_INVALID_SLOT -1 | |
302 | ||
303 | #define OCFS2_VOL_UUID_LEN 16 | |
304 | #define OCFS2_MAX_VOL_LABEL_LEN 64 | |
305 | ||
b61817e1 JB |
306 | /* The alternate, userspace stack fields */ |
307 | #define OCFS2_STACK_LABEL_LEN 4 | |
308 | #define OCFS2_CLUSTER_NAME_LEN 16 | |
309 | ||
ccd979bd MF |
310 | /* Journal limits (in bytes) */ |
311 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) | |
ccd979bd | 312 | |
2fbe8d1e SM |
313 | /* |
314 | * Default local alloc size (in megabytes) | |
315 | * | |
316 | * The value chosen should be such that most allocations, including new | |
317 | * block groups, use local alloc. | |
318 | */ | |
319 | #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8 | |
320 | ||
fdd77704 TY |
321 | /* |
322 | * Inline extended attribute size (in bytes) | |
323 | * The value chosen should be aligned to 16 byte boundaries. | |
324 | */ | |
325 | #define OCFS2_MIN_XATTR_INLINE_SIZE 256 | |
326 | ||
ccd979bd MF |
327 | struct ocfs2_system_inode_info { |
328 | char *si_name; | |
329 | int si_iflags; | |
330 | int si_mode; | |
331 | }; | |
332 | ||
333 | /* System file index */ | |
334 | enum { | |
335 | BAD_BLOCK_SYSTEM_INODE = 0, | |
336 | GLOBAL_INODE_ALLOC_SYSTEM_INODE, | |
337 | SLOT_MAP_SYSTEM_INODE, | |
338 | #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE | |
339 | HEARTBEAT_SYSTEM_INODE, | |
340 | GLOBAL_BITMAP_SYSTEM_INODE, | |
1a224ad1 JK |
341 | USER_QUOTA_SYSTEM_INODE, |
342 | GROUP_QUOTA_SYSTEM_INODE, | |
343 | #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE | |
ccd979bd MF |
344 | ORPHAN_DIR_SYSTEM_INODE, |
345 | EXTENT_ALLOC_SYSTEM_INODE, | |
346 | INODE_ALLOC_SYSTEM_INODE, | |
347 | JOURNAL_SYSTEM_INODE, | |
348 | LOCAL_ALLOC_SYSTEM_INODE, | |
349 | TRUNCATE_LOG_SYSTEM_INODE, | |
1a224ad1 JK |
350 | LOCAL_USER_QUOTA_SYSTEM_INODE, |
351 | LOCAL_GROUP_QUOTA_SYSTEM_INODE, | |
ccd979bd MF |
352 | NUM_SYSTEM_INODES |
353 | }; | |
354 | ||
355 | static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { | |
356 | /* Global system inodes (single copy) */ | |
357 | /* The first two are only used from userspace mfks/tunefs */ | |
358 | [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 }, | |
359 | [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | |
360 | ||
361 | /* These are used by the running filesystem */ | |
362 | [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 }, | |
363 | [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 }, | |
364 | [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 }, | |
1a224ad1 JK |
365 | [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 }, |
366 | [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | |
ccd979bd MF |
367 | |
368 | /* Slot-specific system inodes (one copy per slot) */ | |
369 | [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 }, | |
370 | [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | |
371 | [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | |
372 | [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 }, | |
373 | [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }, | |
1a224ad1 JK |
374 | [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }, |
375 | [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | |
376 | [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | |
ccd979bd MF |
377 | }; |
378 | ||
379 | /* Parameter passed from mount.ocfs2 to module */ | |
380 | #define OCFS2_HB_NONE "heartbeat=none" | |
381 | #define OCFS2_HB_LOCAL "heartbeat=local" | |
382 | ||
383 | /* | |
384 | * OCFS2 directory file types. Only the low 3 bits are used. The | |
385 | * other bits are reserved for now. | |
386 | */ | |
387 | #define OCFS2_FT_UNKNOWN 0 | |
388 | #define OCFS2_FT_REG_FILE 1 | |
389 | #define OCFS2_FT_DIR 2 | |
390 | #define OCFS2_FT_CHRDEV 3 | |
391 | #define OCFS2_FT_BLKDEV 4 | |
392 | #define OCFS2_FT_FIFO 5 | |
393 | #define OCFS2_FT_SOCK 6 | |
394 | #define OCFS2_FT_SYMLINK 7 | |
395 | ||
396 | #define OCFS2_FT_MAX 8 | |
397 | ||
398 | /* | |
399 | * OCFS2_DIR_PAD defines the directory entries boundaries | |
400 | * | |
401 | * NOTE: It must be a multiple of 4 | |
402 | */ | |
403 | #define OCFS2_DIR_PAD 4 | |
404 | #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1) | |
405 | #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name) | |
406 | #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \ | |
407 | OCFS2_DIR_ROUND) & \ | |
408 | ~OCFS2_DIR_ROUND) | |
409 | ||
410 | #define OCFS2_LINK_MAX 32000 | |
411 | ||
412 | #define S_SHIFT 12 | |
413 | static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { | |
414 | [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE, | |
415 | [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR, | |
416 | [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV, | |
417 | [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV, | |
418 | [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO, | |
419 | [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK, | |
420 | [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK, | |
421 | }; | |
422 | ||
423 | ||
424 | /* | |
425 | * Convenience casts | |
426 | */ | |
427 | #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super)) | |
428 | ||
429 | /* | |
430 | * On disk extent record for OCFS2 | |
431 | * It describes a range of clusters on disk. | |
e48edee2 MF |
432 | * |
433 | * Length fields are divided into interior and leaf node versions. | |
434 | * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes. | |
ccd979bd MF |
435 | */ |
436 | struct ocfs2_extent_rec { | |
437 | /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */ | |
e48edee2 MF |
438 | union { |
439 | __le32 e_int_clusters; /* Clusters covered by all children */ | |
440 | struct { | |
441 | __le16 e_leaf_clusters; /* Clusters covered by this | |
442 | extent */ | |
443 | __u8 e_reserved1; | |
444 | __u8 e_flags; /* Extent flags */ | |
445 | }; | |
446 | }; | |
ccd979bd MF |
447 | __le64 e_blkno; /* Physical disk offset, in blocks */ |
448 | /*10*/ | |
449 | }; | |
450 | ||
451 | struct ocfs2_chain_rec { | |
452 | __le32 c_free; /* Number of free bits in this chain. */ | |
453 | __le32 c_total; /* Number of total bits in this chain */ | |
454 | __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */ | |
455 | }; | |
456 | ||
457 | struct ocfs2_truncate_rec { | |
458 | __le32 t_start; /* 1st cluster in this log */ | |
459 | __le32 t_clusters; /* Number of total clusters covered */ | |
460 | }; | |
461 | ||
462 | /* | |
463 | * On disk extent list for OCFS2 (node in the tree). Note that this | |
464 | * is contained inside ocfs2_dinode or ocfs2_extent_block, so the | |
465 | * offsets are relative to ocfs2_dinode.id2.i_list or | |
466 | * ocfs2_extent_block.h_list, respectively. | |
467 | */ | |
468 | struct ocfs2_extent_list { | |
469 | /*00*/ __le16 l_tree_depth; /* Extent tree depth from this | |
470 | point. 0 means data extents | |
471 | hang directly off this | |
dcd0538f MF |
472 | header (a leaf) |
473 | NOTE: The high 8 bits cannot be | |
474 | used - tree_depth is never that big. | |
475 | */ | |
ccd979bd MF |
476 | __le16 l_count; /* Number of extent records */ |
477 | __le16 l_next_free_rec; /* Next unused extent slot */ | |
478 | __le16 l_reserved1; | |
479 | __le64 l_reserved2; /* Pad to | |
480 | sizeof(ocfs2_extent_rec) */ | |
481 | /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */ | |
482 | }; | |
483 | ||
484 | /* | |
485 | * On disk allocation chain list for OCFS2. Note that this is | |
486 | * contained inside ocfs2_dinode, so the offsets are relative to | |
487 | * ocfs2_dinode.id2.i_chain. | |
488 | */ | |
489 | struct ocfs2_chain_list { | |
490 | /*00*/ __le16 cl_cpg; /* Clusters per Block Group */ | |
491 | __le16 cl_bpc; /* Bits per cluster */ | |
492 | __le16 cl_count; /* Total chains in this list */ | |
493 | __le16 cl_next_free_rec; /* Next unused chain slot */ | |
494 | __le64 cl_reserved1; | |
495 | /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */ | |
496 | }; | |
497 | ||
498 | /* | |
499 | * On disk deallocation log for OCFS2. Note that this is | |
500 | * contained inside ocfs2_dinode, so the offsets are relative to | |
501 | * ocfs2_dinode.id2.i_dealloc. | |
502 | */ | |
503 | struct ocfs2_truncate_log { | |
504 | /*00*/ __le16 tl_count; /* Total records in this log */ | |
505 | __le16 tl_used; /* Number of records in use */ | |
506 | __le32 tl_reserved1; | |
507 | /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */ | |
508 | }; | |
509 | ||
510 | /* | |
511 | * On disk extent block (indirect block) for OCFS2 | |
512 | */ | |
513 | struct ocfs2_extent_block | |
514 | { | |
515 | /*00*/ __u8 h_signature[8]; /* Signature for verification */ | |
516 | __le64 h_reserved1; | |
517 | /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this | |
518 | extent_header belongs to */ | |
519 | __le16 h_suballoc_bit; /* Bit offset in suballocator | |
520 | block group */ | |
521 | __le32 h_fs_generation; /* Must match super block */ | |
522 | __le64 h_blkno; /* Offset on disk, in blocks */ | |
523 | /*20*/ __le64 h_reserved3; | |
524 | __le64 h_next_leaf_blk; /* Offset on disk, in blocks, | |
525 | of next leaf header pointing | |
526 | to data */ | |
527 | /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */ | |
528 | /* Actual on-disk size is one block */ | |
529 | }; | |
530 | ||
fb86b1f0 JB |
531 | /* |
532 | * On disk slot map for OCFS2. This defines the contents of the "slot_map" | |
386a2ef8 JB |
533 | * system file. A slot is valid if it contains a node number >= 0. The |
534 | * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty. | |
fb86b1f0 JB |
535 | */ |
536 | struct ocfs2_slot_map { | |
537 | /*00*/ __le16 sm_slots[0]; | |
538 | /* | |
539 | * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255, | |
540 | * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize. | |
541 | */ | |
542 | }; | |
543 | ||
386a2ef8 JB |
544 | struct ocfs2_extended_slot { |
545 | /*00*/ __u8 es_valid; | |
546 | __u8 es_reserved1[3]; | |
547 | __le32 es_node_num; | |
548 | /*10*/ | |
549 | }; | |
550 | ||
551 | /* | |
552 | * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP | |
553 | * is set. It separates out the valid marker from the node number, and | |
554 | * has room to grow. Unlike the old slot map, this format is defined by | |
555 | * i_size. | |
556 | */ | |
557 | struct ocfs2_slot_map_extended { | |
558 | /*00*/ struct ocfs2_extended_slot se_slots[0]; | |
559 | /* | |
560 | * Actual size is i_size of the slot_map system file. It should | |
561 | * match s_max_slots * sizeof(struct ocfs2_extended_slot) | |
562 | */ | |
563 | }; | |
564 | ||
b61817e1 JB |
565 | struct ocfs2_cluster_info { |
566 | /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN]; | |
567 | __le32 ci_reserved; | |
568 | /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN]; | |
569 | /*18*/ | |
570 | }; | |
571 | ||
ccd979bd MF |
572 | /* |
573 | * On disk superblock for OCFS2 | |
574 | * Note that it is contained inside an ocfs2_dinode, so all offsets | |
575 | * are relative to the start of ocfs2_dinode.id2. | |
576 | */ | |
577 | struct ocfs2_super_block { | |
578 | /*00*/ __le16 s_major_rev_level; | |
579 | __le16 s_minor_rev_level; | |
580 | __le16 s_mnt_count; | |
581 | __le16 s_max_mnt_count; | |
582 | __le16 s_state; /* File system state */ | |
583 | __le16 s_errors; /* Behaviour when detecting errors */ | |
584 | __le32 s_checkinterval; /* Max time between checks */ | |
585 | /*10*/ __le64 s_lastcheck; /* Time of last check */ | |
586 | __le32 s_creator_os; /* OS */ | |
587 | __le32 s_feature_compat; /* Compatible feature set */ | |
588 | /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */ | |
589 | __le32 s_feature_ro_compat; /* Readonly-compatible feature set */ | |
590 | __le64 s_root_blkno; /* Offset, in blocks, of root directory | |
591 | dinode */ | |
592 | /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system | |
593 | directory dinode */ | |
594 | __le32 s_blocksize_bits; /* Blocksize for this fs */ | |
595 | __le32 s_clustersize_bits; /* Clustersize for this fs */ | |
596 | /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts | |
597 | before tunefs required */ | |
92e91ce2 | 598 | __le16 s_tunefs_flag; |
cf1d6c76 | 599 | __le32 s_uuid_hash; /* hash value of uuid */ |
ccd979bd MF |
600 | __le64 s_first_cluster_group; /* Block offset of 1st cluster |
601 | * group header */ | |
602 | /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */ | |
603 | /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */ | |
b61817e1 JB |
604 | /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace |
605 | stack. Only valid | |
606 | with INCOMPAT flag. */ | |
8154da3d TY |
607 | /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size |
608 | for this fs*/ | |
609 | __le16 s_reserved0; | |
610 | __le32 s_reserved1; | |
611 | /*C0*/ __le64 s_reserved2[16]; /* Fill out superblock */ | |
b61817e1 JB |
612 | /*140*/ |
613 | ||
614 | /* | |
615 | * NOTE: As stated above, all offsets are relative to | |
616 | * ocfs2_dinode.id2, which is at 0xC0 in the inode. | |
617 | * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within | |
618 | * our smallest blocksize, which is 512 bytes. To ensure this, | |
619 | * we reserve the space in s_reserved2. Anything past s_reserved2 | |
620 | * will not be available on the smallest blocksize. | |
621 | */ | |
ccd979bd MF |
622 | }; |
623 | ||
624 | /* | |
625 | * Local allocation bitmap for OCFS2 slots | |
626 | * Note that it exists inside an ocfs2_dinode, so all offsets are | |
627 | * relative to the start of ocfs2_dinode.id2. | |
628 | */ | |
629 | struct ocfs2_local_alloc | |
630 | { | |
631 | /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */ | |
632 | __le16 la_size; /* Size of included bitmap, in bytes */ | |
633 | __le16 la_reserved1; | |
634 | __le64 la_reserved2; | |
635 | /*10*/ __u8 la_bitmap[0]; | |
636 | }; | |
637 | ||
15b1e36b MF |
638 | /* |
639 | * Data-in-inode header. This is only used if i_dyn_features has | |
640 | * OCFS2_INLINE_DATA_FL set. | |
641 | */ | |
642 | struct ocfs2_inline_data | |
643 | { | |
644 | /*00*/ __le16 id_count; /* Number of bytes that can be used | |
645 | * for data, starting at id_data */ | |
646 | __le16 id_reserved0; | |
647 | __le32 id_reserved1; | |
648 | __u8 id_data[0]; /* Start of user data */ | |
649 | }; | |
650 | ||
ccd979bd MF |
651 | /* |
652 | * On disk inode for OCFS2 | |
653 | */ | |
654 | struct ocfs2_dinode { | |
655 | /*00*/ __u8 i_signature[8]; /* Signature for validation */ | |
656 | __le32 i_generation; /* Generation number */ | |
657 | __le16 i_suballoc_slot; /* Slot suballocator this inode | |
658 | belongs to */ | |
659 | __le16 i_suballoc_bit; /* Bit offset in suballocator | |
660 | block group */ | |
fdd77704 TY |
661 | /*10*/ __le16 i_reserved0; |
662 | __le16 i_xattr_inline_size; | |
ccd979bd MF |
663 | __le32 i_clusters; /* Cluster count */ |
664 | __le32 i_uid; /* Owner UID */ | |
665 | __le32 i_gid; /* Owning GID */ | |
666 | /*20*/ __le64 i_size; /* Size in bytes */ | |
667 | __le16 i_mode; /* File mode */ | |
668 | __le16 i_links_count; /* Links count */ | |
669 | __le32 i_flags; /* File flags */ | |
670 | /*30*/ __le64 i_atime; /* Access time */ | |
671 | __le64 i_ctime; /* Creation time */ | |
672 | /*40*/ __le64 i_mtime; /* Modification time */ | |
673 | __le64 i_dtime; /* Deletion time */ | |
674 | /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */ | |
675 | __le64 i_last_eb_blk; /* Pointer to last extent | |
676 | block */ | |
677 | /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */ | |
678 | __le32 i_atime_nsec; | |
679 | __le32 i_ctime_nsec; | |
680 | __le32 i_mtime_nsec; | |
fdd77704 | 681 | /*70*/ __le32 i_attr; |
50008630 TY |
682 | __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL |
683 | was set in i_flags */ | |
15b1e36b | 684 | __le16 i_dyn_features; |
fdd77704 TY |
685 | __le64 i_xattr_loc; |
686 | /*80*/ __le64 i_reserved2[7]; | |
ccd979bd MF |
687 | /*B8*/ union { |
688 | __le64 i_pad1; /* Generic way to refer to this | |
689 | 64bit union */ | |
690 | struct { | |
691 | __le64 i_rdev; /* Device number */ | |
692 | } dev1; | |
693 | struct { /* Info for bitmap system | |
694 | inodes */ | |
695 | __le32 i_used; /* Bits (ie, clusters) used */ | |
696 | __le32 i_total; /* Total bits (clusters) | |
697 | available */ | |
698 | } bitmap1; | |
699 | struct { /* Info for journal system | |
700 | inodes */ | |
701 | __le32 ij_flags; /* Mounted, version, etc. */ | |
c69991aa SM |
702 | __le32 ij_recovery_generation; /* Incremented when the |
703 | journal is recovered | |
704 | after an unclean | |
705 | shutdown */ | |
ccd979bd MF |
706 | } journal1; |
707 | } id1; /* Inode type dependant 1 */ | |
708 | /*C0*/ union { | |
709 | struct ocfs2_super_block i_super; | |
710 | struct ocfs2_local_alloc i_lab; | |
711 | struct ocfs2_chain_list i_chain; | |
712 | struct ocfs2_extent_list i_list; | |
713 | struct ocfs2_truncate_log i_dealloc; | |
15b1e36b | 714 | struct ocfs2_inline_data i_data; |
ccd979bd MF |
715 | __u8 i_symlink[0]; |
716 | } id2; | |
717 | /* Actual on-disk size is one block */ | |
718 | }; | |
719 | ||
720 | /* | |
721 | * On-disk directory entry structure for OCFS2 | |
722 | * | |
723 | * Packed as this structure could be accessed unaligned on 64-bit platforms | |
724 | */ | |
725 | struct ocfs2_dir_entry { | |
726 | /*00*/ __le64 inode; /* Inode number */ | |
727 | __le16 rec_len; /* Directory entry length */ | |
728 | __u8 name_len; /* Name length */ | |
729 | __u8 file_type; | |
730 | /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */ | |
731 | /* Actual on-disk length specified by rec_len */ | |
732 | } __attribute__ ((packed)); | |
733 | ||
734 | /* | |
735 | * On disk allocator group structure for OCFS2 | |
736 | */ | |
737 | struct ocfs2_group_desc | |
738 | { | |
739 | /*00*/ __u8 bg_signature[8]; /* Signature for validation */ | |
740 | __le16 bg_size; /* Size of included bitmap in | |
741 | bytes. */ | |
742 | __le16 bg_bits; /* Bits represented by this | |
743 | group. */ | |
744 | __le16 bg_free_bits_count; /* Free bits count */ | |
745 | __le16 bg_chain; /* What chain I am in. */ | |
746 | /*10*/ __le32 bg_generation; | |
747 | __le32 bg_reserved1; | |
748 | __le64 bg_next_group; /* Next group in my list, in | |
749 | blocks */ | |
750 | /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in | |
751 | blocks */ | |
752 | __le64 bg_blkno; /* Offset on disk, in blocks */ | |
753 | /*30*/ __le64 bg_reserved2[2]; | |
754 | /*40*/ __u8 bg_bitmap[0]; | |
755 | }; | |
756 | ||
5a7bc8eb TM |
757 | /* |
758 | * On disk extended attribute structure for OCFS2. | |
759 | */ | |
760 | ||
761 | /* | |
762 | * ocfs2_xattr_entry indicates one extend attribute. | |
763 | * | |
764 | * Note that it can be stored in inode, one block or one xattr bucket. | |
765 | */ | |
766 | struct ocfs2_xattr_entry { | |
767 | __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */ | |
8573f79d | 768 | __le16 xe_name_offset; /* byte offset from the 1st entry in the |
5a7bc8eb TM |
769 | local xattr storage(inode, xattr block or |
770 | xattr bucket). */ | |
771 | __u8 xe_name_len; /* xattr name len, does't include prefix. */ | |
8573f79d TM |
772 | __u8 xe_type; /* the low 7 bits indicate the name prefix |
773 | * type and the highest bit indicates whether | |
5a7bc8eb TM |
774 | * the EA is stored in the local storage. */ |
775 | __le64 xe_value_size; /* real xattr value length. */ | |
776 | }; | |
777 | ||
778 | /* | |
779 | * On disk structure for xattr header. | |
780 | * | |
781 | * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in | |
782 | * the local xattr storage. | |
783 | */ | |
784 | struct ocfs2_xattr_header { | |
785 | __le16 xh_count; /* contains the count of how | |
786 | many records are in the | |
787 | local xattr storage. */ | |
0c044f0b TM |
788 | __le16 xh_free_start; /* current offset for storing |
789 | xattr. */ | |
790 | __le16 xh_name_value_len; /* total length of name/value | |
791 | length in this bucket. */ | |
8573f79d TM |
792 | __le16 xh_num_buckets; /* Number of xattr buckets |
793 | in this extent record, | |
794 | only valid in the first | |
795 | bucket. */ | |
5a7bc8eb TM |
796 | __le64 xh_csum; |
797 | struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */ | |
798 | }; | |
799 | ||
800 | /* | |
801 | * On disk structure for xattr value root. | |
802 | * | |
8573f79d TM |
803 | * When an xattr's value is large enough, it is stored in an external |
804 | * b-tree like file data. The xattr value root points to this structure. | |
5a7bc8eb TM |
805 | */ |
806 | struct ocfs2_xattr_value_root { | |
807 | /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */ | |
808 | __le32 xr_reserved0; | |
809 | __le64 xr_last_eb_blk; /* Pointer to last extent block */ | |
810 | /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */ | |
811 | }; | |
812 | ||
813 | /* | |
814 | * On disk structure for xattr tree root. | |
815 | * | |
816 | * It is used when there are too many extended attributes for one file. These | |
817 | * attributes will be organized and stored in an indexed-btree. | |
818 | */ | |
819 | struct ocfs2_xattr_tree_root { | |
820 | /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */ | |
821 | __le32 xt_reserved0; | |
822 | __le64 xt_last_eb_blk; /* Pointer to last extent block */ | |
823 | /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */ | |
824 | }; | |
825 | ||
cf1d6c76 TY |
826 | #define OCFS2_XATTR_INDEXED 0x1 |
827 | #define OCFS2_HASH_SHIFT 5 | |
828 | #define OCFS2_XATTR_ROUND 3 | |
829 | #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \ | |
830 | ~(OCFS2_XATTR_ROUND)) | |
5a7bc8eb | 831 | |
0c044f0b TM |
832 | #define OCFS2_XATTR_BUCKET_SIZE 4096 |
833 | #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \ | |
834 | / OCFS2_MIN_BLOCKSIZE) | |
835 | ||
5a7bc8eb TM |
836 | /* |
837 | * On disk structure for xattr block. | |
838 | */ | |
839 | struct ocfs2_xattr_block { | |
840 | /*00*/ __u8 xb_signature[8]; /* Signature for verification */ | |
841 | __le16 xb_suballoc_slot; /* Slot suballocator this | |
842 | block belongs to. */ | |
843 | __le16 xb_suballoc_bit; /* Bit offset in suballocator | |
844 | block group */ | |
845 | __le32 xb_fs_generation; /* Must match super block */ | |
846 | /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */ | |
847 | __le64 xb_csum; | |
848 | /*20*/ __le16 xb_flags; /* Indicates whether this block contains | |
849 | real xattr or a xattr tree. */ | |
850 | __le16 xb_reserved0; | |
851 | __le32 xb_reserved1; | |
852 | __le64 xb_reserved2; | |
853 | /*30*/ union { | |
854 | struct ocfs2_xattr_header xb_header; /* xattr header if this | |
855 | block contains xattr */ | |
856 | struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this | |
857 | block cotains xattr | |
858 | tree. */ | |
859 | } xb_attrs; | |
860 | }; | |
861 | ||
862 | #define OCFS2_XATTR_ENTRY_LOCAL 0x80 | |
863 | #define OCFS2_XATTR_TYPE_MASK 0x7F | |
864 | static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe, | |
865 | int local) | |
866 | { | |
867 | if (local) | |
868 | xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL; | |
869 | else | |
870 | xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL; | |
871 | } | |
872 | ||
873 | static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe) | |
874 | { | |
875 | return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL; | |
876 | } | |
877 | ||
878 | static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type) | |
879 | { | |
880 | xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK; | |
881 | } | |
882 | ||
883 | static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe) | |
884 | { | |
885 | return xe->xe_type & OCFS2_XATTR_TYPE_MASK; | |
886 | } | |
887 | ||
9e33d69f JK |
888 | /* |
889 | * On disk structures for global quota file | |
890 | */ | |
891 | ||
892 | /* Magic numbers and known versions for global quota files */ | |
893 | #define OCFS2_GLOBAL_QMAGICS {\ | |
894 | 0x0cf52470, /* USRQUOTA */ \ | |
895 | 0x0cf52471 /* GRPQUOTA */ \ | |
896 | } | |
897 | ||
898 | #define OCFS2_GLOBAL_QVERSIONS {\ | |
899 | 0, \ | |
900 | 0, \ | |
901 | } | |
902 | ||
903 | ||
904 | /* Each block of each quota file has a certain fixed number of bytes reserved | |
905 | * for OCFS2 internal use at its end. OCFS2 can use it for things like | |
906 | * checksums, etc. */ | |
907 | #define OCFS2_QBLK_RESERVED_SPACE 8 | |
908 | ||
909 | /* Generic header of all quota files */ | |
910 | struct ocfs2_disk_dqheader { | |
911 | __le32 dqh_magic; /* Magic number identifying file */ | |
912 | __le32 dqh_version; /* Quota format version */ | |
913 | }; | |
914 | ||
915 | #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader)) | |
916 | ||
917 | /* Information header of global quota file (immediately follows the generic | |
918 | * header) */ | |
919 | struct ocfs2_global_disk_dqinfo { | |
920 | /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */ | |
921 | __le32 dqi_igrace; /* Grace time for inode softlimit excess */ | |
922 | __le32 dqi_syncms; /* Time after which we sync local changes to | |
923 | * global quota file */ | |
924 | __le32 dqi_blocks; /* Number of blocks in quota file */ | |
925 | /*10*/ __le32 dqi_free_blk; /* First free block in quota file */ | |
926 | __le32 dqi_free_entry; /* First block with free dquot entry in quota | |
927 | * file */ | |
928 | }; | |
929 | ||
930 | /* Structure with global user / group information. We reserve some space | |
931 | * for future use. */ | |
932 | struct ocfs2_global_disk_dqblk { | |
933 | /*00*/ __le32 dqb_id; /* ID the structure belongs to */ | |
934 | __le32 dqb_use_count; /* Number of nodes having reference to this structure */ | |
935 | __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */ | |
936 | /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */ | |
937 | __le64 dqb_curinodes; /* current # allocated inodes */ | |
938 | /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */ | |
939 | __le64 dqb_bsoftlimit; /* preferred limit on disk space */ | |
940 | /*30*/ __le64 dqb_curspace; /* current space occupied */ | |
941 | __le64 dqb_btime; /* time limit for excessive disk use */ | |
942 | /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */ | |
943 | __le64 dqb_pad1; | |
944 | /*50*/ __le64 dqb_pad2; | |
945 | }; | |
946 | ||
947 | /* | |
948 | * On-disk structures for local quota file | |
949 | */ | |
950 | ||
951 | /* Magic numbers and known versions for local quota files */ | |
952 | #define OCFS2_LOCAL_QMAGICS {\ | |
953 | 0x0cf524c0, /* USRQUOTA */ \ | |
954 | 0x0cf524c1 /* GRPQUOTA */ \ | |
955 | } | |
956 | ||
957 | #define OCFS2_LOCAL_QVERSIONS {\ | |
958 | 0, \ | |
959 | 0, \ | |
960 | } | |
961 | ||
962 | /* Quota flags in dqinfo header */ | |
963 | #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\ | |
964 | * quota has been cleanly turned off) */ | |
965 | ||
966 | #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader)) | |
967 | ||
968 | /* Information header of local quota file (immediately follows the generic | |
969 | * header) */ | |
970 | struct ocfs2_local_disk_dqinfo { | |
971 | __le32 dqi_flags; /* Flags for quota file */ | |
972 | __le32 dqi_chunks; /* Number of chunks of quota structures | |
973 | * with a bitmap */ | |
974 | __le32 dqi_blocks; /* Number of blocks allocated for quota file */ | |
975 | }; | |
976 | ||
977 | /* Header of one chunk of a quota file */ | |
978 | struct ocfs2_local_disk_chunk { | |
979 | __le32 dqc_free; /* Number of free entries in the bitmap */ | |
980 | u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding | |
981 | * chunk of quota file */ | |
982 | }; | |
983 | ||
984 | /* One entry in local quota file */ | |
985 | struct ocfs2_local_disk_dqblk { | |
986 | /*00*/ __le64 dqb_id; /* id this quota applies to */ | |
987 | __le64 dqb_spacemod; /* Change in the amount of used space */ | |
988 | /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */ | |
989 | }; | |
990 | ||
ccd979bd MF |
991 | #ifdef __KERNEL__ |
992 | static inline int ocfs2_fast_symlink_chars(struct super_block *sb) | |
993 | { | |
994 | return sb->s_blocksize - | |
995 | offsetof(struct ocfs2_dinode, id2.i_symlink); | |
996 | } | |
997 | ||
15b1e36b MF |
998 | static inline int ocfs2_max_inline_data(struct super_block *sb) |
999 | { | |
1000 | return sb->s_blocksize - | |
1001 | offsetof(struct ocfs2_dinode, id2.i_data.id_data); | |
1002 | } | |
1003 | ||
fdd77704 TY |
1004 | static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb, |
1005 | struct ocfs2_dinode *di) | |
1006 | { | |
1007 | unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size); | |
1008 | ||
1009 | if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL) | |
1010 | return sb->s_blocksize - | |
1011 | offsetof(struct ocfs2_dinode, id2.i_data.id_data) - | |
1012 | xattrsize; | |
1013 | else | |
1014 | return sb->s_blocksize - | |
1015 | offsetof(struct ocfs2_dinode, id2.i_data.id_data); | |
1016 | } | |
1017 | ||
ccd979bd MF |
1018 | static inline int ocfs2_extent_recs_per_inode(struct super_block *sb) |
1019 | { | |
1020 | int size; | |
1021 | ||
1022 | size = sb->s_blocksize - | |
1023 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | |
1024 | ||
1025 | return size / sizeof(struct ocfs2_extent_rec); | |
1026 | } | |
1027 | ||
fdd77704 TY |
1028 | static inline int ocfs2_extent_recs_per_inode_with_xattr( |
1029 | struct super_block *sb, | |
1030 | struct ocfs2_dinode *di) | |
1031 | { | |
1032 | int size; | |
1033 | unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size); | |
1034 | ||
1035 | if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL) | |
1036 | size = sb->s_blocksize - | |
1037 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs) - | |
1038 | xattrsize; | |
1039 | else | |
1040 | size = sb->s_blocksize - | |
1041 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | |
1042 | ||
1043 | return size / sizeof(struct ocfs2_extent_rec); | |
1044 | } | |
1045 | ||
ccd979bd MF |
1046 | static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) |
1047 | { | |
1048 | int size; | |
1049 | ||
1050 | size = sb->s_blocksize - | |
1051 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); | |
1052 | ||
1053 | return size / sizeof(struct ocfs2_chain_rec); | |
1054 | } | |
1055 | ||
1056 | static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) | |
1057 | { | |
1058 | int size; | |
1059 | ||
1060 | size = sb->s_blocksize - | |
1061 | offsetof(struct ocfs2_extent_block, h_list.l_recs); | |
1062 | ||
1063 | return size / sizeof(struct ocfs2_extent_rec); | |
1064 | } | |
1065 | ||
1066 | static inline u16 ocfs2_local_alloc_size(struct super_block *sb) | |
1067 | { | |
1068 | u16 size; | |
1069 | ||
1070 | size = sb->s_blocksize - | |
1071 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | |
1072 | ||
1073 | return size; | |
1074 | } | |
1075 | ||
1076 | static inline int ocfs2_group_bitmap_size(struct super_block *sb) | |
1077 | { | |
1078 | int size; | |
1079 | ||
1080 | size = sb->s_blocksize - | |
1081 | offsetof(struct ocfs2_group_desc, bg_bitmap); | |
1082 | ||
1083 | return size; | |
1084 | } | |
1085 | ||
1086 | static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb) | |
1087 | { | |
1088 | int size; | |
1089 | ||
1090 | size = sb->s_blocksize - | |
1091 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); | |
1092 | ||
1093 | return size / sizeof(struct ocfs2_truncate_rec); | |
1094 | } | |
50af94b1 MF |
1095 | |
1096 | static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index) | |
1097 | { | |
1098 | u64 offset = OCFS2_BACKUP_SB_START; | |
1099 | ||
1100 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | |
1101 | offset <<= (2 * index); | |
a8a75a20 | 1102 | offset >>= sb->s_blocksize_bits; |
50af94b1 MF |
1103 | return offset; |
1104 | } | |
1105 | ||
1106 | return 0; | |
1107 | ||
1108 | } | |
0c044f0b TM |
1109 | |
1110 | static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb) | |
1111 | { | |
1112 | int size; | |
1113 | ||
1114 | size = sb->s_blocksize - | |
1115 | offsetof(struct ocfs2_xattr_block, | |
1116 | xb_attrs.xb_root.xt_list.l_recs); | |
1117 | ||
1118 | return size / sizeof(struct ocfs2_extent_rec); | |
1119 | } | |
ccd979bd MF |
1120 | #else |
1121 | static inline int ocfs2_fast_symlink_chars(int blocksize) | |
1122 | { | |
1123 | return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink); | |
1124 | } | |
1125 | ||
15b1e36b MF |
1126 | static inline int ocfs2_max_inline_data(int blocksize) |
1127 | { | |
1128 | return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data); | |
1129 | } | |
1130 | ||
ccd979bd MF |
1131 | static inline int ocfs2_extent_recs_per_inode(int blocksize) |
1132 | { | |
1133 | int size; | |
1134 | ||
1135 | size = blocksize - | |
1136 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | |
1137 | ||
1138 | return size / sizeof(struct ocfs2_extent_rec); | |
1139 | } | |
1140 | ||
1141 | static inline int ocfs2_chain_recs_per_inode(int blocksize) | |
1142 | { | |
1143 | int size; | |
1144 | ||
1145 | size = blocksize - | |
1146 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); | |
1147 | ||
1148 | return size / sizeof(struct ocfs2_chain_rec); | |
1149 | } | |
1150 | ||
1151 | static inline int ocfs2_extent_recs_per_eb(int blocksize) | |
1152 | { | |
1153 | int size; | |
1154 | ||
1155 | size = blocksize - | |
1156 | offsetof(struct ocfs2_extent_block, h_list.l_recs); | |
1157 | ||
1158 | return size / sizeof(struct ocfs2_extent_rec); | |
1159 | } | |
1160 | ||
1161 | static inline int ocfs2_local_alloc_size(int blocksize) | |
1162 | { | |
1163 | int size; | |
1164 | ||
1165 | size = blocksize - | |
1166 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | |
1167 | ||
1168 | return size; | |
1169 | } | |
1170 | ||
1171 | static inline int ocfs2_group_bitmap_size(int blocksize) | |
1172 | { | |
1173 | int size; | |
1174 | ||
1175 | size = blocksize - | |
1176 | offsetof(struct ocfs2_group_desc, bg_bitmap); | |
1177 | ||
1178 | return size; | |
1179 | } | |
1180 | ||
1181 | static inline int ocfs2_truncate_recs_per_inode(int blocksize) | |
1182 | { | |
1183 | int size; | |
1184 | ||
1185 | size = blocksize - | |
1186 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); | |
1187 | ||
1188 | return size / sizeof(struct ocfs2_truncate_rec); | |
1189 | } | |
50af94b1 MF |
1190 | |
1191 | static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index) | |
1192 | { | |
1193 | uint64_t offset = OCFS2_BACKUP_SB_START; | |
1194 | ||
1195 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | |
1196 | offset <<= (2 * index); | |
1197 | offset /= blocksize; | |
1198 | return offset; | |
1199 | } | |
1200 | ||
1201 | return 0; | |
1202 | } | |
0c044f0b TM |
1203 | |
1204 | static inline int ocfs2_xattr_recs_per_xb(int blocksize) | |
1205 | { | |
1206 | int size; | |
1207 | ||
1208 | size = blocksize - | |
1209 | offsetof(struct ocfs2_xattr_block, | |
1210 | xb_attrs.xb_root.xt_list.l_recs); | |
1211 | ||
1212 | return size / sizeof(struct ocfs2_extent_rec); | |
1213 | } | |
ccd979bd MF |
1214 | #endif /* __KERNEL__ */ |
1215 | ||
1216 | ||
1217 | static inline int ocfs2_system_inode_is_global(int type) | |
1218 | { | |
1219 | return ((type >= 0) && | |
1220 | (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)); | |
1221 | } | |
1222 | ||
1223 | static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, | |
1224 | int type, int slot) | |
1225 | { | |
1226 | int chars; | |
1227 | ||
1228 | /* | |
1229 | * Global system inodes can only have one copy. Everything | |
1230 | * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode | |
1231 | * list has a copy per slot. | |
1232 | */ | |
1233 | if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) | |
fe9f3877 | 1234 | chars = snprintf(buf, len, "%s", |
ccd979bd MF |
1235 | ocfs2_system_inodes[type].si_name); |
1236 | else | |
1237 | chars = snprintf(buf, len, | |
1238 | ocfs2_system_inodes[type].si_name, | |
1239 | slot); | |
1240 | ||
1241 | return chars; | |
1242 | } | |
1243 | ||
1244 | static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, | |
1245 | umode_t mode) | |
1246 | { | |
1247 | de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; | |
1248 | } | |
1249 | ||
1250 | #endif /* _OCFS2_FS_H */ | |
1251 |