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"
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 #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
102 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
103 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
106 * Heartbeat-only devices are missing journals and other files. The
107 * filesystem driver can't load them, but the library can. Never put
108 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
110 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
113 * tunefs sets this incompat flag before starting the resize and clears it
114 * at the end. This flag protects users from inadvertently mounting the fs
115 * after an aborted run without fsck-ing.
117 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
119 /* Used to denote a non-clustered volume */
120 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
122 /* Support for sparse allocation in b-trees */
123 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
126 * Tunefs sets this incompat flag before starting an operation which
127 * would require cleanup on abort. This is done to protect users from
128 * inadvertently mounting the fs after an aborted run without
131 * s_tunefs_flags on the super block describes precisely which
132 * operations were in progress.
134 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
136 /* Support for data packed into inode blocks */
137 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
140 * Support for alternate, userspace cluster stacks. If set, the superblock
141 * field s_cluster_info contains a tag for the alternate stack in use as
142 * well as the name of the cluster being joined.
143 * mount.ocfs2 must pass in a matching stack name.
145 * If not set, the classic stack will be used. This is compatbile with
146 * all older versions.
148 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
150 /* Support for the extended slot map */
151 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
153 /* Support for extended attributes */
154 #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
156 /* Support for indexed directores */
157 #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
159 /* Metadata checksum and error correction */
160 #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
163 * backup superblock flag is used to indicate that this volume
164 * has backup superblocks.
166 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
169 * The filesystem will correctly handle journal feature bits.
171 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
174 * Unwritten extents support.
176 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
179 * Maintain quota information for this filesystem
181 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
182 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
184 /* The byte offset of the first backup block will be 1G.
185 * The following will be 4G, 16G, 64G, 256G and 1T.
187 #define OCFS2_BACKUP_SB_START 1 << 30
189 /* the max backup superblock nums */
190 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
193 * Flags on ocfs2_super_block.s_tunefs_flags
195 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
198 * Flags on ocfs2_dinode.i_flags
200 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
201 #define OCFS2_UNUSED2_FL (0x00000002)
202 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
203 #define OCFS2_UNUSED3_FL (0x00000008)
204 /* System inode flags */
205 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
206 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
207 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
208 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
209 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
210 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
211 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
212 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
213 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
216 * Flags on ocfs2_dinode.i_dyn_features
218 * These can change much more often than i_flags. When adding flags,
219 * keep in mind that i_dyn_features is only 16 bits wide.
221 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
222 #define OCFS2_HAS_XATTR_FL (0x0002)
223 #define OCFS2_INLINE_XATTR_FL (0x0004)
224 #define OCFS2_INDEXED_DIR_FL (0x0008)
226 /* Inode attributes, keep in sync with EXT2 */
227 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
228 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
229 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
230 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
231 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
232 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
233 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
234 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
235 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
237 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
238 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
241 * Extent record flags (e_node.leaf.flags)
243 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
249 #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
250 #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
251 #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
252 #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
255 * Space reservation / allocation / free ioctls and argument structure
256 * are designed to be compatible with XFS.
258 * ALLOCSP* and FREESP* are not and will never be supported, but are
259 * included here for completeness.
261 struct ocfs2_space_resv {
265 __s64 l_len; /* len == 0 means until end of file */
268 __s32 l_pad[4]; /* reserve area */
271 #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
272 #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
273 #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
274 #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
275 #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
276 #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
277 #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
278 #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
280 /* Used to pass group descriptor data when online resize is done */
281 struct ocfs2_new_group_input {
282 __u64 group; /* Group descriptor's blkno. */
283 __u32 clusters; /* Total number of clusters in this group */
284 __u32 frees; /* Total free clusters in this group */
285 __u16 chain; /* Chain for this group */
290 #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
291 #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
292 #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
295 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
297 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
300 * superblock s_state flags
302 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
304 /* Limit of space in ocfs2_dir_entry */
305 #define OCFS2_MAX_FILENAME_LEN 255
307 /* Maximum slots on an ocfs2 file system */
308 #define OCFS2_MAX_SLOTS 255
310 /* Slot map indicator for an empty slot */
311 #define OCFS2_INVALID_SLOT -1
313 #define OCFS2_VOL_UUID_LEN 16
314 #define OCFS2_MAX_VOL_LABEL_LEN 64
316 /* The alternate, userspace stack fields */
317 #define OCFS2_STACK_LABEL_LEN 4
318 #define OCFS2_CLUSTER_NAME_LEN 16
320 /* Journal limits (in bytes) */
321 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
324 * Default local alloc size (in megabytes)
326 * The value chosen should be such that most allocations, including new
327 * block groups, use local alloc.
329 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
332 * Inline extended attribute size (in bytes)
333 * The value chosen should be aligned to 16 byte boundaries.
335 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
337 struct ocfs2_system_inode_info {
343 /* System file index */
345 BAD_BLOCK_SYSTEM_INODE = 0,
346 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
347 SLOT_MAP_SYSTEM_INODE,
348 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
349 HEARTBEAT_SYSTEM_INODE,
350 GLOBAL_BITMAP_SYSTEM_INODE,
351 USER_QUOTA_SYSTEM_INODE,
352 GROUP_QUOTA_SYSTEM_INODE,
353 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
354 ORPHAN_DIR_SYSTEM_INODE,
355 EXTENT_ALLOC_SYSTEM_INODE,
356 INODE_ALLOC_SYSTEM_INODE,
357 JOURNAL_SYSTEM_INODE,
358 LOCAL_ALLOC_SYSTEM_INODE,
359 TRUNCATE_LOG_SYSTEM_INODE,
360 LOCAL_USER_QUOTA_SYSTEM_INODE,
361 LOCAL_GROUP_QUOTA_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"
394 * OCFS2 directory file types. Only the low 3 bits are used. The
395 * other bits are reserved for now.
397 #define OCFS2_FT_UNKNOWN 0
398 #define OCFS2_FT_REG_FILE 1
399 #define OCFS2_FT_DIR 2
400 #define OCFS2_FT_CHRDEV 3
401 #define OCFS2_FT_BLKDEV 4
402 #define OCFS2_FT_FIFO 5
403 #define OCFS2_FT_SOCK 6
404 #define OCFS2_FT_SYMLINK 7
406 #define OCFS2_FT_MAX 8
409 * OCFS2_DIR_PAD defines the directory entries boundaries
411 * NOTE: It must be a multiple of 4
413 #define OCFS2_DIR_PAD 4
414 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
415 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
416 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
419 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
421 #define OCFS2_LINK_MAX 32000
424 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
425 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
426 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
427 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
428 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
429 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
430 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
431 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
438 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
441 * Block checking structure. This is used in metadata to validate the
442 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
445 struct ocfs2_block_check {
446 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
447 __le16 bc_ecc; /* Single-error-correction parity vector.
448 This is a simple Hamming code dependant
449 on the blocksize. OCFS2's maximum
450 blocksize, 4K, requires 16 parity bits,
451 so we fit in __le16. */
457 * On disk extent record for OCFS2
458 * It describes a range of clusters on disk.
460 * Length fields are divided into interior and leaf node versions.
461 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
463 struct ocfs2_extent_rec {
464 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
466 __le32 e_int_clusters; /* Clusters covered by all children */
468 __le16 e_leaf_clusters; /* Clusters covered by this
471 __u8 e_flags; /* Extent flags */
474 __le64 e_blkno; /* Physical disk offset, in blocks */
478 struct ocfs2_chain_rec {
479 __le32 c_free; /* Number of free bits in this chain. */
480 __le32 c_total; /* Number of total bits in this chain */
481 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
484 struct ocfs2_truncate_rec {
485 __le32 t_start; /* 1st cluster in this log */
486 __le32 t_clusters; /* Number of total clusters covered */
490 * On disk extent list for OCFS2 (node in the tree). Note that this
491 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
492 * offsets are relative to ocfs2_dinode.id2.i_list or
493 * ocfs2_extent_block.h_list, respectively.
495 struct ocfs2_extent_list {
496 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
497 point. 0 means data extents
498 hang directly off this
500 NOTE: The high 8 bits cannot be
501 used - tree_depth is never that big.
503 __le16 l_count; /* Number of extent records */
504 __le16 l_next_free_rec; /* Next unused extent slot */
506 __le64 l_reserved2; /* Pad to
507 sizeof(ocfs2_extent_rec) */
508 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
512 * On disk allocation chain list for OCFS2. Note that this is
513 * contained inside ocfs2_dinode, so the offsets are relative to
514 * ocfs2_dinode.id2.i_chain.
516 struct ocfs2_chain_list {
517 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
518 __le16 cl_bpc; /* Bits per cluster */
519 __le16 cl_count; /* Total chains in this list */
520 __le16 cl_next_free_rec; /* Next unused chain slot */
522 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
526 * On disk deallocation log for OCFS2. Note that this is
527 * contained inside ocfs2_dinode, so the offsets are relative to
528 * ocfs2_dinode.id2.i_dealloc.
530 struct ocfs2_truncate_log {
531 /*00*/ __le16 tl_count; /* Total records in this log */
532 __le16 tl_used; /* Number of records in use */
534 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
538 * On disk extent block (indirect block) for OCFS2
540 struct ocfs2_extent_block
542 /*00*/ __u8 h_signature[8]; /* Signature for verification */
543 struct ocfs2_block_check h_check; /* Error checking */
544 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
545 extent_header belongs to */
546 __le16 h_suballoc_bit; /* Bit offset in suballocator
548 __le32 h_fs_generation; /* Must match super block */
549 __le64 h_blkno; /* Offset on disk, in blocks */
550 /*20*/ __le64 h_reserved3;
551 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
552 of next leaf header pointing
554 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
555 /* Actual on-disk size is one block */
559 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
560 * system file. A slot is valid if it contains a node number >= 0. The
561 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
563 struct ocfs2_slot_map {
564 /*00*/ __le16 sm_slots[0];
566 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
567 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
571 struct ocfs2_extended_slot {
572 /*00*/ __u8 es_valid;
573 __u8 es_reserved1[3];
579 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
580 * is set. It separates out the valid marker from the node number, and
581 * has room to grow. Unlike the old slot map, this format is defined by
584 struct ocfs2_slot_map_extended {
585 /*00*/ struct ocfs2_extended_slot se_slots[0];
587 * Actual size is i_size of the slot_map system file. It should
588 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
592 struct ocfs2_cluster_info {
593 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
595 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
600 * On disk superblock for OCFS2
601 * Note that it is contained inside an ocfs2_dinode, so all offsets
602 * are relative to the start of ocfs2_dinode.id2.
604 struct ocfs2_super_block {
605 /*00*/ __le16 s_major_rev_level;
606 __le16 s_minor_rev_level;
608 __le16 s_max_mnt_count;
609 __le16 s_state; /* File system state */
610 __le16 s_errors; /* Behaviour when detecting errors */
611 __le32 s_checkinterval; /* Max time between checks */
612 /*10*/ __le64 s_lastcheck; /* Time of last check */
613 __le32 s_creator_os; /* OS */
614 __le32 s_feature_compat; /* Compatible feature set */
615 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
616 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
617 __le64 s_root_blkno; /* Offset, in blocks, of root directory
619 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
621 __le32 s_blocksize_bits; /* Blocksize for this fs */
622 __le32 s_clustersize_bits; /* Clustersize for this fs */
623 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
624 before tunefs required */
625 __le16 s_tunefs_flag;
626 __le32 s_uuid_hash; /* hash value of uuid */
627 __le64 s_first_cluster_group; /* Block offset of 1st cluster
629 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
630 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
631 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
633 with INCOMPAT flag. */
634 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
637 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
638 * s_uuid_hash serves as seed[3]. */
639 /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
643 * NOTE: As stated above, all offsets are relative to
644 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
645 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
646 * our smallest blocksize, which is 512 bytes. To ensure this,
647 * we reserve the space in s_reserved2. Anything past s_reserved2
648 * will not be available on the smallest blocksize.
653 * Local allocation bitmap for OCFS2 slots
654 * Note that it exists inside an ocfs2_dinode, so all offsets are
655 * relative to the start of ocfs2_dinode.id2.
657 struct ocfs2_local_alloc
659 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
660 __le16 la_size; /* Size of included bitmap, in bytes */
663 /*10*/ __u8 la_bitmap[0];
667 * Data-in-inode header. This is only used if i_dyn_features has
668 * OCFS2_INLINE_DATA_FL set.
670 struct ocfs2_inline_data
672 /*00*/ __le16 id_count; /* Number of bytes that can be used
673 * for data, starting at id_data */
676 __u8 id_data[0]; /* Start of user data */
680 * On disk inode for OCFS2
682 struct ocfs2_dinode {
683 /*00*/ __u8 i_signature[8]; /* Signature for validation */
684 __le32 i_generation; /* Generation number */
685 __le16 i_suballoc_slot; /* Slot suballocator this inode
687 __le16 i_suballoc_bit; /* Bit offset in suballocator
689 /*10*/ __le16 i_reserved0;
690 __le16 i_xattr_inline_size;
691 __le32 i_clusters; /* Cluster count */
692 __le32 i_uid; /* Owner UID */
693 __le32 i_gid; /* Owning GID */
694 /*20*/ __le64 i_size; /* Size in bytes */
695 __le16 i_mode; /* File mode */
696 __le16 i_links_count; /* Links count */
697 __le32 i_flags; /* File flags */
698 /*30*/ __le64 i_atime; /* Access time */
699 __le64 i_ctime; /* Creation time */
700 /*40*/ __le64 i_mtime; /* Modification time */
701 __le64 i_dtime; /* Deletion time */
702 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
703 __le64 i_last_eb_blk; /* Pointer to last extent
705 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
709 /*70*/ __le32 i_attr;
710 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
711 was set in i_flags */
712 __le16 i_dyn_features;
714 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
715 /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
716 __le64 i_reserved2[5];
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 dependant 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 __le64 db_free_next; /* Next block in list (unused) */
785 /*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
786 __le64 db_parent_dinode; /* dinode which owns me, in
788 /*30*/ 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 */
846 __le64 dr_free_blk; /* Pointer to head of free
847 * unindexed block list. */
848 __le64 dr_reserved3[15];
850 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
851 * bits for maximum space
853 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
854 * entries. We grow out
861 * The header of a leaf block in the indexed tree.
863 struct ocfs2_dx_leaf {
864 __u8 dl_signature[8];/* Signature for verification */
865 struct ocfs2_block_check dl_check; /* Error checking */
866 __le64 dl_blkno; /* Offset on disk, in blocks */
867 __le32 dl_fs_generation;/* Must match super block */
870 struct ocfs2_dx_entry_list dl_list;
874 * On disk allocator group structure for OCFS2
876 struct ocfs2_group_desc
878 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
879 __le16 bg_size; /* Size of included bitmap in
881 __le16 bg_bits; /* Bits represented by this
883 __le16 bg_free_bits_count; /* Free bits count */
884 __le16 bg_chain; /* What chain I am in. */
885 /*10*/ __le32 bg_generation;
887 __le64 bg_next_group; /* Next group in my list, in
889 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
891 __le64 bg_blkno; /* Offset on disk, in blocks */
892 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
894 /*40*/ __u8 bg_bitmap[0];
898 * On disk extended attribute structure for OCFS2.
902 * ocfs2_xattr_entry indicates one extend attribute.
904 * Note that it can be stored in inode, one block or one xattr bucket.
906 struct ocfs2_xattr_entry {
907 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
908 __le16 xe_name_offset; /* byte offset from the 1st entry in the
909 local xattr storage(inode, xattr block or
911 __u8 xe_name_len; /* xattr name len, does't include prefix. */
912 __u8 xe_type; /* the low 7 bits indicate the name prefix
913 * type and the highest bit indicates whether
914 * the EA is stored in the local storage. */
915 __le64 xe_value_size; /* real xattr value length. */
919 * On disk structure for xattr header.
921 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
922 * the local xattr storage.
924 struct ocfs2_xattr_header {
925 __le16 xh_count; /* contains the count of how
926 many records are in the
927 local xattr storage. */
928 __le16 xh_free_start; /* current offset for storing
930 __le16 xh_name_value_len; /* total length of name/value
931 length in this bucket. */
932 __le16 xh_num_buckets; /* Number of xattr buckets
933 in this extent record,
934 only valid in the first
936 struct ocfs2_block_check xh_check; /* Error checking
939 buckets. A block uses
941 this field to zero.) */
942 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
946 * On disk structure for xattr value root.
948 * When an xattr's value is large enough, it is stored in an external
949 * b-tree like file data. The xattr value root points to this structure.
951 struct ocfs2_xattr_value_root {
952 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
954 __le64 xr_last_eb_blk; /* Pointer to last extent block */
955 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
959 * On disk structure for xattr tree root.
961 * It is used when there are too many extended attributes for one file. These
962 * attributes will be organized and stored in an indexed-btree.
964 struct ocfs2_xattr_tree_root {
965 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
967 __le64 xt_last_eb_blk; /* Pointer to last extent block */
968 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
971 #define OCFS2_XATTR_INDEXED 0x1
972 #define OCFS2_HASH_SHIFT 5
973 #define OCFS2_XATTR_ROUND 3
974 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
975 ~(OCFS2_XATTR_ROUND))
977 #define OCFS2_XATTR_BUCKET_SIZE 4096
978 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
979 / OCFS2_MIN_BLOCKSIZE)
982 * On disk structure for xattr block.
984 struct ocfs2_xattr_block {
985 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
986 __le16 xb_suballoc_slot; /* Slot suballocator this
988 __le16 xb_suballoc_bit; /* Bit offset in suballocator
990 __le32 xb_fs_generation; /* Must match super block */
991 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
992 struct ocfs2_block_check xb_check; /* Error checking */
993 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
994 real xattr or a xattr tree. */
999 struct ocfs2_xattr_header xb_header; /* xattr header if this
1000 block contains xattr */
1001 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1007 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1008 #define OCFS2_XATTR_TYPE_MASK 0x7F
1009 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1013 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1015 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1018 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1020 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1023 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1025 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1028 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1030 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1034 * On disk structures for global quota file
1037 /* Magic numbers and known versions for global quota files */
1038 #define OCFS2_GLOBAL_QMAGICS {\
1039 0x0cf52470, /* USRQUOTA */ \
1040 0x0cf52471 /* GRPQUOTA */ \
1043 #define OCFS2_GLOBAL_QVERSIONS {\
1049 /* Each block of each quota file has a certain fixed number of bytes reserved
1050 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1051 * checksums, etc. */
1052 #define OCFS2_QBLK_RESERVED_SPACE 8
1054 /* Generic header of all quota files */
1055 struct ocfs2_disk_dqheader {
1056 __le32 dqh_magic; /* Magic number identifying file */
1057 __le32 dqh_version; /* Quota format version */
1060 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1062 /* Information header of global quota file (immediately follows the generic
1064 struct ocfs2_global_disk_dqinfo {
1065 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1066 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1067 __le32 dqi_syncms; /* Time after which we sync local changes to
1068 * global quota file */
1069 __le32 dqi_blocks; /* Number of blocks in quota file */
1070 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1071 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1075 /* Structure with global user / group information. We reserve some space
1076 * for future use. */
1077 struct ocfs2_global_disk_dqblk {
1078 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
1079 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1080 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1081 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1082 __le64 dqb_curinodes; /* current # allocated inodes */
1083 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1084 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1085 /*30*/ __le64 dqb_curspace; /* current space occupied */
1086 __le64 dqb_btime; /* time limit for excessive disk use */
1087 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1089 /*50*/ __le64 dqb_pad2;
1093 * On-disk structures for local quota file
1096 /* Magic numbers and known versions for local quota files */
1097 #define OCFS2_LOCAL_QMAGICS {\
1098 0x0cf524c0, /* USRQUOTA */ \
1099 0x0cf524c1 /* GRPQUOTA */ \
1102 #define OCFS2_LOCAL_QVERSIONS {\
1107 /* Quota flags in dqinfo header */
1108 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1109 * quota has been cleanly turned off) */
1111 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1113 /* Information header of local quota file (immediately follows the generic
1115 struct ocfs2_local_disk_dqinfo {
1116 __le32 dqi_flags; /* Flags for quota file */
1117 __le32 dqi_chunks; /* Number of chunks of quota structures
1119 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1122 /* Header of one chunk of a quota file */
1123 struct ocfs2_local_disk_chunk {
1124 __le32 dqc_free; /* Number of free entries in the bitmap */
1125 u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1126 * chunk of quota file */
1129 /* One entry in local quota file */
1130 struct ocfs2_local_disk_dqblk {
1131 /*00*/ __le64 dqb_id; /* id this quota applies to */
1132 __le64 dqb_spacemod; /* Change in the amount of used space */
1133 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1138 * The quota trailer lives at the end of each quota block.
1141 struct ocfs2_disk_dqtrailer {
1142 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1143 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1146 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1150 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1152 return (struct ocfs2_disk_dqtrailer *)ptr;
1156 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1158 return sb->s_blocksize -
1159 offsetof(struct ocfs2_dinode, id2.i_symlink);
1162 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1163 struct ocfs2_dinode *di)
1165 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1167 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1168 return sb->s_blocksize -
1169 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1172 return sb->s_blocksize -
1173 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1176 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1180 size = sb->s_blocksize -
1181 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1183 return size / sizeof(struct ocfs2_extent_rec);
1186 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1187 struct super_block *sb,
1188 struct ocfs2_dinode *di)
1191 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1193 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1194 size = sb->s_blocksize -
1195 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1198 size = sb->s_blocksize -
1199 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1201 return size / sizeof(struct ocfs2_extent_rec);
1204 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1208 size = sb->s_blocksize -
1209 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1211 return size / sizeof(struct ocfs2_extent_rec);
1214 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1218 size = sb->s_blocksize -
1219 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1221 return size / sizeof(struct ocfs2_chain_rec);
1224 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1228 size = sb->s_blocksize -
1229 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1231 return size / sizeof(struct ocfs2_extent_rec);
1234 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1238 size = sb->s_blocksize -
1239 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1241 return size / sizeof(struct ocfs2_dx_entry);
1244 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1248 size = sb->s_blocksize -
1249 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1251 return size / sizeof(struct ocfs2_dx_entry);
1254 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1258 size = sb->s_blocksize -
1259 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1264 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
1268 size = sb->s_blocksize -
1269 offsetof(struct ocfs2_group_desc, bg_bitmap);
1274 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1278 size = sb->s_blocksize -
1279 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1281 return size / sizeof(struct ocfs2_truncate_rec);
1284 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1286 u64 offset = OCFS2_BACKUP_SB_START;
1288 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1289 offset <<= (2 * index);
1290 offset >>= sb->s_blocksize_bits;
1298 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1302 size = sb->s_blocksize -
1303 offsetof(struct ocfs2_xattr_block,
1304 xb_attrs.xb_root.xt_list.l_recs);
1306 return size / sizeof(struct ocfs2_extent_rec);
1309 static inline int ocfs2_fast_symlink_chars(int blocksize)
1311 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1314 static inline int ocfs2_max_inline_data(int blocksize)
1316 return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1319 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1324 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1326 return size / sizeof(struct ocfs2_extent_rec);
1329 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1334 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1336 return size / sizeof(struct ocfs2_chain_rec);
1339 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1344 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1346 return size / sizeof(struct ocfs2_extent_rec);
1349 static inline int ocfs2_local_alloc_size(int blocksize)
1354 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1359 static inline int ocfs2_group_bitmap_size(int blocksize)
1364 offsetof(struct ocfs2_group_desc, bg_bitmap);
1369 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1374 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1376 return size / sizeof(struct ocfs2_truncate_rec);
1379 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1381 uint64_t offset = OCFS2_BACKUP_SB_START;
1383 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1384 offset <<= (2 * index);
1385 offset /= blocksize;
1392 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1397 offsetof(struct ocfs2_xattr_block,
1398 xb_attrs.xb_root.xt_list.l_recs);
1400 return size / sizeof(struct ocfs2_extent_rec);
1402 #endif /* __KERNEL__ */
1405 static inline int ocfs2_system_inode_is_global(int type)
1407 return ((type >= 0) &&
1408 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1411 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1417 * Global system inodes can only have one copy. Everything
1418 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1419 * list has a copy per slot.
1421 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1422 chars = snprintf(buf, len, "%s",
1423 ocfs2_system_inodes[type].si_name);
1425 chars = snprintf(buf, len,
1426 ocfs2_system_inodes[type].si_name,
1432 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1435 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1438 #endif /* _OCFS2_FS_H */