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.
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
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
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
277 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
278 * counted in an associated
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 {
330 /* System file index */
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 ORPHAN_DIR_SYSTEM_INODE,
342 EXTENT_ALLOC_SYSTEM_INODE,
343 INODE_ALLOC_SYSTEM_INODE,
344 JOURNAL_SYSTEM_INODE,
345 LOCAL_ALLOC_SYSTEM_INODE,
346 TRUNCATE_LOG_SYSTEM_INODE,
347 LOCAL_USER_QUOTA_SYSTEM_INODE,
348 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
352 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
353 /* Global system inodes (single copy) */
354 /* The first two are only used from userspace mfks/tunefs */
355 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
356 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
358 /* These are used by the running filesystem */
359 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
360 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
361 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
362 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
363 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
365 /* Slot-specific system inodes (one copy per slot) */
366 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
367 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
368 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
369 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
370 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
371 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
372 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
373 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
376 /* Parameter passed from mount.ocfs2 to module */
377 #define OCFS2_HB_NONE "heartbeat=none"
378 #define OCFS2_HB_LOCAL "heartbeat=local"
379 #define OCFS2_HB_GLOBAL "heartbeat=global"
382 * OCFS2 directory file types. Only the low 3 bits are used. The
383 * other bits are reserved for now.
385 #define OCFS2_FT_UNKNOWN 0
386 #define OCFS2_FT_REG_FILE 1
387 #define OCFS2_FT_DIR 2
388 #define OCFS2_FT_CHRDEV 3
389 #define OCFS2_FT_BLKDEV 4
390 #define OCFS2_FT_FIFO 5
391 #define OCFS2_FT_SOCK 6
392 #define OCFS2_FT_SYMLINK 7
394 #define OCFS2_FT_MAX 8
397 * OCFS2_DIR_PAD defines the directory entries boundaries
399 * NOTE: It must be a multiple of 4
401 #define OCFS2_DIR_PAD 4
402 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
403 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
404 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
407 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
409 #define OCFS2_LINK_MAX 32000
410 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
411 #define OCFS2_LINKS_HI_SHIFT 16
412 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
415 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
416 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
417 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
418 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
419 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
420 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
421 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
422 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
429 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
432 * Block checking structure. This is used in metadata to validate the
433 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
436 struct ocfs2_block_check {
437 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
438 __le16 bc_ecc; /* Single-error-correction parity vector.
439 This is a simple Hamming code dependant
440 on the blocksize. OCFS2's maximum
441 blocksize, 4K, requires 16 parity bits,
442 so we fit in __le16. */
448 * On disk extent record for OCFS2
449 * It describes a range of clusters on disk.
451 * Length fields are divided into interior and leaf node versions.
452 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
454 struct ocfs2_extent_rec {
455 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
457 __le32 e_int_clusters; /* Clusters covered by all children */
459 __le16 e_leaf_clusters; /* Clusters covered by this
462 __u8 e_flags; /* Extent flags */
465 __le64 e_blkno; /* Physical disk offset, in blocks */
469 struct ocfs2_chain_rec {
470 __le32 c_free; /* Number of free bits in this chain. */
471 __le32 c_total; /* Number of total bits in this chain */
472 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
475 struct ocfs2_truncate_rec {
476 __le32 t_start; /* 1st cluster in this log */
477 __le32 t_clusters; /* Number of total clusters covered */
481 * On disk extent list for OCFS2 (node in the tree). Note that this
482 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
483 * offsets are relative to ocfs2_dinode.id2.i_list or
484 * ocfs2_extent_block.h_list, respectively.
486 struct ocfs2_extent_list {
487 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
488 point. 0 means data extents
489 hang directly off this
491 NOTE: The high 8 bits cannot be
492 used - tree_depth is never that big.
494 __le16 l_count; /* Number of extent records */
495 __le16 l_next_free_rec; /* Next unused extent slot */
497 __le64 l_reserved2; /* Pad to
498 sizeof(ocfs2_extent_rec) */
499 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
503 * On disk allocation chain list for OCFS2. Note that this is
504 * contained inside ocfs2_dinode, so the offsets are relative to
505 * ocfs2_dinode.id2.i_chain.
507 struct ocfs2_chain_list {
508 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
509 __le16 cl_bpc; /* Bits per cluster */
510 __le16 cl_count; /* Total chains in this list */
511 __le16 cl_next_free_rec; /* Next unused chain slot */
513 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
517 * On disk deallocation log for OCFS2. Note that this is
518 * contained inside ocfs2_dinode, so the offsets are relative to
519 * ocfs2_dinode.id2.i_dealloc.
521 struct ocfs2_truncate_log {
522 /*00*/ __le16 tl_count; /* Total records in this log */
523 __le16 tl_used; /* Number of records in use */
525 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
529 * On disk extent block (indirect block) for OCFS2
531 struct ocfs2_extent_block
533 /*00*/ __u8 h_signature[8]; /* Signature for verification */
534 struct ocfs2_block_check h_check; /* Error checking */
535 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
536 extent_header belongs to */
537 __le16 h_suballoc_bit; /* Bit offset in suballocator
539 __le32 h_fs_generation; /* Must match super block */
540 __le64 h_blkno; /* Offset on disk, in blocks */
541 /*20*/ __le64 h_suballoc_loc; /* Suballocator block group this
542 eb belongs to. Only valid
544 discontiguous block group */
545 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
546 of next leaf header pointing
548 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
549 /* Actual on-disk size is one block */
553 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
554 * system file. A slot is valid if it contains a node number >= 0. The
555 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
557 struct ocfs2_slot_map {
558 /*00*/ __le16 sm_slots[0];
560 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
561 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
565 struct ocfs2_extended_slot {
566 /*00*/ __u8 es_valid;
567 __u8 es_reserved1[3];
573 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
574 * is set. It separates out the valid marker from the node number, and
575 * has room to grow. Unlike the old slot map, this format is defined by
578 struct ocfs2_slot_map_extended {
579 /*00*/ struct ocfs2_extended_slot se_slots[0];
581 * Actual size is i_size of the slot_map system file. It should
582 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
587 * ci_stackflags is only valid if the incompat bit
588 * OCFS2_FEATURE_INCOMPAT_CLUSTERINFO is set.
590 struct ocfs2_cluster_info {
591 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
601 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
606 * On disk superblock for OCFS2
607 * Note that it is contained inside an ocfs2_dinode, so all offsets
608 * are relative to the start of ocfs2_dinode.id2.
610 struct ocfs2_super_block {
611 /*00*/ __le16 s_major_rev_level;
612 __le16 s_minor_rev_level;
614 __le16 s_max_mnt_count;
615 __le16 s_state; /* File system state */
616 __le16 s_errors; /* Behaviour when detecting errors */
617 __le32 s_checkinterval; /* Max time between checks */
618 /*10*/ __le64 s_lastcheck; /* Time of last check */
619 __le32 s_creator_os; /* OS */
620 __le32 s_feature_compat; /* Compatible feature set */
621 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
622 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
623 __le64 s_root_blkno; /* Offset, in blocks, of root directory
625 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
627 __le32 s_blocksize_bits; /* Blocksize for this fs */
628 __le32 s_clustersize_bits; /* Clustersize for this fs */
629 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
630 before tunefs required */
631 __le16 s_tunefs_flag;
632 __le32 s_uuid_hash; /* hash value of uuid */
633 __le64 s_first_cluster_group; /* Block offset of 1st cluster
635 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
636 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
637 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Only valid if either
638 userspace or clusterinfo
639 INCOMPAT flag set. */
640 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
643 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
644 * s_uuid_hash serves as seed[3]. */
645 /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
649 * NOTE: As stated above, all offsets are relative to
650 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
651 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
652 * our smallest blocksize, which is 512 bytes. To ensure this,
653 * we reserve the space in s_reserved2. Anything past s_reserved2
654 * will not be available on the smallest blocksize.
659 * Local allocation bitmap for OCFS2 slots
660 * Note that it exists inside an ocfs2_dinode, so all offsets are
661 * relative to the start of ocfs2_dinode.id2.
663 struct ocfs2_local_alloc
665 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
666 __le16 la_size; /* Size of included bitmap, in bytes */
669 /*10*/ __u8 la_bitmap[0];
673 * Data-in-inode header. This is only used if i_dyn_features has
674 * OCFS2_INLINE_DATA_FL set.
676 struct ocfs2_inline_data
678 /*00*/ __le16 id_count; /* Number of bytes that can be used
679 * for data, starting at id_data */
682 __u8 id_data[0]; /* Start of user data */
686 * On disk inode for OCFS2
688 struct ocfs2_dinode {
689 /*00*/ __u8 i_signature[8]; /* Signature for validation */
690 __le32 i_generation; /* Generation number */
691 __le16 i_suballoc_slot; /* Slot suballocator this inode
693 __le16 i_suballoc_bit; /* Bit offset in suballocator
695 /*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
696 __le16 i_xattr_inline_size;
697 __le32 i_clusters; /* Cluster count */
698 __le32 i_uid; /* Owner UID */
699 __le32 i_gid; /* Owning GID */
700 /*20*/ __le64 i_size; /* Size in bytes */
701 __le16 i_mode; /* File mode */
702 __le16 i_links_count; /* Links count */
703 __le32 i_flags; /* File flags */
704 /*30*/ __le64 i_atime; /* Access time */
705 __le64 i_ctime; /* Creation time */
706 /*40*/ __le64 i_mtime; /* Modification time */
707 __le64 i_dtime; /* Deletion time */
708 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
709 __le64 i_last_eb_blk; /* Pointer to last extent
711 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
715 /*70*/ __le32 i_attr;
716 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
717 was set in i_flags */
718 __le16 i_dyn_features;
720 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
721 /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
722 /*90*/ __le64 i_refcount_loc;
723 __le64 i_suballoc_loc; /* Suballocator block group this
724 inode belongs to. Only valid
726 discontiguous block group */
727 /*A0*/ __le64 i_reserved2[3];
729 __le64 i_pad1; /* Generic way to refer to this
732 __le64 i_rdev; /* Device number */
734 struct { /* Info for bitmap system
736 __le32 i_used; /* Bits (ie, clusters) used */
737 __le32 i_total; /* Total bits (clusters)
740 struct { /* Info for journal system
742 __le32 ij_flags; /* Mounted, version, etc. */
743 __le32 ij_recovery_generation; /* Incremented when the
748 } id1; /* Inode type dependant 1 */
750 struct ocfs2_super_block i_super;
751 struct ocfs2_local_alloc i_lab;
752 struct ocfs2_chain_list i_chain;
753 struct ocfs2_extent_list i_list;
754 struct ocfs2_truncate_log i_dealloc;
755 struct ocfs2_inline_data i_data;
758 /* Actual on-disk size is one block */
762 * On-disk directory entry structure for OCFS2
764 * Packed as this structure could be accessed unaligned on 64-bit platforms
766 struct ocfs2_dir_entry {
767 /*00*/ __le64 inode; /* Inode number */
768 __le16 rec_len; /* Directory entry length */
769 __u8 name_len; /* Name length */
771 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
772 /* Actual on-disk length specified by rec_len */
773 } __attribute__ ((packed));
776 * Per-block record for the unindexed directory btree. This is carefully
777 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
778 * mirrored. That way, the directory manipulation code needs a minimal amount
781 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
783 struct ocfs2_dir_block_trailer {
784 /*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
786 __le16 db_compat_rec_len; /* Backwards compatible with
787 * ocfs2_dir_entry. */
788 __u8 db_compat_name_len; /* Always zero. Was name_len */
791 __le16 db_free_rec_len; /* Size of largest empty hole
792 * in this block. (unused) */
793 /*10*/ __u8 db_signature[8]; /* Signature for verification */
795 __le64 db_free_next; /* Next block in list (unused) */
796 /*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
797 __le64 db_parent_dinode; /* dinode which owns me, in
799 /*30*/ struct ocfs2_block_check db_check; /* Error checking */
804 * A directory entry in the indexed tree. We don't store the full name here,
805 * but instead provide a pointer to the full dirent in the unindexed tree.
807 * We also store name_len here so as to reduce the number of leaf blocks we
808 * need to search in case of collisions.
810 struct ocfs2_dx_entry {
811 __le32 dx_major_hash; /* Used to find logical
812 * cluster in index */
813 __le32 dx_minor_hash; /* Lower bits used to find
814 * block in cluster */
815 __le64 dx_dirent_blk; /* Physical block in unindexed
816 * tree holding this dirent. */
819 struct ocfs2_dx_entry_list {
821 __le16 de_count; /* Maximum number of entries
822 * possible in de_entries */
823 __le16 de_num_used; /* Current number of
824 * de_entries entries */
825 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
826 * in a packed array of
827 * length de_num_used */
830 #define OCFS2_DX_FLAG_INLINE 0x01
833 * A directory indexing block. Each indexed directory has one of these,
834 * pointed to by ocfs2_dinode.
836 * This block stores an indexed btree root, and a set of free space
837 * start-of-list pointers.
839 struct ocfs2_dx_root_block {
840 __u8 dr_signature[8]; /* Signature for verification */
841 struct ocfs2_block_check dr_check; /* Error checking */
842 __le16 dr_suballoc_slot; /* Slot suballocator this
843 * block belongs to. */
844 __le16 dr_suballoc_bit; /* Bit offset in suballocator
846 __le32 dr_fs_generation; /* Must match super block */
847 __le64 dr_blkno; /* Offset on disk, in blocks */
848 __le64 dr_last_eb_blk; /* Pointer to last
850 __le32 dr_clusters; /* Clusters allocated
851 * to the indexed tree. */
852 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
855 __le64 dr_dir_blkno; /* Pointer to parent inode */
856 __le32 dr_num_entries; /* Total number of
860 __le64 dr_free_blk; /* Pointer to head of free
861 * unindexed block list. */
862 __le64 dr_suballoc_loc; /* Suballocator block group
863 this root belongs to.
864 Only valid if allocated
867 __le64 dr_reserved3[14];
869 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
870 * bits for maximum space
872 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
873 * entries. We grow out
880 * The header of a leaf block in the indexed tree.
882 struct ocfs2_dx_leaf {
883 __u8 dl_signature[8];/* Signature for verification */
884 struct ocfs2_block_check dl_check; /* Error checking */
885 __le64 dl_blkno; /* Offset on disk, in blocks */
886 __le32 dl_fs_generation;/* Must match super block */
889 struct ocfs2_dx_entry_list dl_list;
893 * Largest bitmap for a block (suballocator) group in bytes. This limit
894 * does not affect cluster groups (global allocator). Cluster group
895 * bitmaps run to the end of the block.
897 #define OCFS2_MAX_BG_BITMAP_SIZE 256
900 * On disk allocator group structure for OCFS2
902 struct ocfs2_group_desc
904 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
905 __le16 bg_size; /* Size of included bitmap in
907 __le16 bg_bits; /* Bits represented by this
909 __le16 bg_free_bits_count; /* Free bits count */
910 __le16 bg_chain; /* What chain I am in. */
911 /*10*/ __le32 bg_generation;
913 __le64 bg_next_group; /* Next group in my list, in
915 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
917 __le64 bg_blkno; /* Offset on disk, in blocks */
918 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
924 * Block groups may be discontiguous when
925 * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
926 * The extents of a discontigous block group are
927 * stored in bg_list. It is a flat list.
928 * l_tree_depth must always be zero. A
929 * discontiguous group is signified by a non-zero
930 * bg_list->l_next_free_rec. Only block groups
931 * can be discontiguous; Cluster groups cannot.
932 * We've never made a block group with more than
933 * 2048 blocks (256 bytes of bg_bitmap). This
934 * codifies that limit so that we can fit bg_list.
935 * bg_size of a discontiguous block group will
936 * be 256 to match bg_bitmap_filler.
938 __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
939 /*140*/ struct ocfs2_extent_list bg_list;
942 /* Actual on-disk size is one block */
945 struct ocfs2_refcount_rec {
946 /*00*/ __le64 r_cpos; /* Physical offset, in clusters */
947 __le32 r_clusters; /* Clusters covered by this extent */
948 __le32 r_refcount; /* Reference count of this extent */
951 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
953 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
954 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
956 struct ocfs2_refcount_list {
957 /*00*/ __le16 rl_count; /* Maximum number of entries possible
959 __le16 rl_used; /* Current number of used records */
961 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
962 /*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
966 struct ocfs2_refcount_block {
967 /*00*/ __u8 rf_signature[8]; /* Signature for verification */
968 __le16 rf_suballoc_slot; /* Slot suballocator this block
970 __le16 rf_suballoc_bit; /* Bit offset in suballocator
972 __le32 rf_fs_generation; /* Must match superblock */
973 /*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
974 __le64 rf_parent; /* Parent block, only valid if
975 OCFS2_REFCOUNT_LEAF_FL is set in
977 /*20*/ struct ocfs2_block_check rf_check; /* Error checking */
978 __le64 rf_last_eb_blk; /* Pointer to last extent block */
979 /*30*/ __le32 rf_count; /* Number of inodes sharing this
981 __le32 rf_flags; /* See the flags above */
982 __le32 rf_clusters; /* clusters covered by refcount tree. */
983 __le32 rf_cpos; /* cluster offset in refcount tree.*/
984 /*40*/ __le32 rf_generation; /* generation number. all be the same
985 * for the same refcount tree. */
987 __le64 rf_suballoc_loc; /* Suballocator block group this
988 refcount block belongs to. Only
989 valid if allocated from a
990 discontiguous block group */
991 /*50*/ __le64 rf_reserved1[6];
993 struct ocfs2_refcount_list rf_records; /* List of refcount
995 struct ocfs2_extent_list rf_list; /* Extent record list,
997 OCFS2_REFCOUNT_TREE_FL
998 is set in rf_flags */
1000 /* Actual on-disk size is one block */
1004 * On disk extended attribute structure for OCFS2.
1008 * ocfs2_xattr_entry indicates one extend attribute.
1010 * Note that it can be stored in inode, one block or one xattr bucket.
1012 struct ocfs2_xattr_entry {
1013 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
1014 __le16 xe_name_offset; /* byte offset from the 1st entry in the
1015 local xattr storage(inode, xattr block or
1017 __u8 xe_name_len; /* xattr name len, does't include prefix. */
1018 __u8 xe_type; /* the low 7 bits indicate the name prefix
1019 * type and the highest bit indicates whether
1020 * the EA is stored in the local storage. */
1021 __le64 xe_value_size; /* real xattr value length. */
1025 * On disk structure for xattr header.
1027 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
1028 * the local xattr storage.
1030 struct ocfs2_xattr_header {
1031 __le16 xh_count; /* contains the count of how
1032 many records are in the
1033 local xattr storage. */
1034 __le16 xh_free_start; /* current offset for storing
1036 __le16 xh_name_value_len; /* total length of name/value
1037 length in this bucket. */
1038 __le16 xh_num_buckets; /* Number of xattr buckets
1039 in this extent record,
1040 only valid in the first
1042 struct ocfs2_block_check xh_check; /* Error checking
1045 buckets. A block uses
1047 this field to zero.) */
1048 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
1052 * On disk structure for xattr value root.
1054 * When an xattr's value is large enough, it is stored in an external
1055 * b-tree like file data. The xattr value root points to this structure.
1057 struct ocfs2_xattr_value_root {
1058 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
1059 __le32 xr_reserved0;
1060 __le64 xr_last_eb_blk; /* Pointer to last extent block */
1061 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
1065 * On disk structure for xattr tree root.
1067 * It is used when there are too many extended attributes for one file. These
1068 * attributes will be organized and stored in an indexed-btree.
1070 struct ocfs2_xattr_tree_root {
1071 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
1072 __le32 xt_reserved0;
1073 __le64 xt_last_eb_blk; /* Pointer to last extent block */
1074 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
1077 #define OCFS2_XATTR_INDEXED 0x1
1078 #define OCFS2_HASH_SHIFT 5
1079 #define OCFS2_XATTR_ROUND 3
1080 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1081 ~(OCFS2_XATTR_ROUND))
1083 #define OCFS2_XATTR_BUCKET_SIZE 4096
1084 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1085 / OCFS2_MIN_BLOCKSIZE)
1088 * On disk structure for xattr block.
1090 struct ocfs2_xattr_block {
1091 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
1092 __le16 xb_suballoc_slot; /* Slot suballocator this
1093 block belongs to. */
1094 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1096 __le32 xb_fs_generation; /* Must match super block */
1097 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
1098 struct ocfs2_block_check xb_check; /* Error checking */
1099 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
1100 real xattr or a xattr tree. */
1101 __le16 xb_reserved0;
1102 __le32 xb_reserved1;
1103 __le64 xb_suballoc_loc; /* Suballocator block group this
1104 xattr block belongs to. Only
1105 valid if allocated from a
1106 discontiguous block group */
1108 struct ocfs2_xattr_header xb_header; /* xattr header if this
1109 block contains xattr */
1110 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1116 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1117 #define OCFS2_XATTR_TYPE_MASK 0x7F
1118 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1122 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1124 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1127 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1129 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1132 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1134 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1137 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1139 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1143 * On disk structures for global quota file
1146 /* Magic numbers and known versions for global quota files */
1147 #define OCFS2_GLOBAL_QMAGICS {\
1148 0x0cf52470, /* USRQUOTA */ \
1149 0x0cf52471 /* GRPQUOTA */ \
1152 #define OCFS2_GLOBAL_QVERSIONS {\
1158 /* Each block of each quota file has a certain fixed number of bytes reserved
1159 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1160 * checksums, etc. */
1161 #define OCFS2_QBLK_RESERVED_SPACE 8
1163 /* Generic header of all quota files */
1164 struct ocfs2_disk_dqheader {
1165 __le32 dqh_magic; /* Magic number identifying file */
1166 __le32 dqh_version; /* Quota format version */
1169 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1171 /* Information header of global quota file (immediately follows the generic
1173 struct ocfs2_global_disk_dqinfo {
1174 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1175 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1176 __le32 dqi_syncms; /* Time after which we sync local changes to
1177 * global quota file */
1178 __le32 dqi_blocks; /* Number of blocks in quota file */
1179 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1180 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1184 /* Structure with global user / group information. We reserve some space
1185 * for future use. */
1186 struct ocfs2_global_disk_dqblk {
1187 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
1188 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1189 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1190 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1191 __le64 dqb_curinodes; /* current # allocated inodes */
1192 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1193 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1194 /*30*/ __le64 dqb_curspace; /* current space occupied */
1195 __le64 dqb_btime; /* time limit for excessive disk use */
1196 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1198 /*50*/ __le64 dqb_pad2;
1202 * On-disk structures for local quota file
1205 /* Magic numbers and known versions for local quota files */
1206 #define OCFS2_LOCAL_QMAGICS {\
1207 0x0cf524c0, /* USRQUOTA */ \
1208 0x0cf524c1 /* GRPQUOTA */ \
1211 #define OCFS2_LOCAL_QVERSIONS {\
1216 /* Quota flags in dqinfo header */
1217 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1218 * quota has been cleanly turned off) */
1220 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1222 /* Information header of local quota file (immediately follows the generic
1224 struct ocfs2_local_disk_dqinfo {
1225 __le32 dqi_flags; /* Flags for quota file */
1226 __le32 dqi_chunks; /* Number of chunks of quota structures
1228 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1231 /* Header of one chunk of a quota file */
1232 struct ocfs2_local_disk_chunk {
1233 __le32 dqc_free; /* Number of free entries in the bitmap */
1234 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1235 * chunk of quota file */
1238 /* One entry in local quota file */
1239 struct ocfs2_local_disk_dqblk {
1240 /*00*/ __le64 dqb_id; /* id this quota applies to */
1241 __le64 dqb_spacemod; /* Change in the amount of used space */
1242 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1247 * The quota trailer lives at the end of each quota block.
1250 struct ocfs2_disk_dqtrailer {
1251 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1252 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1255 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1259 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1261 return (struct ocfs2_disk_dqtrailer *)ptr;
1265 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1267 return sb->s_blocksize -
1268 offsetof(struct ocfs2_dinode, id2.i_symlink);
1271 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1272 struct ocfs2_dinode *di)
1274 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1276 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1277 return sb->s_blocksize -
1278 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1281 return sb->s_blocksize -
1282 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1285 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1289 size = sb->s_blocksize -
1290 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1292 return size / sizeof(struct ocfs2_extent_rec);
1295 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1296 struct super_block *sb,
1297 struct ocfs2_dinode *di)
1300 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1302 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1303 size = sb->s_blocksize -
1304 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1307 size = sb->s_blocksize -
1308 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1310 return size / sizeof(struct ocfs2_extent_rec);
1313 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1317 size = sb->s_blocksize -
1318 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1320 return size / sizeof(struct ocfs2_extent_rec);
1323 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1327 size = sb->s_blocksize -
1328 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1330 return size / sizeof(struct ocfs2_chain_rec);
1333 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1337 size = sb->s_blocksize -
1338 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1340 return size / sizeof(struct ocfs2_extent_rec);
1343 static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1347 size = sb->s_blocksize -
1348 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1350 return size / sizeof(struct ocfs2_extent_rec);
1353 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1357 size = sb->s_blocksize -
1358 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1360 return size / sizeof(struct ocfs2_dx_entry);
1363 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1367 size = sb->s_blocksize -
1368 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1370 return size / sizeof(struct ocfs2_dx_entry);
1373 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1377 size = sb->s_blocksize -
1378 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1383 static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1385 u32 feature_incompat)
1387 int size = sb->s_blocksize -
1388 offsetof(struct ocfs2_group_desc, bg_bitmap);
1391 * The cluster allocator uses the entire block. Suballocators have
1392 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1393 * code expects bg_size set to the maximum. Thus we must keep
1394 * bg_size as-is unless discontig_bg is enabled.
1397 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1398 size = OCFS2_MAX_BG_BITMAP_SIZE;
1403 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1407 size = sb->s_blocksize -
1408 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1410 return size / sizeof(struct ocfs2_truncate_rec);
1413 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1415 u64 offset = OCFS2_BACKUP_SB_START;
1417 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1418 offset <<= (2 * index);
1419 offset >>= sb->s_blocksize_bits;
1427 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1431 size = sb->s_blocksize -
1432 offsetof(struct ocfs2_xattr_block,
1433 xb_attrs.xb_root.xt_list.l_recs);
1435 return size / sizeof(struct ocfs2_extent_rec);
1438 static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1442 size = sb->s_blocksize -
1443 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1445 return size / sizeof(struct ocfs2_extent_rec);
1448 static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1452 size = sb->s_blocksize -
1453 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1455 return size / sizeof(struct ocfs2_refcount_rec);
1459 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1461 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1464 static inline int ocfs2_fast_symlink_chars(int blocksize)
1466 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1469 static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1470 struct ocfs2_dinode *di)
1472 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1474 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1475 di->i_xattr_inline_size;
1478 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1481 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1486 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1488 return size / sizeof(struct ocfs2_extent_rec);
1491 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1496 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1498 return size / sizeof(struct ocfs2_chain_rec);
1501 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1506 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1508 return size / sizeof(struct ocfs2_extent_rec);
1511 static inline int ocfs2_extent_recs_per_gd(int blocksize)
1516 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1518 return size / sizeof(struct ocfs2_extent_rec);
1521 static inline int ocfs2_local_alloc_size(int blocksize)
1526 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1531 static inline int ocfs2_group_bitmap_size(int blocksize,
1533 uint32_t feature_incompat)
1535 int size = sb->s_blocksize -
1536 offsetof(struct ocfs2_group_desc, bg_bitmap);
1539 * The cluster allocator uses the entire block. Suballocators have
1540 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1541 * code expects bg_size set to the maximum. Thus we must keep
1542 * bg_size as-is unless discontig_bg is enabled.
1545 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1546 size = OCFS2_MAX_BG_BITMAP_SIZE;
1551 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1556 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1558 return size / sizeof(struct ocfs2_truncate_rec);
1561 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1563 uint64_t offset = OCFS2_BACKUP_SB_START;
1565 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1566 offset <<= (2 * index);
1567 offset /= blocksize;
1574 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1579 offsetof(struct ocfs2_xattr_block,
1580 xb_attrs.xb_root.xt_list.l_recs);
1582 return size / sizeof(struct ocfs2_extent_rec);
1584 #endif /* __KERNEL__ */
1587 static inline int ocfs2_system_inode_is_global(int type)
1589 return ((type >= 0) &&
1590 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1593 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1599 * Global system inodes can only have one copy. Everything
1600 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1601 * list has a copy per slot.
1603 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1604 chars = snprintf(buf, len, "%s",
1605 ocfs2_system_inodes[type].si_name);
1607 chars = snprintf(buf, len,
1608 ocfs2_system_inodes[type].si_name,
1614 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1617 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1620 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1622 if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1623 le16_to_cpu(gd->bg_size)) !=
1624 offsetof(struct ocfs2_group_desc, bg_list))
1627 * Only valid to check l_next_free_rec if
1628 * bg_bitmap + bg_size == bg_list.
1630 if (!gd->bg_list.l_next_free_rec)
1634 #endif /* _OCFS2_FS_H */