HID: usbhid: fix out-of-bounds bug
[linux/fpc-iii.git] / fs / ocfs2 / ocfs2_fs.h
blob938387a10d5d7c2caa65ee5faeb1649d5fbc578d
1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
4 * ocfs2_fs.h
6 * On-disk structures for OCFS2.
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
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.
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.
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.
25 #ifndef _OCFS2_FS_H
26 #define _OCFS2_FS_H
28 /* Version */
29 #define OCFS2_MAJOR_REV_LEVEL 0
30 #define OCFS2_MINOR_REV_LEVEL 90
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.
38 * All other structures are found from the superblock information.
40 * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a
41 * blocksize of 2K, it is 4096 bytes into disk.
43 #define OCFS2_SUPER_BLOCK_BLKNO 2
46 * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could
47 * grow if needed.
49 #define OCFS2_MIN_CLUSTERSIZE 4096
50 #define OCFS2_MAX_CLUSTERSIZE 1048576
53 * Blocks cannot be bigger than clusters, so the maximum blocksize is the
54 * minimum cluster size.
56 #define OCFS2_MIN_BLOCKSIZE 512
57 #define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE
59 /* Filesystem magic number */
60 #define OCFS2_SUPER_MAGIC 0x7461636f
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"
67 #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
68 #define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
69 #define OCFS2_DX_ROOT_SIGNATURE "DXDIR01"
70 #define OCFS2_DX_LEAF_SIGNATURE "DXLEAF1"
71 #define OCFS2_REFCOUNT_BLOCK_SIGNATURE "REFCNT1"
73 /* Compatibility flags */
74 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
75 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
76 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
77 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
78 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
79 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
80 #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
81 OCFS2_SB(sb)->s_feature_compat |= (mask)
82 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
83 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
84 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
85 OCFS2_SB(sb)->s_feature_incompat |= (mask)
86 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
87 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
88 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
89 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
90 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
91 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
93 #define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \
94 | OCFS2_FEATURE_COMPAT_JBD2_SB)
95 #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
96 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
97 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
98 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
99 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
100 | OCFS2_FEATURE_INCOMPAT_XATTR \
101 | OCFS2_FEATURE_INCOMPAT_META_ECC \
102 | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
103 | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
104 | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \
105 | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)
106 #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
107 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
108 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
111 * Heartbeat-only devices are missing journals and other files. The
112 * filesystem driver can't load them, but the library can. Never put
113 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
115 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
118 * tunefs sets this incompat flag before starting the resize and clears it
119 * at the end. This flag protects users from inadvertently mounting the fs
120 * after an aborted run without fsck-ing.
122 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
124 /* Used to denote a non-clustered volume */
125 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
127 /* Support for sparse allocation in b-trees */
128 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
131 * Tunefs sets this incompat flag before starting an operation which
132 * would require cleanup on abort. This is done to protect users from
133 * inadvertently mounting the fs after an aborted run without
134 * fsck-ing.
136 * s_tunefs_flags on the super block describes precisely which
137 * operations were in progress.
139 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
141 /* Support for data packed into inode blocks */
142 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
145 * Support for alternate, userspace cluster stacks. If set, the superblock
146 * field s_cluster_info contains a tag for the alternate stack in use as
147 * well as the name of the cluster being joined.
148 * mount.ocfs2 must pass in a matching stack name.
150 * If not set, the classic stack will be used. This is compatbile with
151 * all older versions.
153 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
155 /* Support for the extended slot map */
156 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
158 /* Support for extended attributes */
159 #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
161 /* Support for indexed directores */
162 #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
164 /* Metadata checksum and error correction */
165 #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
167 /* Refcount tree support */
168 #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
170 /* Discontigous block groups */
171 #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
174 * Incompat bit to indicate useable clusterinfo with stackflags for all
175 * cluster stacks (userspace adnd o2cb). If this bit is set,
176 * INCOMPAT_USERSPACE_STACK becomes superfluous and thus should not be set.
178 #define OCFS2_FEATURE_INCOMPAT_CLUSTERINFO 0x4000
181 * backup superblock flag is used to indicate that this volume
182 * has backup superblocks.
184 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
187 * The filesystem will correctly handle journal feature bits.
189 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
192 * Unwritten extents support.
194 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
197 * Maintain quota information for this filesystem
199 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
200 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
202 /* The byte offset of the first backup block will be 1G.
203 * The following will be 4G, 16G, 64G, 256G and 1T.
205 #define OCFS2_BACKUP_SB_START 1 << 30
207 /* the max backup superblock nums */
208 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
211 * Flags on ocfs2_super_block.s_tunefs_flags
213 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
216 * Flags on ocfs2_dinode.i_flags
218 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
219 #define OCFS2_UNUSED2_FL (0x00000002)
220 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
221 #define OCFS2_UNUSED3_FL (0x00000008)
222 /* System inode flags */
223 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
224 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
225 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
226 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
227 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
228 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
229 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
230 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
231 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
234 * Flags on ocfs2_dinode.i_dyn_features
236 * These can change much more often than i_flags. When adding flags,
237 * keep in mind that i_dyn_features is only 16 bits wide.
239 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
240 #define OCFS2_HAS_XATTR_FL (0x0002)
241 #define OCFS2_INLINE_XATTR_FL (0x0004)
242 #define OCFS2_INDEXED_DIR_FL (0x0008)
243 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
245 /* Inode attributes, keep in sync with EXT2 */
246 #define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
247 #define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
248 #define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
249 #define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
250 #define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
251 #define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
252 #define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
253 #define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
254 /* Reserved for compression usage... */
255 #define OCFS2_DIRTY_FL FS_DIRTY_FL
256 #define OCFS2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */
257 #define OCFS2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */
258 #define OCFS2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */
259 /* End compression flags --- maybe not all used */
260 #define OCFS2_BTREE_FL FS_BTREE_FL /* btree format dir */
261 #define OCFS2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */
262 #define OCFS2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */
263 #define OCFS2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */
264 #define OCFS2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
265 #define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
266 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
267 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
269 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
270 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
273 * Extent record flags (e_node.leaf.flags)
275 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
276 * unwritten */
277 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
278 * counted in an associated
279 * refcount tree */
282 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
284 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
287 * superblock s_state flags
289 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
291 /* Limit of space in ocfs2_dir_entry */
292 #define OCFS2_MAX_FILENAME_LEN 255
294 /* Maximum slots on an ocfs2 file system */
295 #define OCFS2_MAX_SLOTS 255
297 /* Slot map indicator for an empty slot */
298 #define OCFS2_INVALID_SLOT -1
300 #define OCFS2_VOL_UUID_LEN 16
301 #define OCFS2_MAX_VOL_LABEL_LEN 64
303 /* The cluster stack fields */
304 #define OCFS2_STACK_LABEL_LEN 4
305 #define OCFS2_CLUSTER_NAME_LEN 16
307 /* Classic (historically speaking) cluster stack */
308 #define OCFS2_CLASSIC_CLUSTER_STACK "o2cb"
310 /* Journal limits (in bytes) */
311 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
314 * Inline extended attribute size (in bytes)
315 * The value chosen should be aligned to 16 byte boundaries.
317 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
320 * Cluster info flags (ocfs2_cluster_info.ci_stackflags)
322 #define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT (0x01)
324 struct ocfs2_system_inode_info {
325 char *si_name;
326 int si_iflags;
327 int si_mode;
330 /* System file index */
331 enum {
332 BAD_BLOCK_SYSTEM_INODE = 0,
333 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
334 SLOT_MAP_SYSTEM_INODE,
335 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
336 HEARTBEAT_SYSTEM_INODE,
337 GLOBAL_BITMAP_SYSTEM_INODE,
338 USER_QUOTA_SYSTEM_INODE,
339 GROUP_QUOTA_SYSTEM_INODE,
340 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
341 #define OCFS2_FIRST_LOCAL_SYSTEM_INODE ORPHAN_DIR_SYSTEM_INODE
342 ORPHAN_DIR_SYSTEM_INODE,
343 EXTENT_ALLOC_SYSTEM_INODE,
344 INODE_ALLOC_SYSTEM_INODE,
345 JOURNAL_SYSTEM_INODE,
346 LOCAL_ALLOC_SYSTEM_INODE,
347 TRUNCATE_LOG_SYSTEM_INODE,
348 LOCAL_USER_QUOTA_SYSTEM_INODE,
349 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
350 #define OCFS2_LAST_LOCAL_SYSTEM_INODE LOCAL_GROUP_QUOTA_SYSTEM_INODE
351 NUM_SYSTEM_INODES
353 #define NUM_GLOBAL_SYSTEM_INODES OCFS2_FIRST_LOCAL_SYSTEM_INODE
354 #define NUM_LOCAL_SYSTEM_INODES \
355 (NUM_SYSTEM_INODES - OCFS2_FIRST_LOCAL_SYSTEM_INODE)
357 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
358 /* Global system inodes (single copy) */
359 /* The first two are only used from userspace mfks/tunefs */
360 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
361 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
363 /* These are used by the running filesystem */
364 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
365 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
366 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
367 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
368 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
370 /* Slot-specific system inodes (one copy per slot) */
371 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
372 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
373 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
374 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
375 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
376 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
377 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
378 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
381 /* Parameter passed from mount.ocfs2 to module */
382 #define OCFS2_HB_NONE "heartbeat=none"
383 #define OCFS2_HB_LOCAL "heartbeat=local"
384 #define OCFS2_HB_GLOBAL "heartbeat=global"
387 * OCFS2 directory file types. Only the low 3 bits are used. The
388 * other bits are reserved for now.
390 #define OCFS2_FT_UNKNOWN 0
391 #define OCFS2_FT_REG_FILE 1
392 #define OCFS2_FT_DIR 2
393 #define OCFS2_FT_CHRDEV 3
394 #define OCFS2_FT_BLKDEV 4
395 #define OCFS2_FT_FIFO 5
396 #define OCFS2_FT_SOCK 6
397 #define OCFS2_FT_SYMLINK 7
399 #define OCFS2_FT_MAX 8
402 * OCFS2_DIR_PAD defines the directory entries boundaries
404 * NOTE: It must be a multiple of 4
406 #define OCFS2_DIR_PAD 4
407 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
408 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
409 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
410 OCFS2_DIR_ROUND) & \
411 ~OCFS2_DIR_ROUND)
412 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
414 #define OCFS2_LINK_MAX 32000
415 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
416 #define OCFS2_LINKS_HI_SHIFT 16
417 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
419 #define S_SHIFT 12
420 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
421 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
422 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
423 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
424 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
425 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
426 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
427 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
432 * Convenience casts
434 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
437 * Block checking structure. This is used in metadata to validate the
438 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
439 * zeros.
441 struct ocfs2_block_check {
442 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
443 __le16 bc_ecc; /* Single-error-correction parity vector.
444 This is a simple Hamming code dependent
445 on the blocksize. OCFS2's maximum
446 blocksize, 4K, requires 16 parity bits,
447 so we fit in __le16. */
448 __le16 bc_reserved1;
449 /*08*/
453 * On disk extent record for OCFS2
454 * It describes a range of clusters on disk.
456 * Length fields are divided into interior and leaf node versions.
457 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
459 struct ocfs2_extent_rec {
460 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
461 union {
462 __le32 e_int_clusters; /* Clusters covered by all children */
463 struct {
464 __le16 e_leaf_clusters; /* Clusters covered by this
465 extent */
466 __u8 e_reserved1;
467 __u8 e_flags; /* Extent flags */
470 __le64 e_blkno; /* Physical disk offset, in blocks */
471 /*10*/
474 struct ocfs2_chain_rec {
475 __le32 c_free; /* Number of free bits in this chain. */
476 __le32 c_total; /* Number of total bits in this chain */
477 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
480 struct ocfs2_truncate_rec {
481 __le32 t_start; /* 1st cluster in this log */
482 __le32 t_clusters; /* Number of total clusters covered */
486 * On disk extent list for OCFS2 (node in the tree). Note that this
487 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
488 * offsets are relative to ocfs2_dinode.id2.i_list or
489 * ocfs2_extent_block.h_list, respectively.
491 struct ocfs2_extent_list {
492 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
493 point. 0 means data extents
494 hang directly off this
495 header (a leaf)
496 NOTE: The high 8 bits cannot be
497 used - tree_depth is never that big.
499 __le16 l_count; /* Number of extent records */
500 __le16 l_next_free_rec; /* Next unused extent slot */
501 __le16 l_reserved1;
502 __le64 l_reserved2; /* Pad to
503 sizeof(ocfs2_extent_rec) */
504 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
508 * On disk allocation chain list for OCFS2. Note that this is
509 * contained inside ocfs2_dinode, so the offsets are relative to
510 * ocfs2_dinode.id2.i_chain.
512 struct ocfs2_chain_list {
513 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
514 __le16 cl_bpc; /* Bits per cluster */
515 __le16 cl_count; /* Total chains in this list */
516 __le16 cl_next_free_rec; /* Next unused chain slot */
517 __le64 cl_reserved1;
518 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
522 * On disk deallocation log for OCFS2. Note that this is
523 * contained inside ocfs2_dinode, so the offsets are relative to
524 * ocfs2_dinode.id2.i_dealloc.
526 struct ocfs2_truncate_log {
527 /*00*/ __le16 tl_count; /* Total records in this log */
528 __le16 tl_used; /* Number of records in use */
529 __le32 tl_reserved1;
530 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
534 * On disk extent block (indirect block) for OCFS2
536 struct ocfs2_extent_block
538 /*00*/ __u8 h_signature[8]; /* Signature for verification */
539 struct ocfs2_block_check h_check; /* Error checking */
540 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
541 extent_header belongs to */
542 __le16 h_suballoc_bit; /* Bit offset in suballocator
543 block group */
544 __le32 h_fs_generation; /* Must match super block */
545 __le64 h_blkno; /* Offset on disk, in blocks */
546 /*20*/ __le64 h_suballoc_loc; /* Suballocator block group this
547 eb belongs to. Only valid
548 if allocated from a
549 discontiguous block group */
550 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
551 of next leaf header pointing
552 to data */
553 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
554 /* Actual on-disk size is one block */
558 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
559 * system file. A slot is valid if it contains a node number >= 0. The
560 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
562 struct ocfs2_slot_map {
563 /*00*/ __le16 sm_slots[0];
565 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
566 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
570 struct ocfs2_extended_slot {
571 /*00*/ __u8 es_valid;
572 __u8 es_reserved1[3];
573 __le32 es_node_num;
574 /*10*/
578 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
579 * is set. It separates out the valid marker from the node number, and
580 * has room to grow. Unlike the old slot map, this format is defined by
581 * i_size.
583 struct ocfs2_slot_map_extended {
584 /*00*/ struct ocfs2_extended_slot se_slots[0];
586 * Actual size is i_size of the slot_map system file. It should
587 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
592 * ci_stackflags is only valid if the incompat bit
593 * OCFS2_FEATURE_INCOMPAT_CLUSTERINFO is set.
595 struct ocfs2_cluster_info {
596 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
597 union {
598 __le32 ci_reserved;
599 struct {
600 __u8 ci_stackflags;
601 __u8 ci_reserved1;
602 __u8 ci_reserved2;
603 __u8 ci_reserved3;
606 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
607 /*18*/
611 * On disk superblock for OCFS2
612 * Note that it is contained inside an ocfs2_dinode, so all offsets
613 * are relative to the start of ocfs2_dinode.id2.
615 struct ocfs2_super_block {
616 /*00*/ __le16 s_major_rev_level;
617 __le16 s_minor_rev_level;
618 __le16 s_mnt_count;
619 __le16 s_max_mnt_count;
620 __le16 s_state; /* File system state */
621 __le16 s_errors; /* Behaviour when detecting errors */
622 __le32 s_checkinterval; /* Max time between checks */
623 /*10*/ __le64 s_lastcheck; /* Time of last check */
624 __le32 s_creator_os; /* OS */
625 __le32 s_feature_compat; /* Compatible feature set */
626 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
627 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
628 __le64 s_root_blkno; /* Offset, in blocks, of root directory
629 dinode */
630 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
631 directory dinode */
632 __le32 s_blocksize_bits; /* Blocksize for this fs */
633 __le32 s_clustersize_bits; /* Clustersize for this fs */
634 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
635 before tunefs required */
636 __le16 s_tunefs_flag;
637 __le32 s_uuid_hash; /* hash value of uuid */
638 __le64 s_first_cluster_group; /* Block offset of 1st cluster
639 * group header */
640 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
641 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
642 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Only valid if either
643 userspace or clusterinfo
644 INCOMPAT flag set. */
645 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
646 for this fs*/
647 __le16 s_reserved0;
648 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
649 * s_uuid_hash serves as seed[3]. */
650 /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
651 /*140*/
654 * NOTE: As stated above, all offsets are relative to
655 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
656 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
657 * our smallest blocksize, which is 512 bytes. To ensure this,
658 * we reserve the space in s_reserved2. Anything past s_reserved2
659 * will not be available on the smallest blocksize.
664 * Local allocation bitmap for OCFS2 slots
665 * Note that it exists inside an ocfs2_dinode, so all offsets are
666 * relative to the start of ocfs2_dinode.id2.
668 struct ocfs2_local_alloc
670 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
671 __le16 la_size; /* Size of included bitmap, in bytes */
672 __le16 la_reserved1;
673 __le64 la_reserved2;
674 /*10*/ __u8 la_bitmap[0];
678 * Data-in-inode header. This is only used if i_dyn_features has
679 * OCFS2_INLINE_DATA_FL set.
681 struct ocfs2_inline_data
683 /*00*/ __le16 id_count; /* Number of bytes that can be used
684 * for data, starting at id_data */
685 __le16 id_reserved0;
686 __le32 id_reserved1;
687 __u8 id_data[0]; /* Start of user data */
691 * On disk inode for OCFS2
693 struct ocfs2_dinode {
694 /*00*/ __u8 i_signature[8]; /* Signature for validation */
695 __le32 i_generation; /* Generation number */
696 __le16 i_suballoc_slot; /* Slot suballocator this inode
697 belongs to */
698 __le16 i_suballoc_bit; /* Bit offset in suballocator
699 block group */
700 /*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
701 __le16 i_xattr_inline_size;
702 __le32 i_clusters; /* Cluster count */
703 __le32 i_uid; /* Owner UID */
704 __le32 i_gid; /* Owning GID */
705 /*20*/ __le64 i_size; /* Size in bytes */
706 __le16 i_mode; /* File mode */
707 __le16 i_links_count; /* Links count */
708 __le32 i_flags; /* File flags */
709 /*30*/ __le64 i_atime; /* Access time */
710 __le64 i_ctime; /* Creation time */
711 /*40*/ __le64 i_mtime; /* Modification time */
712 __le64 i_dtime; /* Deletion time */
713 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
714 __le64 i_last_eb_blk; /* Pointer to last extent
715 block */
716 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
717 __le32 i_atime_nsec;
718 __le32 i_ctime_nsec;
719 __le32 i_mtime_nsec;
720 /*70*/ __le32 i_attr;
721 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
722 was set in i_flags */
723 __le16 i_dyn_features;
724 __le64 i_xattr_loc;
725 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
726 /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
727 /*90*/ __le64 i_refcount_loc;
728 __le64 i_suballoc_loc; /* Suballocator block group this
729 inode belongs to. Only valid
730 if allocated from a
731 discontiguous block group */
732 /*A0*/ __le64 i_reserved2[3];
733 /*B8*/ union {
734 __le64 i_pad1; /* Generic way to refer to this
735 64bit union */
736 struct {
737 __le64 i_rdev; /* Device number */
738 } dev1;
739 struct { /* Info for bitmap system
740 inodes */
741 __le32 i_used; /* Bits (ie, clusters) used */
742 __le32 i_total; /* Total bits (clusters)
743 available */
744 } bitmap1;
745 struct { /* Info for journal system
746 inodes */
747 __le32 ij_flags; /* Mounted, version, etc. */
748 __le32 ij_recovery_generation; /* Incremented when the
749 journal is recovered
750 after an unclean
751 shutdown */
752 } journal1;
753 } id1; /* Inode type dependent 1 */
754 /*C0*/ union {
755 struct ocfs2_super_block i_super;
756 struct ocfs2_local_alloc i_lab;
757 struct ocfs2_chain_list i_chain;
758 struct ocfs2_extent_list i_list;
759 struct ocfs2_truncate_log i_dealloc;
760 struct ocfs2_inline_data i_data;
761 __u8 i_symlink[0];
762 } id2;
763 /* Actual on-disk size is one block */
767 * On-disk directory entry structure for OCFS2
769 * Packed as this structure could be accessed unaligned on 64-bit platforms
771 struct ocfs2_dir_entry {
772 /*00*/ __le64 inode; /* Inode number */
773 __le16 rec_len; /* Directory entry length */
774 __u8 name_len; /* Name length */
775 __u8 file_type;
776 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
777 /* Actual on-disk length specified by rec_len */
778 } __attribute__ ((packed));
781 * Per-block record for the unindexed directory btree. This is carefully
782 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
783 * mirrored. That way, the directory manipulation code needs a minimal amount
784 * of update.
786 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
788 struct ocfs2_dir_block_trailer {
789 /*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
791 __le16 db_compat_rec_len; /* Backwards compatible with
792 * ocfs2_dir_entry. */
793 __u8 db_compat_name_len; /* Always zero. Was name_len */
794 __u8 db_reserved0;
795 __le16 db_reserved1;
796 __le16 db_free_rec_len; /* Size of largest empty hole
797 * in this block. (unused) */
798 /*10*/ __u8 db_signature[8]; /* Signature for verification */
799 __le64 db_reserved2;
800 __le64 db_free_next; /* Next block in list (unused) */
801 /*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
802 __le64 db_parent_dinode; /* dinode which owns me, in
803 blocks */
804 /*30*/ struct ocfs2_block_check db_check; /* Error checking */
805 /*40*/
809 * A directory entry in the indexed tree. We don't store the full name here,
810 * but instead provide a pointer to the full dirent in the unindexed tree.
812 * We also store name_len here so as to reduce the number of leaf blocks we
813 * need to search in case of collisions.
815 struct ocfs2_dx_entry {
816 __le32 dx_major_hash; /* Used to find logical
817 * cluster in index */
818 __le32 dx_minor_hash; /* Lower bits used to find
819 * block in cluster */
820 __le64 dx_dirent_blk; /* Physical block in unindexed
821 * tree holding this dirent. */
824 struct ocfs2_dx_entry_list {
825 __le32 de_reserved;
826 __le16 de_count; /* Maximum number of entries
827 * possible in de_entries */
828 __le16 de_num_used; /* Current number of
829 * de_entries entries */
830 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
831 * in a packed array of
832 * length de_num_used */
835 #define OCFS2_DX_FLAG_INLINE 0x01
838 * A directory indexing block. Each indexed directory has one of these,
839 * pointed to by ocfs2_dinode.
841 * This block stores an indexed btree root, and a set of free space
842 * start-of-list pointers.
844 struct ocfs2_dx_root_block {
845 __u8 dr_signature[8]; /* Signature for verification */
846 struct ocfs2_block_check dr_check; /* Error checking */
847 __le16 dr_suballoc_slot; /* Slot suballocator this
848 * block belongs to. */
849 __le16 dr_suballoc_bit; /* Bit offset in suballocator
850 * block group */
851 __le32 dr_fs_generation; /* Must match super block */
852 __le64 dr_blkno; /* Offset on disk, in blocks */
853 __le64 dr_last_eb_blk; /* Pointer to last
854 * extent block */
855 __le32 dr_clusters; /* Clusters allocated
856 * to the indexed tree. */
857 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
858 __u8 dr_reserved0;
859 __le16 dr_reserved1;
860 __le64 dr_dir_blkno; /* Pointer to parent inode */
861 __le32 dr_num_entries; /* Total number of
862 * names stored in
863 * this directory.*/
864 __le32 dr_reserved2;
865 __le64 dr_free_blk; /* Pointer to head of free
866 * unindexed block list. */
867 __le64 dr_suballoc_loc; /* Suballocator block group
868 this root belongs to.
869 Only valid if allocated
870 from a discontiguous
871 block group */
872 __le64 dr_reserved3[14];
873 union {
874 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
875 * bits for maximum space
876 * efficiency. */
877 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
878 * entries. We grow out
879 * to extents if this
880 * gets too big. */
885 * The header of a leaf block in the indexed tree.
887 struct ocfs2_dx_leaf {
888 __u8 dl_signature[8];/* Signature for verification */
889 struct ocfs2_block_check dl_check; /* Error checking */
890 __le64 dl_blkno; /* Offset on disk, in blocks */
891 __le32 dl_fs_generation;/* Must match super block */
892 __le32 dl_reserved0;
893 __le64 dl_reserved1;
894 struct ocfs2_dx_entry_list dl_list;
898 * Largest bitmap for a block (suballocator) group in bytes. This limit
899 * does not affect cluster groups (global allocator). Cluster group
900 * bitmaps run to the end of the block.
902 #define OCFS2_MAX_BG_BITMAP_SIZE 256
905 * On disk allocator group structure for OCFS2
907 struct ocfs2_group_desc
909 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
910 __le16 bg_size; /* Size of included bitmap in
911 bytes. */
912 __le16 bg_bits; /* Bits represented by this
913 group. */
914 __le16 bg_free_bits_count; /* Free bits count */
915 __le16 bg_chain; /* What chain I am in. */
916 /*10*/ __le32 bg_generation;
917 __le32 bg_reserved1;
918 __le64 bg_next_group; /* Next group in my list, in
919 blocks */
920 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
921 blocks */
922 __le64 bg_blkno; /* Offset on disk, in blocks */
923 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
924 __le64 bg_reserved2;
925 /*40*/ union {
926 __u8 bg_bitmap[0];
927 struct {
929 * Block groups may be discontiguous when
930 * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
931 * The extents of a discontigous block group are
932 * stored in bg_list. It is a flat list.
933 * l_tree_depth must always be zero. A
934 * discontiguous group is signified by a non-zero
935 * bg_list->l_next_free_rec. Only block groups
936 * can be discontiguous; Cluster groups cannot.
937 * We've never made a block group with more than
938 * 2048 blocks (256 bytes of bg_bitmap). This
939 * codifies that limit so that we can fit bg_list.
940 * bg_size of a discontiguous block group will
941 * be 256 to match bg_bitmap_filler.
943 __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
944 /*140*/ struct ocfs2_extent_list bg_list;
947 /* Actual on-disk size is one block */
950 struct ocfs2_refcount_rec {
951 /*00*/ __le64 r_cpos; /* Physical offset, in clusters */
952 __le32 r_clusters; /* Clusters covered by this extent */
953 __le32 r_refcount; /* Reference count of this extent */
954 /*10*/
956 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
958 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
959 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
961 struct ocfs2_refcount_list {
962 /*00*/ __le16 rl_count; /* Maximum number of entries possible
963 in rl_records */
964 __le16 rl_used; /* Current number of used records */
965 __le32 rl_reserved2;
966 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
967 /*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
971 struct ocfs2_refcount_block {
972 /*00*/ __u8 rf_signature[8]; /* Signature for verification */
973 __le16 rf_suballoc_slot; /* Slot suballocator this block
974 belongs to */
975 __le16 rf_suballoc_bit; /* Bit offset in suballocator
976 block group */
977 __le32 rf_fs_generation; /* Must match superblock */
978 /*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
979 __le64 rf_parent; /* Parent block, only valid if
980 OCFS2_REFCOUNT_LEAF_FL is set in
981 rf_flags */
982 /*20*/ struct ocfs2_block_check rf_check; /* Error checking */
983 __le64 rf_last_eb_blk; /* Pointer to last extent block */
984 /*30*/ __le32 rf_count; /* Number of inodes sharing this
985 refcount tree */
986 __le32 rf_flags; /* See the flags above */
987 __le32 rf_clusters; /* clusters covered by refcount tree. */
988 __le32 rf_cpos; /* cluster offset in refcount tree.*/
989 /*40*/ __le32 rf_generation; /* generation number. all be the same
990 * for the same refcount tree. */
991 __le32 rf_reserved0;
992 __le64 rf_suballoc_loc; /* Suballocator block group this
993 refcount block belongs to. Only
994 valid if allocated from a
995 discontiguous block group */
996 /*50*/ __le64 rf_reserved1[6];
997 /*80*/ union {
998 struct ocfs2_refcount_list rf_records; /* List of refcount
999 records */
1000 struct ocfs2_extent_list rf_list; /* Extent record list,
1001 only valid if
1002 OCFS2_REFCOUNT_TREE_FL
1003 is set in rf_flags */
1005 /* Actual on-disk size is one block */
1009 * On disk extended attribute structure for OCFS2.
1013 * ocfs2_xattr_entry indicates one extend attribute.
1015 * Note that it can be stored in inode, one block or one xattr bucket.
1017 struct ocfs2_xattr_entry {
1018 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
1019 __le16 xe_name_offset; /* byte offset from the 1st entry in the
1020 local xattr storage(inode, xattr block or
1021 xattr bucket). */
1022 __u8 xe_name_len; /* xattr name len, doesn't include prefix. */
1023 __u8 xe_type; /* the low 7 bits indicate the name prefix
1024 * type and the highest bit indicates whether
1025 * the EA is stored in the local storage. */
1026 __le64 xe_value_size; /* real xattr value length. */
1030 * On disk structure for xattr header.
1032 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
1033 * the local xattr storage.
1035 struct ocfs2_xattr_header {
1036 __le16 xh_count; /* contains the count of how
1037 many records are in the
1038 local xattr storage. */
1039 __le16 xh_free_start; /* current offset for storing
1040 xattr. */
1041 __le16 xh_name_value_len; /* total length of name/value
1042 length in this bucket. */
1043 __le16 xh_num_buckets; /* Number of xattr buckets
1044 in this extent record,
1045 only valid in the first
1046 bucket. */
1047 struct ocfs2_block_check xh_check; /* Error checking
1048 (Note, this is only
1049 used for xattr
1050 buckets. A block uses
1051 xb_check and sets
1052 this field to zero.) */
1053 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
1057 * On disk structure for xattr value root.
1059 * When an xattr's value is large enough, it is stored in an external
1060 * b-tree like file data. The xattr value root points to this structure.
1062 struct ocfs2_xattr_value_root {
1063 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
1064 __le32 xr_reserved0;
1065 __le64 xr_last_eb_blk; /* Pointer to last extent block */
1066 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
1070 * On disk structure for xattr tree root.
1072 * It is used when there are too many extended attributes for one file. These
1073 * attributes will be organized and stored in an indexed-btree.
1075 struct ocfs2_xattr_tree_root {
1076 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
1077 __le32 xt_reserved0;
1078 __le64 xt_last_eb_blk; /* Pointer to last extent block */
1079 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
1082 #define OCFS2_XATTR_INDEXED 0x1
1083 #define OCFS2_HASH_SHIFT 5
1084 #define OCFS2_XATTR_ROUND 3
1085 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1086 ~(OCFS2_XATTR_ROUND))
1088 #define OCFS2_XATTR_BUCKET_SIZE 4096
1089 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1090 / OCFS2_MIN_BLOCKSIZE)
1093 * On disk structure for xattr block.
1095 struct ocfs2_xattr_block {
1096 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
1097 __le16 xb_suballoc_slot; /* Slot suballocator this
1098 block belongs to. */
1099 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1100 block group */
1101 __le32 xb_fs_generation; /* Must match super block */
1102 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
1103 struct ocfs2_block_check xb_check; /* Error checking */
1104 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
1105 real xattr or a xattr tree. */
1106 __le16 xb_reserved0;
1107 __le32 xb_reserved1;
1108 __le64 xb_suballoc_loc; /* Suballocator block group this
1109 xattr block belongs to. Only
1110 valid if allocated from a
1111 discontiguous block group */
1112 /*30*/ union {
1113 struct ocfs2_xattr_header xb_header; /* xattr header if this
1114 block contains xattr */
1115 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1116 block cotains xattr
1117 tree. */
1118 } xb_attrs;
1121 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1122 #define OCFS2_XATTR_TYPE_MASK 0x7F
1123 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1124 int local)
1126 if (local)
1127 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1128 else
1129 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1132 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1134 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1137 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1139 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1142 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1144 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1148 * On disk structures for global quota file
1151 /* Magic numbers and known versions for global quota files */
1152 #define OCFS2_GLOBAL_QMAGICS {\
1153 0x0cf52470, /* USRQUOTA */ \
1154 0x0cf52471 /* GRPQUOTA */ \
1157 #define OCFS2_GLOBAL_QVERSIONS {\
1158 0, \
1159 0, \
1163 /* Each block of each quota file has a certain fixed number of bytes reserved
1164 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1165 * checksums, etc. */
1166 #define OCFS2_QBLK_RESERVED_SPACE 8
1168 /* Generic header of all quota files */
1169 struct ocfs2_disk_dqheader {
1170 __le32 dqh_magic; /* Magic number identifying file */
1171 __le32 dqh_version; /* Quota format version */
1174 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1176 /* Information header of global quota file (immediately follows the generic
1177 * header) */
1178 struct ocfs2_global_disk_dqinfo {
1179 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1180 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1181 __le32 dqi_syncms; /* Time after which we sync local changes to
1182 * global quota file */
1183 __le32 dqi_blocks; /* Number of blocks in quota file */
1184 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1185 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1186 * file */
1189 /* Structure with global user / group information. We reserve some space
1190 * for future use. */
1191 struct ocfs2_global_disk_dqblk {
1192 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
1193 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1194 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1195 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1196 __le64 dqb_curinodes; /* current # allocated inodes */
1197 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1198 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1199 /*30*/ __le64 dqb_curspace; /* current space occupied */
1200 __le64 dqb_btime; /* time limit for excessive disk use */
1201 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1202 __le64 dqb_pad1;
1203 /*50*/ __le64 dqb_pad2;
1207 * On-disk structures for local quota file
1210 /* Magic numbers and known versions for local quota files */
1211 #define OCFS2_LOCAL_QMAGICS {\
1212 0x0cf524c0, /* USRQUOTA */ \
1213 0x0cf524c1 /* GRPQUOTA */ \
1216 #define OCFS2_LOCAL_QVERSIONS {\
1217 0, \
1218 0, \
1221 /* Quota flags in dqinfo header */
1222 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1223 * quota has been cleanly turned off) */
1225 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1227 /* Information header of local quota file (immediately follows the generic
1228 * header) */
1229 struct ocfs2_local_disk_dqinfo {
1230 __le32 dqi_flags; /* Flags for quota file */
1231 __le32 dqi_chunks; /* Number of chunks of quota structures
1232 * with a bitmap */
1233 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1236 /* Header of one chunk of a quota file */
1237 struct ocfs2_local_disk_chunk {
1238 __le32 dqc_free; /* Number of free entries in the bitmap */
1239 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1240 * chunk of quota file */
1243 /* One entry in local quota file */
1244 struct ocfs2_local_disk_dqblk {
1245 /*00*/ __le64 dqb_id; /* id this quota applies to */
1246 __le64 dqb_spacemod; /* Change in the amount of used space */
1247 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1252 * The quota trailer lives at the end of each quota block.
1255 struct ocfs2_disk_dqtrailer {
1256 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1257 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1260 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1261 void *buf)
1263 char *ptr = buf;
1264 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1266 return (struct ocfs2_disk_dqtrailer *)ptr;
1269 #ifdef __KERNEL__
1270 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1272 return sb->s_blocksize -
1273 offsetof(struct ocfs2_dinode, id2.i_symlink);
1276 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1277 struct ocfs2_dinode *di)
1279 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1281 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1282 return sb->s_blocksize -
1283 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1284 xattrsize;
1285 else
1286 return sb->s_blocksize -
1287 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1290 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1292 int size;
1294 size = sb->s_blocksize -
1295 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1297 return size / sizeof(struct ocfs2_extent_rec);
1300 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1301 struct super_block *sb,
1302 struct ocfs2_dinode *di)
1304 int size;
1305 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1307 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1308 size = sb->s_blocksize -
1309 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1310 xattrsize;
1311 else
1312 size = sb->s_blocksize -
1313 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1315 return size / sizeof(struct ocfs2_extent_rec);
1318 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1320 int size;
1322 size = sb->s_blocksize -
1323 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1325 return size / sizeof(struct ocfs2_extent_rec);
1328 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1330 int size;
1332 size = sb->s_blocksize -
1333 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1335 return size / sizeof(struct ocfs2_chain_rec);
1338 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1340 int size;
1342 size = sb->s_blocksize -
1343 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1345 return size / sizeof(struct ocfs2_extent_rec);
1348 static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1350 int size;
1352 size = sb->s_blocksize -
1353 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1355 return size / sizeof(struct ocfs2_extent_rec);
1358 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1360 int size;
1362 size = sb->s_blocksize -
1363 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1365 return size / sizeof(struct ocfs2_dx_entry);
1368 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1370 int size;
1372 size = sb->s_blocksize -
1373 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1375 return size / sizeof(struct ocfs2_dx_entry);
1378 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1380 u16 size;
1382 size = sb->s_blocksize -
1383 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1385 return size;
1388 static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1389 int suballocator,
1390 u32 feature_incompat)
1392 int size = sb->s_blocksize -
1393 offsetof(struct ocfs2_group_desc, bg_bitmap);
1396 * The cluster allocator uses the entire block. Suballocators have
1397 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1398 * code expects bg_size set to the maximum. Thus we must keep
1399 * bg_size as-is unless discontig_bg is enabled.
1401 if (suballocator &&
1402 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1403 size = OCFS2_MAX_BG_BITMAP_SIZE;
1405 return size;
1408 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1410 int size;
1412 size = sb->s_blocksize -
1413 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1415 return size / sizeof(struct ocfs2_truncate_rec);
1418 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1420 u64 offset = OCFS2_BACKUP_SB_START;
1422 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1423 offset <<= (2 * index);
1424 offset >>= sb->s_blocksize_bits;
1425 return offset;
1428 return 0;
1432 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1434 int size;
1436 size = sb->s_blocksize -
1437 offsetof(struct ocfs2_xattr_block,
1438 xb_attrs.xb_root.xt_list.l_recs);
1440 return size / sizeof(struct ocfs2_extent_rec);
1443 static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1445 int size;
1447 size = sb->s_blocksize -
1448 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1450 return size / sizeof(struct ocfs2_extent_rec);
1453 static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1455 int size;
1457 size = sb->s_blocksize -
1458 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1460 return size / sizeof(struct ocfs2_refcount_rec);
1463 static inline u32
1464 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1466 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1468 #else
1469 static inline int ocfs2_fast_symlink_chars(int blocksize)
1471 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1474 static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1475 struct ocfs2_dinode *di)
1477 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1478 return blocksize -
1479 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1480 di->i_xattr_inline_size;
1481 else
1482 return blocksize -
1483 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1486 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1488 int size;
1490 size = blocksize -
1491 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1493 return size / sizeof(struct ocfs2_extent_rec);
1496 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1498 int size;
1500 size = blocksize -
1501 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1503 return size / sizeof(struct ocfs2_chain_rec);
1506 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1508 int size;
1510 size = blocksize -
1511 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1513 return size / sizeof(struct ocfs2_extent_rec);
1516 static inline int ocfs2_extent_recs_per_gd(int blocksize)
1518 int size;
1520 size = blocksize -
1521 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1523 return size / sizeof(struct ocfs2_extent_rec);
1526 static inline int ocfs2_local_alloc_size(int blocksize)
1528 int size;
1530 size = blocksize -
1531 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1533 return size;
1536 static inline int ocfs2_group_bitmap_size(int blocksize,
1537 int suballocator,
1538 uint32_t feature_incompat)
1540 int size = sb->s_blocksize -
1541 offsetof(struct ocfs2_group_desc, bg_bitmap);
1544 * The cluster allocator uses the entire block. Suballocators have
1545 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1546 * code expects bg_size set to the maximum. Thus we must keep
1547 * bg_size as-is unless discontig_bg is enabled.
1549 if (suballocator &&
1550 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1551 size = OCFS2_MAX_BG_BITMAP_SIZE;
1553 return size;
1556 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1558 int size;
1560 size = blocksize -
1561 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1563 return size / sizeof(struct ocfs2_truncate_rec);
1566 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1568 uint64_t offset = OCFS2_BACKUP_SB_START;
1570 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1571 offset <<= (2 * index);
1572 offset /= blocksize;
1573 return offset;
1576 return 0;
1579 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1581 int size;
1583 size = blocksize -
1584 offsetof(struct ocfs2_xattr_block,
1585 xb_attrs.xb_root.xt_list.l_recs);
1587 return size / sizeof(struct ocfs2_extent_rec);
1589 #endif /* __KERNEL__ */
1592 static inline int ocfs2_system_inode_is_global(int type)
1594 return ((type >= 0) &&
1595 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1598 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1599 int type, int slot)
1601 int chars;
1604 * Global system inodes can only have one copy. Everything
1605 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1606 * list has a copy per slot.
1608 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1609 chars = snprintf(buf, len, "%s",
1610 ocfs2_system_inodes[type].si_name);
1611 else
1612 chars = snprintf(buf, len,
1613 ocfs2_system_inodes[type].si_name,
1614 slot);
1616 return chars;
1619 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1620 umode_t mode)
1622 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1625 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1627 if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1628 le16_to_cpu(gd->bg_size)) !=
1629 offsetof(struct ocfs2_group_desc, bg_list))
1630 return 0;
1632 * Only valid to check l_next_free_rec if
1633 * bg_bitmap + bg_size == bg_list.
1635 if (!gd->bg_list.l_next_free_rec)
1636 return 0;
1637 return 1;
1639 #endif /* _OCFS2_FS_H */