1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
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.
28 #include <linux/magic.h>
31 #define OCFS2_MAJOR_REV_LEVEL 0
32 #define OCFS2_MINOR_REV_LEVEL 90
35 * An OCFS2 volume starts this way:
36 * Sector 0: Valid ocfs1_vol_disk_hdr that cleanly fails to mount OCFS.
37 * Sector 1: Valid ocfs1_vol_label that cleanly fails to mount OCFS.
38 * Block OCFS2_SUPER_BLOCK_BLKNO: OCFS2 superblock.
40 * All other structures are found from the superblock information.
42 * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a
43 * blocksize of 2K, it is 4096 bytes into disk.
45 #define OCFS2_SUPER_BLOCK_BLKNO 2
48 * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could
51 #define OCFS2_MIN_CLUSTERSIZE 4096
52 #define OCFS2_MAX_CLUSTERSIZE 1048576
55 * Blocks cannot be bigger than clusters, so the maximum blocksize is the
56 * minimum cluster size.
58 #define OCFS2_MIN_BLOCKSIZE 512
59 #define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE
61 /* Object signatures */
62 #define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
63 #define OCFS2_INODE_SIGNATURE "INODE01"
64 #define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
65 #define OCFS2_GROUP_DESC_SIGNATURE "GROUP01"
66 #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
67 #define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
68 #define OCFS2_DX_ROOT_SIGNATURE "DXDIR01"
69 #define OCFS2_DX_LEAF_SIGNATURE "DXLEAF1"
70 #define OCFS2_REFCOUNT_BLOCK_SIGNATURE "REFCNT1"
72 /* Compatibility flags */
73 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
74 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
75 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
76 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
77 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
78 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
79 #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
80 OCFS2_SB(sb)->s_feature_compat |= (mask)
81 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
82 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
83 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
84 OCFS2_SB(sb)->s_feature_incompat |= (mask)
85 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
86 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
87 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
88 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
89 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
90 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
92 #define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \
93 | OCFS2_FEATURE_COMPAT_JBD2_SB)
94 #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
95 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
96 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
97 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
98 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
99 | OCFS2_FEATURE_INCOMPAT_XATTR \
100 | OCFS2_FEATURE_INCOMPAT_META_ECC \
101 | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
102 | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
103 | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \
104 | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO \
105 | OCFS2_FEATURE_INCOMPAT_APPEND_DIO)
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
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 /* Discontiguous 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 * Append Direct IO support
183 #define OCFS2_FEATURE_INCOMPAT_APPEND_DIO 0x8000
186 * backup superblock flag is used to indicate that this volume
187 * has backup superblocks.
189 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
192 * The filesystem will correctly handle journal feature bits.
194 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
197 * Unwritten extents support.
199 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
202 * Maintain quota information for this filesystem
204 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
205 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
208 /* The byte offset of the first backup block will be 1G.
209 * The following will be 4G, 16G, 64G, 256G and 1T.
211 #define OCFS2_BACKUP_SB_START 1 << 30
213 /* the max backup superblock nums */
214 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
217 * Flags on ocfs2_super_block.s_tunefs_flags
219 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
222 * Flags on ocfs2_dinode.i_flags
224 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
225 #define OCFS2_UNUSED2_FL (0x00000002)
226 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
227 #define OCFS2_UNUSED3_FL (0x00000008)
228 /* System inode flags */
229 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
230 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
231 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
232 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
233 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
234 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
235 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
236 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
237 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
238 #define OCFS2_DIO_ORPHANED_FL (0X00002000) /* On the orphan list especially
242 * Flags on ocfs2_dinode.i_dyn_features
244 * These can change much more often than i_flags. When adding flags,
245 * keep in mind that i_dyn_features is only 16 bits wide.
247 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
248 #define OCFS2_HAS_XATTR_FL (0x0002)
249 #define OCFS2_INLINE_XATTR_FL (0x0004)
250 #define OCFS2_INDEXED_DIR_FL (0x0008)
251 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
253 /* Inode attributes, keep in sync with EXT2 */
254 #define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
255 #define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
256 #define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
257 #define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
258 #define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
259 #define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
260 #define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
261 #define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
262 /* Reserved for compression usage... */
263 #define OCFS2_DIRTY_FL FS_DIRTY_FL
264 #define OCFS2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */
265 #define OCFS2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */
266 #define OCFS2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */
267 /* End compression flags --- maybe not all used */
268 #define OCFS2_BTREE_FL FS_BTREE_FL /* btree format dir */
269 #define OCFS2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */
270 #define OCFS2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */
271 #define OCFS2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */
272 #define OCFS2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
273 #define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
274 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
275 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
277 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
278 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
281 * Extent record flags (e_node.leaf.flags)
283 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
285 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
286 * counted in an associated
290 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
292 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
295 * superblock s_state flags
297 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
299 /* Limit of space in ocfs2_dir_entry */
300 #define OCFS2_MAX_FILENAME_LEN 255
302 /* Maximum slots on an ocfs2 file system */
303 #define OCFS2_MAX_SLOTS 255
305 /* Slot map indicator for an empty slot */
306 #define OCFS2_INVALID_SLOT -1
308 #define OCFS2_VOL_UUID_LEN 16
309 #define OCFS2_MAX_VOL_LABEL_LEN 64
311 /* The cluster stack fields */
312 #define OCFS2_STACK_LABEL_LEN 4
313 #define OCFS2_CLUSTER_NAME_LEN 16
315 /* Classic (historically speaking) cluster stack */
316 #define OCFS2_CLASSIC_CLUSTER_STACK "o2cb"
318 /* Journal limits (in bytes) */
319 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
322 * Inline extended attribute size (in bytes)
323 * The value chosen should be aligned to 16 byte boundaries.
325 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
328 * Cluster info flags (ocfs2_cluster_info.ci_stackflags)
330 #define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT (0x01)
332 struct ocfs2_system_inode_info {
338 /* System file index */
340 BAD_BLOCK_SYSTEM_INODE = 0,
341 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
342 SLOT_MAP_SYSTEM_INODE,
343 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
344 HEARTBEAT_SYSTEM_INODE,
345 GLOBAL_BITMAP_SYSTEM_INODE,
346 USER_QUOTA_SYSTEM_INODE,
347 GROUP_QUOTA_SYSTEM_INODE,
348 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
349 #define OCFS2_FIRST_LOCAL_SYSTEM_INODE ORPHAN_DIR_SYSTEM_INODE
350 ORPHAN_DIR_SYSTEM_INODE,
351 EXTENT_ALLOC_SYSTEM_INODE,
352 INODE_ALLOC_SYSTEM_INODE,
353 JOURNAL_SYSTEM_INODE,
354 LOCAL_ALLOC_SYSTEM_INODE,
355 TRUNCATE_LOG_SYSTEM_INODE,
356 LOCAL_USER_QUOTA_SYSTEM_INODE,
357 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
358 #define OCFS2_LAST_LOCAL_SYSTEM_INODE LOCAL_GROUP_QUOTA_SYSTEM_INODE
361 #define NUM_GLOBAL_SYSTEM_INODES OCFS2_FIRST_LOCAL_SYSTEM_INODE
362 #define NUM_LOCAL_SYSTEM_INODES \
363 (NUM_SYSTEM_INODES - OCFS2_FIRST_LOCAL_SYSTEM_INODE)
365 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
366 /* Global system inodes (single copy) */
367 /* The first two are only used from userspace mfks/tunefs */
368 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
369 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
371 /* These are used by the running filesystem */
372 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
373 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
374 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
375 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
376 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
378 /* Slot-specific system inodes (one copy per slot) */
379 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
380 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
381 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
382 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
383 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
384 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
385 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
386 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
389 /* Parameter passed from mount.ocfs2 to module */
390 #define OCFS2_HB_NONE "heartbeat=none"
391 #define OCFS2_HB_LOCAL "heartbeat=local"
392 #define OCFS2_HB_GLOBAL "heartbeat=global"
395 * OCFS2_DIR_PAD defines the directory entries boundaries
397 * NOTE: It must be a multiple of 4
399 #define OCFS2_DIR_PAD 4
400 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
401 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
402 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
405 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
407 #define OCFS2_LINK_MAX 32000
408 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
409 #define OCFS2_LINKS_HI_SHIFT 16
410 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
416 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
419 * Block checking structure. This is used in metadata to validate the
420 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
423 struct ocfs2_block_check {
424 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
425 __le16 bc_ecc; /* Single-error-correction parity vector.
426 This is a simple Hamming code dependent
427 on the blocksize. OCFS2's maximum
428 blocksize, 4K, requires 16 parity bits,
429 so we fit in __le16. */
435 * On disk extent record for OCFS2
436 * It describes a range of clusters on disk.
438 * Length fields are divided into interior and leaf node versions.
439 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
441 struct ocfs2_extent_rec {
442 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
444 __le32 e_int_clusters; /* Clusters covered by all children */
446 __le16 e_leaf_clusters; /* Clusters covered by this
449 __u8 e_flags; /* Extent flags */
452 __le64 e_blkno; /* Physical disk offset, in blocks */
456 struct ocfs2_chain_rec {
457 __le32 c_free; /* Number of free bits in this chain. */
458 __le32 c_total; /* Number of total bits in this chain */
459 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
462 struct ocfs2_truncate_rec {
463 __le32 t_start; /* 1st cluster in this log */
464 __le32 t_clusters; /* Number of total clusters covered */
468 * On disk extent list for OCFS2 (node in the tree). Note that this
469 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
470 * offsets are relative to ocfs2_dinode.id2.i_list or
471 * ocfs2_extent_block.h_list, respectively.
473 struct ocfs2_extent_list {
474 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
475 point. 0 means data extents
476 hang directly off this
478 NOTE: The high 8 bits cannot be
479 used - tree_depth is never that big.
481 __le16 l_count; /* Number of extent records */
482 __le16 l_next_free_rec; /* Next unused extent slot */
484 __le64 l_reserved2; /* Pad to
485 sizeof(ocfs2_extent_rec) */
486 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
490 * On disk allocation chain list for OCFS2. Note that this is
491 * contained inside ocfs2_dinode, so the offsets are relative to
492 * ocfs2_dinode.id2.i_chain.
494 struct ocfs2_chain_list {
495 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
496 __le16 cl_bpc; /* Bits per cluster */
497 __le16 cl_count; /* Total chains in this list */
498 __le16 cl_next_free_rec; /* Next unused chain slot */
500 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
504 * On disk deallocation log for OCFS2. Note that this is
505 * contained inside ocfs2_dinode, so the offsets are relative to
506 * ocfs2_dinode.id2.i_dealloc.
508 struct ocfs2_truncate_log {
509 /*00*/ __le16 tl_count; /* Total records in this log */
510 __le16 tl_used; /* Number of records in use */
512 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
516 * On disk extent block (indirect block) for OCFS2
518 struct ocfs2_extent_block
520 /*00*/ __u8 h_signature[8]; /* Signature for verification */
521 struct ocfs2_block_check h_check; /* Error checking */
522 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
523 extent_header belongs to */
524 __le16 h_suballoc_bit; /* Bit offset in suballocator
526 __le32 h_fs_generation; /* Must match super block */
527 __le64 h_blkno; /* Offset on disk, in blocks */
528 /*20*/ __le64 h_suballoc_loc; /* Suballocator block group this
529 eb belongs to. Only valid
531 discontiguous block group */
532 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
533 of next leaf header pointing
535 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
536 /* Actual on-disk size is one block */
540 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
541 * system file. A slot is valid if it contains a node number >= 0. The
542 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
544 struct ocfs2_slot_map {
545 /*00*/ __le16 sm_slots[0];
547 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
548 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
552 struct ocfs2_extended_slot {
553 /*00*/ __u8 es_valid;
554 __u8 es_reserved1[3];
560 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
561 * is set. It separates out the valid marker from the node number, and
562 * has room to grow. Unlike the old slot map, this format is defined by
565 struct ocfs2_slot_map_extended {
566 /*00*/ struct ocfs2_extended_slot se_slots[0];
568 * Actual size is i_size of the slot_map system file. It should
569 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
574 * ci_stackflags is only valid if the incompat bit
575 * OCFS2_FEATURE_INCOMPAT_CLUSTERINFO is set.
577 struct ocfs2_cluster_info {
578 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
588 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
593 * On disk superblock for OCFS2
594 * Note that it is contained inside an ocfs2_dinode, so all offsets
595 * are relative to the start of ocfs2_dinode.id2.
597 struct ocfs2_super_block {
598 /*00*/ __le16 s_major_rev_level;
599 __le16 s_minor_rev_level;
601 __le16 s_max_mnt_count;
602 __le16 s_state; /* File system state */
603 __le16 s_errors; /* Behaviour when detecting errors */
604 __le32 s_checkinterval; /* Max time between checks */
605 /*10*/ __le64 s_lastcheck; /* Time of last check */
606 __le32 s_creator_os; /* OS */
607 __le32 s_feature_compat; /* Compatible feature set */
608 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
609 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
610 __le64 s_root_blkno; /* Offset, in blocks, of root directory
612 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
614 __le32 s_blocksize_bits; /* Blocksize for this fs */
615 __le32 s_clustersize_bits; /* Clustersize for this fs */
616 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
617 before tunefs required */
618 __le16 s_tunefs_flag;
619 __le32 s_uuid_hash; /* hash value of uuid */
620 __le64 s_first_cluster_group; /* Block offset of 1st cluster
622 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
623 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
624 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Only valid if either
625 userspace or clusterinfo
626 INCOMPAT flag set. */
627 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
630 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
631 * s_uuid_hash serves as seed[3]. */
632 /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
636 * NOTE: As stated above, all offsets are relative to
637 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
638 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
639 * our smallest blocksize, which is 512 bytes. To ensure this,
640 * we reserve the space in s_reserved2. Anything past s_reserved2
641 * will not be available on the smallest blocksize.
646 * Local allocation bitmap for OCFS2 slots
647 * Note that it exists inside an ocfs2_dinode, so all offsets are
648 * relative to the start of ocfs2_dinode.id2.
650 struct ocfs2_local_alloc
652 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
653 __le16 la_size; /* Size of included bitmap, in bytes */
656 /*10*/ __u8 la_bitmap[0];
660 * Data-in-inode header. This is only used if i_dyn_features has
661 * OCFS2_INLINE_DATA_FL set.
663 struct ocfs2_inline_data
665 /*00*/ __le16 id_count; /* Number of bytes that can be used
666 * for data, starting at id_data */
669 __u8 id_data[0]; /* Start of user data */
673 * On disk inode for OCFS2
675 struct ocfs2_dinode {
676 /*00*/ __u8 i_signature[8]; /* Signature for validation */
677 __le32 i_generation; /* Generation number */
678 __le16 i_suballoc_slot; /* Slot suballocator this inode
680 __le16 i_suballoc_bit; /* Bit offset in suballocator
682 /*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
683 __le16 i_xattr_inline_size;
684 __le32 i_clusters; /* Cluster count */
685 __le32 i_uid; /* Owner UID */
686 __le32 i_gid; /* Owning GID */
687 /*20*/ __le64 i_size; /* Size in bytes */
688 __le16 i_mode; /* File mode */
689 __le16 i_links_count; /* Links count */
690 __le32 i_flags; /* File flags */
691 /*30*/ __le64 i_atime; /* Access time */
692 __le64 i_ctime; /* Creation time */
693 /*40*/ __le64 i_mtime; /* Modification time */
694 __le64 i_dtime; /* Deletion time */
695 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
696 __le64 i_last_eb_blk; /* Pointer to last extent
698 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
702 /*70*/ __le32 i_attr;
703 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
704 was set in i_flags */
705 __le16 i_dyn_features;
707 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
708 /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
709 /*90*/ __le64 i_refcount_loc;
710 __le64 i_suballoc_loc; /* Suballocator block group this
711 inode belongs to. Only valid
713 discontiguous block group */
714 /*A0*/ __le16 i_dio_orphaned_slot; /* only used for append dio write */
715 __le16 i_reserved1[3];
716 __le64 i_reserved2[2];
718 __le64 i_pad1; /* Generic way to refer to this
721 __le64 i_rdev; /* Device number */
723 struct { /* Info for bitmap system
725 __le32 i_used; /* Bits (ie, clusters) used */
726 __le32 i_total; /* Total bits (clusters)
729 struct { /* Info for journal system
731 __le32 ij_flags; /* Mounted, version, etc. */
732 __le32 ij_recovery_generation; /* Incremented when the
737 } id1; /* Inode type dependent 1 */
739 struct ocfs2_super_block i_super;
740 struct ocfs2_local_alloc i_lab;
741 struct ocfs2_chain_list i_chain;
742 struct ocfs2_extent_list i_list;
743 struct ocfs2_truncate_log i_dealloc;
744 struct ocfs2_inline_data i_data;
747 /* Actual on-disk size is one block */
751 * On-disk directory entry structure for OCFS2
753 * Packed as this structure could be accessed unaligned on 64-bit platforms
755 struct ocfs2_dir_entry {
756 /*00*/ __le64 inode; /* Inode number */
757 __le16 rec_len; /* Directory entry length */
758 __u8 name_len; /* Name length */
760 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
761 /* Actual on-disk length specified by rec_len */
762 } __attribute__ ((packed));
765 * Per-block record for the unindexed directory btree. This is carefully
766 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
767 * mirrored. That way, the directory manipulation code needs a minimal amount
770 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
772 struct ocfs2_dir_block_trailer {
773 /*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
775 __le16 db_compat_rec_len; /* Backwards compatible with
776 * ocfs2_dir_entry. */
777 __u8 db_compat_name_len; /* Always zero. Was name_len */
780 __le16 db_free_rec_len; /* Size of largest empty hole
781 * in this block. (unused) */
782 /*10*/ __u8 db_signature[8]; /* Signature for verification */
784 /*20*/ __le64 db_free_next; /* Next block in list (unused) */
785 __le64 db_blkno; /* Offset on disk, in blocks */
786 /*30*/ __le64 db_parent_dinode; /* dinode which owns me, in
788 struct ocfs2_block_check db_check; /* Error checking */
793 * A directory entry in the indexed tree. We don't store the full name here,
794 * but instead provide a pointer to the full dirent in the unindexed tree.
796 * We also store name_len here so as to reduce the number of leaf blocks we
797 * need to search in case of collisions.
799 struct ocfs2_dx_entry {
800 __le32 dx_major_hash; /* Used to find logical
801 * cluster in index */
802 __le32 dx_minor_hash; /* Lower bits used to find
803 * block in cluster */
804 __le64 dx_dirent_blk; /* Physical block in unindexed
805 * tree holding this dirent. */
808 struct ocfs2_dx_entry_list {
810 __le16 de_count; /* Maximum number of entries
811 * possible in de_entries */
812 __le16 de_num_used; /* Current number of
813 * de_entries entries */
814 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
815 * in a packed array of
816 * length de_num_used */
819 #define OCFS2_DX_FLAG_INLINE 0x01
822 * A directory indexing block. Each indexed directory has one of these,
823 * pointed to by ocfs2_dinode.
825 * This block stores an indexed btree root, and a set of free space
826 * start-of-list pointers.
828 struct ocfs2_dx_root_block {
829 __u8 dr_signature[8]; /* Signature for verification */
830 struct ocfs2_block_check dr_check; /* Error checking */
831 __le16 dr_suballoc_slot; /* Slot suballocator this
832 * block belongs to. */
833 __le16 dr_suballoc_bit; /* Bit offset in suballocator
835 __le32 dr_fs_generation; /* Must match super block */
836 __le64 dr_blkno; /* Offset on disk, in blocks */
837 __le64 dr_last_eb_blk; /* Pointer to last
839 __le32 dr_clusters; /* Clusters allocated
840 * to the indexed tree. */
841 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
844 __le64 dr_dir_blkno; /* Pointer to parent inode */
845 __le32 dr_num_entries; /* Total number of
849 __le64 dr_free_blk; /* Pointer to head of free
850 * unindexed block list. */
851 __le64 dr_suballoc_loc; /* Suballocator block group
852 this root belongs to.
853 Only valid if allocated
856 __le64 dr_reserved3[14];
858 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
859 * bits for maximum space
861 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
862 * entries. We grow out
869 * The header of a leaf block in the indexed tree.
871 struct ocfs2_dx_leaf {
872 __u8 dl_signature[8];/* Signature for verification */
873 struct ocfs2_block_check dl_check; /* Error checking */
874 __le64 dl_blkno; /* Offset on disk, in blocks */
875 __le32 dl_fs_generation;/* Must match super block */
878 struct ocfs2_dx_entry_list dl_list;
882 * Largest bitmap for a block (suballocator) group in bytes. This limit
883 * does not affect cluster groups (global allocator). Cluster group
884 * bitmaps run to the end of the block.
886 #define OCFS2_MAX_BG_BITMAP_SIZE 256
889 * On disk allocator group structure for OCFS2
891 struct ocfs2_group_desc
893 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
894 __le16 bg_size; /* Size of included bitmap in
896 __le16 bg_bits; /* Bits represented by this
898 __le16 bg_free_bits_count; /* Free bits count */
899 __le16 bg_chain; /* What chain I am in. */
900 /*10*/ __le32 bg_generation;
902 __le64 bg_next_group; /* Next group in my list, in
904 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
906 __le64 bg_blkno; /* Offset on disk, in blocks */
907 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
913 * Block groups may be discontiguous when
914 * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
915 * The extents of a discontiguous block group are
916 * stored in bg_list. It is a flat list.
917 * l_tree_depth must always be zero. A
918 * discontiguous group is signified by a non-zero
919 * bg_list->l_next_free_rec. Only block groups
920 * can be discontiguous; Cluster groups cannot.
921 * We've never made a block group with more than
922 * 2048 blocks (256 bytes of bg_bitmap). This
923 * codifies that limit so that we can fit bg_list.
924 * bg_size of a discontiguous block group will
925 * be 256 to match bg_bitmap_filler.
927 __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
928 /*140*/ struct ocfs2_extent_list bg_list;
931 /* Actual on-disk size is one block */
934 struct ocfs2_refcount_rec {
935 /*00*/ __le64 r_cpos; /* Physical offset, in clusters */
936 __le32 r_clusters; /* Clusters covered by this extent */
937 __le32 r_refcount; /* Reference count of this extent */
940 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
942 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
943 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
945 struct ocfs2_refcount_list {
946 /*00*/ __le16 rl_count; /* Maximum number of entries possible
948 __le16 rl_used; /* Current number of used records */
950 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
951 /*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
955 struct ocfs2_refcount_block {
956 /*00*/ __u8 rf_signature[8]; /* Signature for verification */
957 __le16 rf_suballoc_slot; /* Slot suballocator this block
959 __le16 rf_suballoc_bit; /* Bit offset in suballocator
961 __le32 rf_fs_generation; /* Must match superblock */
962 /*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
963 __le64 rf_parent; /* Parent block, only valid if
964 OCFS2_REFCOUNT_LEAF_FL is set in
966 /*20*/ struct ocfs2_block_check rf_check; /* Error checking */
967 __le64 rf_last_eb_blk; /* Pointer to last extent block */
968 /*30*/ __le32 rf_count; /* Number of inodes sharing this
970 __le32 rf_flags; /* See the flags above */
971 __le32 rf_clusters; /* clusters covered by refcount tree. */
972 __le32 rf_cpos; /* cluster offset in refcount tree.*/
973 /*40*/ __le32 rf_generation; /* generation number. all be the same
974 * for the same refcount tree. */
976 __le64 rf_suballoc_loc; /* Suballocator block group this
977 refcount block belongs to. Only
978 valid if allocated from a
979 discontiguous block group */
980 /*50*/ __le64 rf_reserved1[6];
982 struct ocfs2_refcount_list rf_records; /* List of refcount
984 struct ocfs2_extent_list rf_list; /* Extent record list,
986 OCFS2_REFCOUNT_TREE_FL
987 is set in rf_flags */
989 /* Actual on-disk size is one block */
993 * On disk extended attribute structure for OCFS2.
997 * ocfs2_xattr_entry indicates one extend attribute.
999 * Note that it can be stored in inode, one block or one xattr bucket.
1001 struct ocfs2_xattr_entry {
1002 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
1003 __le16 xe_name_offset; /* byte offset from the 1st entry in the
1004 local xattr storage(inode, xattr block or
1006 __u8 xe_name_len; /* xattr name len, doesn't include prefix. */
1007 __u8 xe_type; /* the low 7 bits indicate the name prefix
1008 * type and the highest bit indicates whether
1009 * the EA is stored in the local storage. */
1010 __le64 xe_value_size; /* real xattr value length. */
1014 * On disk structure for xattr header.
1016 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
1017 * the local xattr storage.
1019 struct ocfs2_xattr_header {
1020 __le16 xh_count; /* contains the count of how
1021 many records are in the
1022 local xattr storage. */
1023 __le16 xh_free_start; /* current offset for storing
1025 __le16 xh_name_value_len; /* total length of name/value
1026 length in this bucket. */
1027 __le16 xh_num_buckets; /* Number of xattr buckets
1028 in this extent record,
1029 only valid in the first
1031 struct ocfs2_block_check xh_check; /* Error checking
1034 buckets. A block uses
1036 this field to zero.) */
1037 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
1041 * On disk structure for xattr value root.
1043 * When an xattr's value is large enough, it is stored in an external
1044 * b-tree like file data. The xattr value root points to this structure.
1046 struct ocfs2_xattr_value_root {
1047 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
1048 __le32 xr_reserved0;
1049 __le64 xr_last_eb_blk; /* Pointer to last extent block */
1050 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
1054 * On disk structure for xattr tree root.
1056 * It is used when there are too many extended attributes for one file. These
1057 * attributes will be organized and stored in an indexed-btree.
1059 struct ocfs2_xattr_tree_root {
1060 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
1061 __le32 xt_reserved0;
1062 __le64 xt_last_eb_blk; /* Pointer to last extent block */
1063 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
1066 #define OCFS2_XATTR_INDEXED 0x1
1067 #define OCFS2_HASH_SHIFT 5
1068 #define OCFS2_XATTR_ROUND 3
1069 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1070 ~(OCFS2_XATTR_ROUND))
1072 #define OCFS2_XATTR_BUCKET_SIZE 4096
1073 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1074 / OCFS2_MIN_BLOCKSIZE)
1077 * On disk structure for xattr block.
1079 struct ocfs2_xattr_block {
1080 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
1081 __le16 xb_suballoc_slot; /* Slot suballocator this
1082 block belongs to. */
1083 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1085 __le32 xb_fs_generation; /* Must match super block */
1086 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
1087 struct ocfs2_block_check xb_check; /* Error checking */
1088 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
1089 real xattr or a xattr tree. */
1090 __le16 xb_reserved0;
1091 __le32 xb_reserved1;
1092 __le64 xb_suballoc_loc; /* Suballocator block group this
1093 xattr block belongs to. Only
1094 valid if allocated from a
1095 discontiguous block group */
1097 struct ocfs2_xattr_header xb_header; /* xattr header if this
1098 block contains xattr */
1099 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1105 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1106 #define OCFS2_XATTR_TYPE_MASK 0x7F
1107 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1111 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1113 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1116 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1118 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1121 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1123 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1126 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1128 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1132 * On disk structures for global quota file
1135 /* Magic numbers and known versions for global quota files */
1136 #define OCFS2_GLOBAL_QMAGICS {\
1137 0x0cf52470, /* USRQUOTA */ \
1138 0x0cf52471 /* GRPQUOTA */ \
1141 #define OCFS2_GLOBAL_QVERSIONS {\
1147 /* Each block of each quota file has a certain fixed number of bytes reserved
1148 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1149 * checksums, etc. */
1150 #define OCFS2_QBLK_RESERVED_SPACE 8
1152 /* Generic header of all quota files */
1153 struct ocfs2_disk_dqheader {
1154 __le32 dqh_magic; /* Magic number identifying file */
1155 __le32 dqh_version; /* Quota format version */
1158 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1160 /* Information header of global quota file (immediately follows the generic
1162 struct ocfs2_global_disk_dqinfo {
1163 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1164 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1165 __le32 dqi_syncms; /* Time after which we sync local changes to
1166 * global quota file */
1167 __le32 dqi_blocks; /* Number of blocks in quota file */
1168 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1169 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1173 /* Structure with global user / group information. We reserve some space
1174 * for future use. */
1175 struct ocfs2_global_disk_dqblk {
1176 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
1177 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1178 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1179 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1180 __le64 dqb_curinodes; /* current # allocated inodes */
1181 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1182 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1183 /*30*/ __le64 dqb_curspace; /* current space occupied */
1184 __le64 dqb_btime; /* time limit for excessive disk use */
1185 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1187 /*50*/ __le64 dqb_pad2;
1191 * On-disk structures for local quota file
1194 /* Magic numbers and known versions for local quota files */
1195 #define OCFS2_LOCAL_QMAGICS {\
1196 0x0cf524c0, /* USRQUOTA */ \
1197 0x0cf524c1 /* GRPQUOTA */ \
1200 #define OCFS2_LOCAL_QVERSIONS {\
1205 /* Quota flags in dqinfo header */
1206 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1207 * quota has been cleanly turned off) */
1209 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1211 /* Information header of local quota file (immediately follows the generic
1213 struct ocfs2_local_disk_dqinfo {
1214 __le32 dqi_flags; /* Flags for quota file */
1215 __le32 dqi_chunks; /* Number of chunks of quota structures
1217 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1220 /* Header of one chunk of a quota file */
1221 struct ocfs2_local_disk_chunk {
1222 __le32 dqc_free; /* Number of free entries in the bitmap */
1223 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1224 * chunk of quota file */
1227 /* One entry in local quota file */
1228 struct ocfs2_local_disk_dqblk {
1229 /*00*/ __le64 dqb_id; /* id this quota applies to */
1230 __le64 dqb_spacemod; /* Change in the amount of used space */
1231 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1236 * The quota trailer lives at the end of each quota block.
1239 struct ocfs2_disk_dqtrailer {
1240 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1241 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1244 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1248 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1250 return (struct ocfs2_disk_dqtrailer *)ptr;
1254 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1256 return sb->s_blocksize -
1257 offsetof(struct ocfs2_dinode, id2.i_symlink);
1260 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1261 struct ocfs2_dinode *di)
1263 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1265 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1266 return sb->s_blocksize -
1267 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1270 return sb->s_blocksize -
1271 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1274 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1278 size = sb->s_blocksize -
1279 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1281 return size / sizeof(struct ocfs2_extent_rec);
1284 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1285 struct super_block *sb,
1286 struct ocfs2_dinode *di)
1289 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1291 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1292 size = sb->s_blocksize -
1293 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1296 size = sb->s_blocksize -
1297 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1299 return size / sizeof(struct ocfs2_extent_rec);
1302 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1306 size = sb->s_blocksize -
1307 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1309 return size / sizeof(struct ocfs2_extent_rec);
1312 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1316 size = sb->s_blocksize -
1317 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1319 return size / sizeof(struct ocfs2_chain_rec);
1322 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1326 size = sb->s_blocksize -
1327 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1329 return size / sizeof(struct ocfs2_extent_rec);
1332 static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1336 size = sb->s_blocksize -
1337 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1339 return size / sizeof(struct ocfs2_extent_rec);
1342 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1346 size = sb->s_blocksize -
1347 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1349 return size / sizeof(struct ocfs2_dx_entry);
1352 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1356 size = sb->s_blocksize -
1357 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1359 return size / sizeof(struct ocfs2_dx_entry);
1362 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1366 size = sb->s_blocksize -
1367 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1372 static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1374 u32 feature_incompat)
1376 int size = sb->s_blocksize -
1377 offsetof(struct ocfs2_group_desc, bg_bitmap);
1380 * The cluster allocator uses the entire block. Suballocators have
1381 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1382 * code expects bg_size set to the maximum. Thus we must keep
1383 * bg_size as-is unless discontig_bg is enabled.
1386 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1387 size = OCFS2_MAX_BG_BITMAP_SIZE;
1392 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1396 size = sb->s_blocksize -
1397 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1399 return size / sizeof(struct ocfs2_truncate_rec);
1402 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1404 u64 offset = OCFS2_BACKUP_SB_START;
1406 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1407 offset <<= (2 * index);
1408 offset >>= sb->s_blocksize_bits;
1416 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1420 size = sb->s_blocksize -
1421 offsetof(struct ocfs2_xattr_block,
1422 xb_attrs.xb_root.xt_list.l_recs);
1424 return size / sizeof(struct ocfs2_extent_rec);
1427 static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1431 size = sb->s_blocksize -
1432 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1434 return size / sizeof(struct ocfs2_extent_rec);
1437 static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1441 size = sb->s_blocksize -
1442 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1444 return size / sizeof(struct ocfs2_refcount_rec);
1448 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1450 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1453 static inline int ocfs2_fast_symlink_chars(int blocksize)
1455 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1458 static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1459 struct ocfs2_dinode *di)
1461 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1463 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1464 di->i_xattr_inline_size;
1467 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1470 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1475 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1477 return size / sizeof(struct ocfs2_extent_rec);
1480 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1485 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1487 return size / sizeof(struct ocfs2_chain_rec);
1490 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1495 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1497 return size / sizeof(struct ocfs2_extent_rec);
1500 static inline int ocfs2_extent_recs_per_gd(int blocksize)
1505 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1507 return size / sizeof(struct ocfs2_extent_rec);
1510 static inline int ocfs2_local_alloc_size(int blocksize)
1515 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1520 static inline int ocfs2_group_bitmap_size(int blocksize,
1522 uint32_t feature_incompat)
1524 int size = sb->s_blocksize -
1525 offsetof(struct ocfs2_group_desc, bg_bitmap);
1528 * The cluster allocator uses the entire block. Suballocators have
1529 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1530 * code expects bg_size set to the maximum. Thus we must keep
1531 * bg_size as-is unless discontig_bg is enabled.
1534 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1535 size = OCFS2_MAX_BG_BITMAP_SIZE;
1540 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1545 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1547 return size / sizeof(struct ocfs2_truncate_rec);
1550 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1552 uint64_t offset = OCFS2_BACKUP_SB_START;
1554 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1555 offset <<= (2 * index);
1556 offset /= blocksize;
1563 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1568 offsetof(struct ocfs2_xattr_block,
1569 xb_attrs.xb_root.xt_list.l_recs);
1571 return size / sizeof(struct ocfs2_extent_rec);
1573 #endif /* __KERNEL__ */
1576 static inline int ocfs2_system_inode_is_global(int type)
1578 return ((type >= 0) &&
1579 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1582 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1588 * Global system inodes can only have one copy. Everything
1589 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1590 * list has a copy per slot.
1592 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1593 chars = snprintf(buf, len, "%s",
1594 ocfs2_system_inodes[type].si_name);
1596 chars = snprintf(buf, len,
1597 ocfs2_system_inodes[type].si_name,
1603 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1606 de->file_type = fs_umode_to_ftype(mode);
1609 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1611 if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1612 le16_to_cpu(gd->bg_size)) !=
1613 offsetof(struct ocfs2_group_desc, bg_list))
1616 * Only valid to check l_next_free_rec if
1617 * bg_bitmap + bg_size == bg_list.
1619 if (!gd->bg_list.l_next_free_rec)
1623 #endif /* _OCFS2_FS_H */