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 #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
105 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
106 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
109 * Heartbeat-only devices are missing journals and other files. The
110 * filesystem driver can't load them, but the library can. Never put
111 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
113 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
116 * tunefs sets this incompat flag before starting the resize and clears it
117 * at the end. This flag protects users from inadvertently mounting the fs
118 * after an aborted run without fsck-ing.
120 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
122 /* Used to denote a non-clustered volume */
123 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
125 /* Support for sparse allocation in b-trees */
126 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
129 * Tunefs sets this incompat flag before starting an operation which
130 * would require cleanup on abort. This is done to protect users from
131 * inadvertently mounting the fs after an aborted run without
134 * s_tunefs_flags on the super block describes precisely which
135 * operations were in progress.
137 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
139 /* Support for data packed into inode blocks */
140 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
143 * Support for alternate, userspace cluster stacks. If set, the superblock
144 * field s_cluster_info contains a tag for the alternate stack in use as
145 * well as the name of the cluster being joined.
146 * mount.ocfs2 must pass in a matching stack name.
148 * If not set, the classic stack will be used. This is compatbile with
149 * all older versions.
151 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
153 /* Support for the extended slot map */
154 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
156 /* Support for extended attributes */
157 #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
159 /* Support for indexed directores */
160 #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
162 /* Metadata checksum and error correction */
163 #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
165 /* Refcount tree support */
166 #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
168 /* Discontigous block groups */
169 #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
172 * backup superblock flag is used to indicate that this volume
173 * has backup superblocks.
175 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
178 * The filesystem will correctly handle journal feature bits.
180 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
183 * Unwritten extents support.
185 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
188 * Maintain quota information for this filesystem
190 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
191 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
193 /* The byte offset of the first backup block will be 1G.
194 * The following will be 4G, 16G, 64G, 256G and 1T.
196 #define OCFS2_BACKUP_SB_START 1 << 30
198 /* the max backup superblock nums */
199 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
202 * Flags on ocfs2_super_block.s_tunefs_flags
204 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
207 * Flags on ocfs2_dinode.i_flags
209 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
210 #define OCFS2_UNUSED2_FL (0x00000002)
211 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
212 #define OCFS2_UNUSED3_FL (0x00000008)
213 /* System inode flags */
214 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
215 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
216 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
217 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
218 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
219 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
220 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
221 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
222 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
225 * Flags on ocfs2_dinode.i_dyn_features
227 * These can change much more often than i_flags. When adding flags,
228 * keep in mind that i_dyn_features is only 16 bits wide.
230 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
231 #define OCFS2_HAS_XATTR_FL (0x0002)
232 #define OCFS2_INLINE_XATTR_FL (0x0004)
233 #define OCFS2_INDEXED_DIR_FL (0x0008)
234 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
236 /* Inode attributes, keep in sync with EXT2 */
237 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
238 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
239 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
240 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
241 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
242 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
243 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
244 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
245 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
247 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
248 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
251 * Extent record flags (e_node.leaf.flags)
253 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
255 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
256 * counted in an associated
260 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
262 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
265 * superblock s_state flags
267 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
269 /* Limit of space in ocfs2_dir_entry */
270 #define OCFS2_MAX_FILENAME_LEN 255
272 /* Maximum slots on an ocfs2 file system */
273 #define OCFS2_MAX_SLOTS 255
275 /* Slot map indicator for an empty slot */
276 #define OCFS2_INVALID_SLOT -1
278 #define OCFS2_VOL_UUID_LEN 16
279 #define OCFS2_MAX_VOL_LABEL_LEN 64
281 /* The alternate, userspace stack fields */
282 #define OCFS2_STACK_LABEL_LEN 4
283 #define OCFS2_CLUSTER_NAME_LEN 16
285 /* Journal limits (in bytes) */
286 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
289 * Inline extended attribute size (in bytes)
290 * The value chosen should be aligned to 16 byte boundaries.
292 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
294 struct ocfs2_system_inode_info
{
300 /* System file index */
302 BAD_BLOCK_SYSTEM_INODE
= 0,
303 GLOBAL_INODE_ALLOC_SYSTEM_INODE
,
304 SLOT_MAP_SYSTEM_INODE
,
305 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
306 HEARTBEAT_SYSTEM_INODE
,
307 GLOBAL_BITMAP_SYSTEM_INODE
,
308 USER_QUOTA_SYSTEM_INODE
,
309 GROUP_QUOTA_SYSTEM_INODE
,
310 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
311 ORPHAN_DIR_SYSTEM_INODE
,
312 EXTENT_ALLOC_SYSTEM_INODE
,
313 INODE_ALLOC_SYSTEM_INODE
,
314 JOURNAL_SYSTEM_INODE
,
315 LOCAL_ALLOC_SYSTEM_INODE
,
316 TRUNCATE_LOG_SYSTEM_INODE
,
317 LOCAL_USER_QUOTA_SYSTEM_INODE
,
318 LOCAL_GROUP_QUOTA_SYSTEM_INODE
,
322 static struct ocfs2_system_inode_info ocfs2_system_inodes
[NUM_SYSTEM_INODES
] = {
323 /* Global system inodes (single copy) */
324 /* The first two are only used from userspace mfks/tunefs */
325 [BAD_BLOCK_SYSTEM_INODE
] = { "bad_blocks", 0, S_IFREG
| 0644 },
326 [GLOBAL_INODE_ALLOC_SYSTEM_INODE
] = { "global_inode_alloc", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
328 /* These are used by the running filesystem */
329 [SLOT_MAP_SYSTEM_INODE
] = { "slot_map", 0, S_IFREG
| 0644 },
330 [HEARTBEAT_SYSTEM_INODE
] = { "heartbeat", OCFS2_HEARTBEAT_FL
, S_IFREG
| 0644 },
331 [GLOBAL_BITMAP_SYSTEM_INODE
] = { "global_bitmap", 0, S_IFREG
| 0644 },
332 [USER_QUOTA_SYSTEM_INODE
] = { "aquota.user", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
333 [GROUP_QUOTA_SYSTEM_INODE
] = { "aquota.group", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
335 /* Slot-specific system inodes (one copy per slot) */
336 [ORPHAN_DIR_SYSTEM_INODE
] = { "orphan_dir:%04d", 0, S_IFDIR
| 0755 },
337 [EXTENT_ALLOC_SYSTEM_INODE
] = { "extent_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
338 [INODE_ALLOC_SYSTEM_INODE
] = { "inode_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
339 [JOURNAL_SYSTEM_INODE
] = { "journal:%04d", OCFS2_JOURNAL_FL
, S_IFREG
| 0644 },
340 [LOCAL_ALLOC_SYSTEM_INODE
] = { "local_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_LOCAL_ALLOC_FL
, S_IFREG
| 0644 },
341 [TRUNCATE_LOG_SYSTEM_INODE
] = { "truncate_log:%04d", OCFS2_DEALLOC_FL
, S_IFREG
| 0644 },
342 [LOCAL_USER_QUOTA_SYSTEM_INODE
] = { "aquota.user:%04d", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
343 [LOCAL_GROUP_QUOTA_SYSTEM_INODE
] = { "aquota.group:%04d", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
346 /* Parameter passed from mount.ocfs2 to module */
347 #define OCFS2_HB_NONE "heartbeat=none"
348 #define OCFS2_HB_LOCAL "heartbeat=local"
351 * OCFS2 directory file types. Only the low 3 bits are used. The
352 * other bits are reserved for now.
354 #define OCFS2_FT_UNKNOWN 0
355 #define OCFS2_FT_REG_FILE 1
356 #define OCFS2_FT_DIR 2
357 #define OCFS2_FT_CHRDEV 3
358 #define OCFS2_FT_BLKDEV 4
359 #define OCFS2_FT_FIFO 5
360 #define OCFS2_FT_SOCK 6
361 #define OCFS2_FT_SYMLINK 7
363 #define OCFS2_FT_MAX 8
366 * OCFS2_DIR_PAD defines the directory entries boundaries
368 * NOTE: It must be a multiple of 4
370 #define OCFS2_DIR_PAD 4
371 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
372 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
373 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
376 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
378 #define OCFS2_LINK_MAX 32000
379 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
380 #define OCFS2_LINKS_HI_SHIFT 16
381 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
384 static unsigned char ocfs2_type_by_mode
[S_IFMT
>> S_SHIFT
] = {
385 [S_IFREG
>> S_SHIFT
] = OCFS2_FT_REG_FILE
,
386 [S_IFDIR
>> S_SHIFT
] = OCFS2_FT_DIR
,
387 [S_IFCHR
>> S_SHIFT
] = OCFS2_FT_CHRDEV
,
388 [S_IFBLK
>> S_SHIFT
] = OCFS2_FT_BLKDEV
,
389 [S_IFIFO
>> S_SHIFT
] = OCFS2_FT_FIFO
,
390 [S_IFSOCK
>> S_SHIFT
] = OCFS2_FT_SOCK
,
391 [S_IFLNK
>> S_SHIFT
] = OCFS2_FT_SYMLINK
,
398 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
401 * Block checking structure. This is used in metadata to validate the
402 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
405 struct ocfs2_block_check
{
406 /*00*/ __le32 bc_crc32e
; /* 802.3 Ethernet II CRC32 */
407 __le16 bc_ecc
; /* Single-error-correction parity vector.
408 This is a simple Hamming code dependant
409 on the blocksize. OCFS2's maximum
410 blocksize, 4K, requires 16 parity bits,
411 so we fit in __le16. */
417 * On disk extent record for OCFS2
418 * It describes a range of clusters on disk.
420 * Length fields are divided into interior and leaf node versions.
421 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
423 struct ocfs2_extent_rec
{
424 /*00*/ __le32 e_cpos
; /* Offset into the file, in clusters */
426 __le32 e_int_clusters
; /* Clusters covered by all children */
428 __le16 e_leaf_clusters
; /* Clusters covered by this
431 __u8 e_flags
; /* Extent flags */
434 __le64 e_blkno
; /* Physical disk offset, in blocks */
438 struct ocfs2_chain_rec
{
439 __le32 c_free
; /* Number of free bits in this chain. */
440 __le32 c_total
; /* Number of total bits in this chain */
441 __le64 c_blkno
; /* Physical disk offset (blocks) of 1st group */
444 struct ocfs2_truncate_rec
{
445 __le32 t_start
; /* 1st cluster in this log */
446 __le32 t_clusters
; /* Number of total clusters covered */
450 * On disk extent list for OCFS2 (node in the tree). Note that this
451 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
452 * offsets are relative to ocfs2_dinode.id2.i_list or
453 * ocfs2_extent_block.h_list, respectively.
455 struct ocfs2_extent_list
{
456 /*00*/ __le16 l_tree_depth
; /* Extent tree depth from this
457 point. 0 means data extents
458 hang directly off this
460 NOTE: The high 8 bits cannot be
461 used - tree_depth is never that big.
463 __le16 l_count
; /* Number of extent records */
464 __le16 l_next_free_rec
; /* Next unused extent slot */
466 __le64 l_reserved2
; /* Pad to
467 sizeof(ocfs2_extent_rec) */
468 /*10*/ struct ocfs2_extent_rec l_recs
[0]; /* Extent records */
472 * On disk allocation chain list for OCFS2. Note that this is
473 * contained inside ocfs2_dinode, so the offsets are relative to
474 * ocfs2_dinode.id2.i_chain.
476 struct ocfs2_chain_list
{
477 /*00*/ __le16 cl_cpg
; /* Clusters per Block Group */
478 __le16 cl_bpc
; /* Bits per cluster */
479 __le16 cl_count
; /* Total chains in this list */
480 __le16 cl_next_free_rec
; /* Next unused chain slot */
482 /*10*/ struct ocfs2_chain_rec cl_recs
[0]; /* Chain records */
486 * On disk deallocation log for OCFS2. Note that this is
487 * contained inside ocfs2_dinode, so the offsets are relative to
488 * ocfs2_dinode.id2.i_dealloc.
490 struct ocfs2_truncate_log
{
491 /*00*/ __le16 tl_count
; /* Total records in this log */
492 __le16 tl_used
; /* Number of records in use */
494 /*08*/ struct ocfs2_truncate_rec tl_recs
[0]; /* Truncate records */
498 * On disk extent block (indirect block) for OCFS2
500 struct ocfs2_extent_block
502 /*00*/ __u8 h_signature
[8]; /* Signature for verification */
503 struct ocfs2_block_check h_check
; /* Error checking */
504 /*10*/ __le16 h_suballoc_slot
; /* Slot suballocator this
505 extent_header belongs to */
506 __le16 h_suballoc_bit
; /* Bit offset in suballocator
508 __le32 h_fs_generation
; /* Must match super block */
509 __le64 h_blkno
; /* Offset on disk, in blocks */
510 /*20*/ __le64 h_suballoc_loc
; /* Suballocator block group this
511 eb belongs to. Only valid
513 discontiguous block group */
514 __le64 h_next_leaf_blk
; /* Offset on disk, in blocks,
515 of next leaf header pointing
517 /*30*/ struct ocfs2_extent_list h_list
; /* Extent record list */
518 /* Actual on-disk size is one block */
522 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
523 * system file. A slot is valid if it contains a node number >= 0. The
524 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
526 struct ocfs2_slot_map
{
527 /*00*/ __le16 sm_slots
[0];
529 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
530 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
534 struct ocfs2_extended_slot
{
535 /*00*/ __u8 es_valid
;
536 __u8 es_reserved1
[3];
542 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
543 * is set. It separates out the valid marker from the node number, and
544 * has room to grow. Unlike the old slot map, this format is defined by
547 struct ocfs2_slot_map_extended
{
548 /*00*/ struct ocfs2_extended_slot se_slots
[0];
550 * Actual size is i_size of the slot_map system file. It should
551 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
555 struct ocfs2_cluster_info
{
556 /*00*/ __u8 ci_stack
[OCFS2_STACK_LABEL_LEN
];
558 /*08*/ __u8 ci_cluster
[OCFS2_CLUSTER_NAME_LEN
];
563 * On disk superblock for OCFS2
564 * Note that it is contained inside an ocfs2_dinode, so all offsets
565 * are relative to the start of ocfs2_dinode.id2.
567 struct ocfs2_super_block
{
568 /*00*/ __le16 s_major_rev_level
;
569 __le16 s_minor_rev_level
;
571 __le16 s_max_mnt_count
;
572 __le16 s_state
; /* File system state */
573 __le16 s_errors
; /* Behaviour when detecting errors */
574 __le32 s_checkinterval
; /* Max time between checks */
575 /*10*/ __le64 s_lastcheck
; /* Time of last check */
576 __le32 s_creator_os
; /* OS */
577 __le32 s_feature_compat
; /* Compatible feature set */
578 /*20*/ __le32 s_feature_incompat
; /* Incompatible feature set */
579 __le32 s_feature_ro_compat
; /* Readonly-compatible feature set */
580 __le64 s_root_blkno
; /* Offset, in blocks, of root directory
582 /*30*/ __le64 s_system_dir_blkno
; /* Offset, in blocks, of system
584 __le32 s_blocksize_bits
; /* Blocksize for this fs */
585 __le32 s_clustersize_bits
; /* Clustersize for this fs */
586 /*40*/ __le16 s_max_slots
; /* Max number of simultaneous mounts
587 before tunefs required */
588 __le16 s_tunefs_flag
;
589 __le32 s_uuid_hash
; /* hash value of uuid */
590 __le64 s_first_cluster_group
; /* Block offset of 1st cluster
592 /*50*/ __u8 s_label
[OCFS2_MAX_VOL_LABEL_LEN
]; /* Label for mounting, etc. */
593 /*90*/ __u8 s_uuid
[OCFS2_VOL_UUID_LEN
]; /* 128-bit uuid */
594 /*A0*/ struct ocfs2_cluster_info s_cluster_info
; /* Selected userspace
596 with INCOMPAT flag. */
597 /*B8*/ __le16 s_xattr_inline_size
; /* extended attribute inline size
600 __le32 s_dx_seed
[3]; /* seed[0-2] for dx dir hash.
601 * s_uuid_hash serves as seed[3]. */
602 /*C0*/ __le64 s_reserved2
[15]; /* Fill out superblock */
606 * NOTE: As stated above, all offsets are relative to
607 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
608 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
609 * our smallest blocksize, which is 512 bytes. To ensure this,
610 * we reserve the space in s_reserved2. Anything past s_reserved2
611 * will not be available on the smallest blocksize.
616 * Local allocation bitmap for OCFS2 slots
617 * Note that it exists inside an ocfs2_dinode, so all offsets are
618 * relative to the start of ocfs2_dinode.id2.
620 struct ocfs2_local_alloc
622 /*00*/ __le32 la_bm_off
; /* Starting bit offset in main bitmap */
623 __le16 la_size
; /* Size of included bitmap, in bytes */
626 /*10*/ __u8 la_bitmap
[0];
630 * Data-in-inode header. This is only used if i_dyn_features has
631 * OCFS2_INLINE_DATA_FL set.
633 struct ocfs2_inline_data
635 /*00*/ __le16 id_count
; /* Number of bytes that can be used
636 * for data, starting at id_data */
639 __u8 id_data
[0]; /* Start of user data */
643 * On disk inode for OCFS2
645 struct ocfs2_dinode
{
646 /*00*/ __u8 i_signature
[8]; /* Signature for validation */
647 __le32 i_generation
; /* Generation number */
648 __le16 i_suballoc_slot
; /* Slot suballocator this inode
650 __le16 i_suballoc_bit
; /* Bit offset in suballocator
652 /*10*/ __le16 i_links_count_hi
; /* High 16 bits of links count */
653 __le16 i_xattr_inline_size
;
654 __le32 i_clusters
; /* Cluster count */
655 __le32 i_uid
; /* Owner UID */
656 __le32 i_gid
; /* Owning GID */
657 /*20*/ __le64 i_size
; /* Size in bytes */
658 __le16 i_mode
; /* File mode */
659 __le16 i_links_count
; /* Links count */
660 __le32 i_flags
; /* File flags */
661 /*30*/ __le64 i_atime
; /* Access time */
662 __le64 i_ctime
; /* Creation time */
663 /*40*/ __le64 i_mtime
; /* Modification time */
664 __le64 i_dtime
; /* Deletion time */
665 /*50*/ __le64 i_blkno
; /* Offset on disk, in blocks */
666 __le64 i_last_eb_blk
; /* Pointer to last extent
668 /*60*/ __le32 i_fs_generation
; /* Generation per fs-instance */
672 /*70*/ __le32 i_attr
;
673 __le16 i_orphaned_slot
; /* Only valid when OCFS2_ORPHANED_FL
674 was set in i_flags */
675 __le16 i_dyn_features
;
677 /*80*/ struct ocfs2_block_check i_check
; /* Error checking */
678 /*88*/ __le64 i_dx_root
; /* Pointer to dir index root block */
679 /*90*/ __le64 i_refcount_loc
;
680 __le64 i_suballoc_loc
; /* Suballocator block group this
681 inode belongs to. Only valid
683 discontiguous block group */
684 /*A0*/ __le64 i_reserved2
[3];
686 __le64 i_pad1
; /* Generic way to refer to this
689 __le64 i_rdev
; /* Device number */
691 struct { /* Info for bitmap system
693 __le32 i_used
; /* Bits (ie, clusters) used */
694 __le32 i_total
; /* Total bits (clusters)
697 struct { /* Info for journal system
699 __le32 ij_flags
; /* Mounted, version, etc. */
700 __le32 ij_recovery_generation
; /* Incremented when the
705 } id1
; /* Inode type dependant 1 */
707 struct ocfs2_super_block i_super
;
708 struct ocfs2_local_alloc i_lab
;
709 struct ocfs2_chain_list i_chain
;
710 struct ocfs2_extent_list i_list
;
711 struct ocfs2_truncate_log i_dealloc
;
712 struct ocfs2_inline_data i_data
;
715 /* Actual on-disk size is one block */
719 * On-disk directory entry structure for OCFS2
721 * Packed as this structure could be accessed unaligned on 64-bit platforms
723 struct ocfs2_dir_entry
{
724 /*00*/ __le64 inode
; /* Inode number */
725 __le16 rec_len
; /* Directory entry length */
726 __u8 name_len
; /* Name length */
728 /*0C*/ char name
[OCFS2_MAX_FILENAME_LEN
]; /* File name */
729 /* Actual on-disk length specified by rec_len */
730 } __attribute__ ((packed
));
733 * Per-block record for the unindexed directory btree. This is carefully
734 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
735 * mirrored. That way, the directory manipulation code needs a minimal amount
738 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
740 struct ocfs2_dir_block_trailer
{
741 /*00*/ __le64 db_compat_inode
; /* Always zero. Was inode */
743 __le16 db_compat_rec_len
; /* Backwards compatible with
744 * ocfs2_dir_entry. */
745 __u8 db_compat_name_len
; /* Always zero. Was name_len */
748 __le16 db_free_rec_len
; /* Size of largest empty hole
749 * in this block. (unused) */
750 /*10*/ __u8 db_signature
[8]; /* Signature for verification */
752 __le64 db_free_next
; /* Next block in list (unused) */
753 /*20*/ __le64 db_blkno
; /* Offset on disk, in blocks */
754 __le64 db_parent_dinode
; /* dinode which owns me, in
756 /*30*/ struct ocfs2_block_check db_check
; /* Error checking */
761 * A directory entry in the indexed tree. We don't store the full name here,
762 * but instead provide a pointer to the full dirent in the unindexed tree.
764 * We also store name_len here so as to reduce the number of leaf blocks we
765 * need to search in case of collisions.
767 struct ocfs2_dx_entry
{
768 __le32 dx_major_hash
; /* Used to find logical
769 * cluster in index */
770 __le32 dx_minor_hash
; /* Lower bits used to find
771 * block in cluster */
772 __le64 dx_dirent_blk
; /* Physical block in unindexed
773 * tree holding this dirent. */
776 struct ocfs2_dx_entry_list
{
778 __le16 de_count
; /* Maximum number of entries
779 * possible in de_entries */
780 __le16 de_num_used
; /* Current number of
781 * de_entries entries */
782 struct ocfs2_dx_entry de_entries
[0]; /* Indexed dir entries
783 * in a packed array of
784 * length de_num_used */
787 #define OCFS2_DX_FLAG_INLINE 0x01
790 * A directory indexing block. Each indexed directory has one of these,
791 * pointed to by ocfs2_dinode.
793 * This block stores an indexed btree root, and a set of free space
794 * start-of-list pointers.
796 struct ocfs2_dx_root_block
{
797 __u8 dr_signature
[8]; /* Signature for verification */
798 struct ocfs2_block_check dr_check
; /* Error checking */
799 __le16 dr_suballoc_slot
; /* Slot suballocator this
800 * block belongs to. */
801 __le16 dr_suballoc_bit
; /* Bit offset in suballocator
803 __le32 dr_fs_generation
; /* Must match super block */
804 __le64 dr_blkno
; /* Offset on disk, in blocks */
805 __le64 dr_last_eb_blk
; /* Pointer to last
807 __le32 dr_clusters
; /* Clusters allocated
808 * to the indexed tree. */
809 __u8 dr_flags
; /* OCFS2_DX_FLAG_* flags */
812 __le64 dr_dir_blkno
; /* Pointer to parent inode */
813 __le32 dr_num_entries
; /* Total number of
817 __le64 dr_free_blk
; /* Pointer to head of free
818 * unindexed block list. */
819 __le64 dr_suballoc_loc
; /* Suballocator block group
820 this root belongs to.
821 Only valid if allocated
824 __le64 dr_reserved3
[14];
826 struct ocfs2_extent_list dr_list
; /* Keep this aligned to 128
827 * bits for maximum space
829 struct ocfs2_dx_entry_list dr_entries
; /* In-root-block list of
830 * entries. We grow out
837 * The header of a leaf block in the indexed tree.
839 struct ocfs2_dx_leaf
{
840 __u8 dl_signature
[8];/* Signature for verification */
841 struct ocfs2_block_check dl_check
; /* Error checking */
842 __le64 dl_blkno
; /* Offset on disk, in blocks */
843 __le32 dl_fs_generation
;/* Must match super block */
846 struct ocfs2_dx_entry_list dl_list
;
850 * Largest bitmap for a block (suballocator) group in bytes. This limit
851 * does not affect cluster groups (global allocator). Cluster group
852 * bitmaps run to the end of the block.
854 #define OCFS2_MAX_BG_BITMAP_SIZE 256
857 * On disk allocator group structure for OCFS2
859 struct ocfs2_group_desc
861 /*00*/ __u8 bg_signature
[8]; /* Signature for validation */
862 __le16 bg_size
; /* Size of included bitmap in
864 __le16 bg_bits
; /* Bits represented by this
866 __le16 bg_free_bits_count
; /* Free bits count */
867 __le16 bg_chain
; /* What chain I am in. */
868 /*10*/ __le32 bg_generation
;
870 __le64 bg_next_group
; /* Next group in my list, in
872 /*20*/ __le64 bg_parent_dinode
; /* dinode which owns me, in
874 __le64 bg_blkno
; /* Offset on disk, in blocks */
875 /*30*/ struct ocfs2_block_check bg_check
; /* Error checking */
881 * Block groups may be discontiguous when
882 * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
883 * The extents of a discontigous block group are
884 * stored in bg_list. It is a flat list.
885 * l_tree_depth must always be zero. A
886 * discontiguous group is signified by a non-zero
887 * bg_list->l_next_free_rec. Only block groups
888 * can be discontiguous; Cluster groups cannot.
889 * We've never made a block group with more than
890 * 2048 blocks (256 bytes of bg_bitmap). This
891 * codifies that limit so that we can fit bg_list.
892 * bg_size of a discontiguous block group will
893 * be 256 to match bg_bitmap_filler.
895 __u8 bg_bitmap_filler
[OCFS2_MAX_BG_BITMAP_SIZE
];
896 /*140*/ struct ocfs2_extent_list bg_list
;
899 /* Actual on-disk size is one block */
902 struct ocfs2_refcount_rec
{
903 /*00*/ __le64 r_cpos
; /* Physical offset, in clusters */
904 __le32 r_clusters
; /* Clusters covered by this extent */
905 __le32 r_refcount
; /* Reference count of this extent */
908 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
910 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
911 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
913 struct ocfs2_refcount_list
{
914 /*00*/ __le16 rl_count
; /* Maximum number of entries possible
916 __le16 rl_used
; /* Current number of used records */
918 __le64 rl_reserved1
; /* Pad to sizeof(ocfs2_refcount_record) */
919 /*10*/ struct ocfs2_refcount_rec rl_recs
[0]; /* Refcount records */
923 struct ocfs2_refcount_block
{
924 /*00*/ __u8 rf_signature
[8]; /* Signature for verification */
925 __le16 rf_suballoc_slot
; /* Slot suballocator this block
927 __le16 rf_suballoc_bit
; /* Bit offset in suballocator
929 __le32 rf_fs_generation
; /* Must match superblock */
930 /*10*/ __le64 rf_blkno
; /* Offset on disk, in blocks */
931 __le64 rf_parent
; /* Parent block, only valid if
932 OCFS2_REFCOUNT_LEAF_FL is set in
934 /*20*/ struct ocfs2_block_check rf_check
; /* Error checking */
935 __le64 rf_last_eb_blk
; /* Pointer to last extent block */
936 /*30*/ __le32 rf_count
; /* Number of inodes sharing this
938 __le32 rf_flags
; /* See the flags above */
939 __le32 rf_clusters
; /* clusters covered by refcount tree. */
940 __le32 rf_cpos
; /* cluster offset in refcount tree.*/
941 /*40*/ __le32 rf_generation
; /* generation number. all be the same
942 * for the same refcount tree. */
944 __le64 rf_suballoc_loc
; /* Suballocator block group this
945 refcount block belongs to. Only
946 valid if allocated from a
947 discontiguous block group */
948 /*50*/ __le64 rf_reserved1
[6];
950 struct ocfs2_refcount_list rf_records
; /* List of refcount
952 struct ocfs2_extent_list rf_list
; /* Extent record list,
954 OCFS2_REFCOUNT_TREE_FL
955 is set in rf_flags */
957 /* Actual on-disk size is one block */
961 * On disk extended attribute structure for OCFS2.
965 * ocfs2_xattr_entry indicates one extend attribute.
967 * Note that it can be stored in inode, one block or one xattr bucket.
969 struct ocfs2_xattr_entry
{
970 __le32 xe_name_hash
; /* hash value of xattr prefix+suffix. */
971 __le16 xe_name_offset
; /* byte offset from the 1st entry in the
972 local xattr storage(inode, xattr block or
974 __u8 xe_name_len
; /* xattr name len, does't include prefix. */
975 __u8 xe_type
; /* the low 7 bits indicate the name prefix
976 * type and the highest bit indicates whether
977 * the EA is stored in the local storage. */
978 __le64 xe_value_size
; /* real xattr value length. */
982 * On disk structure for xattr header.
984 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
985 * the local xattr storage.
987 struct ocfs2_xattr_header
{
988 __le16 xh_count
; /* contains the count of how
989 many records are in the
990 local xattr storage. */
991 __le16 xh_free_start
; /* current offset for storing
993 __le16 xh_name_value_len
; /* total length of name/value
994 length in this bucket. */
995 __le16 xh_num_buckets
; /* Number of xattr buckets
996 in this extent record,
997 only valid in the first
999 struct ocfs2_block_check xh_check
; /* Error checking
1002 buckets. A block uses
1004 this field to zero.) */
1005 struct ocfs2_xattr_entry xh_entries
[0]; /* xattr entry list. */
1009 * On disk structure for xattr value root.
1011 * When an xattr's value is large enough, it is stored in an external
1012 * b-tree like file data. The xattr value root points to this structure.
1014 struct ocfs2_xattr_value_root
{
1015 /*00*/ __le32 xr_clusters
; /* clusters covered by xattr value. */
1016 __le32 xr_reserved0
;
1017 __le64 xr_last_eb_blk
; /* Pointer to last extent block */
1018 /*10*/ struct ocfs2_extent_list xr_list
; /* Extent record list */
1022 * On disk structure for xattr tree root.
1024 * It is used when there are too many extended attributes for one file. These
1025 * attributes will be organized and stored in an indexed-btree.
1027 struct ocfs2_xattr_tree_root
{
1028 /*00*/ __le32 xt_clusters
; /* clusters covered by xattr. */
1029 __le32 xt_reserved0
;
1030 __le64 xt_last_eb_blk
; /* Pointer to last extent block */
1031 /*10*/ struct ocfs2_extent_list xt_list
; /* Extent record list */
1034 #define OCFS2_XATTR_INDEXED 0x1
1035 #define OCFS2_HASH_SHIFT 5
1036 #define OCFS2_XATTR_ROUND 3
1037 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1038 ~(OCFS2_XATTR_ROUND))
1040 #define OCFS2_XATTR_BUCKET_SIZE 4096
1041 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1042 / OCFS2_MIN_BLOCKSIZE)
1045 * On disk structure for xattr block.
1047 struct ocfs2_xattr_block
{
1048 /*00*/ __u8 xb_signature
[8]; /* Signature for verification */
1049 __le16 xb_suballoc_slot
; /* Slot suballocator this
1050 block belongs to. */
1051 __le16 xb_suballoc_bit
; /* Bit offset in suballocator
1053 __le32 xb_fs_generation
; /* Must match super block */
1054 /*10*/ __le64 xb_blkno
; /* Offset on disk, in blocks */
1055 struct ocfs2_block_check xb_check
; /* Error checking */
1056 /*20*/ __le16 xb_flags
; /* Indicates whether this block contains
1057 real xattr or a xattr tree. */
1058 __le16 xb_reserved0
;
1059 __le32 xb_reserved1
;
1060 __le64 xb_suballoc_loc
; /* Suballocator block group this
1061 xattr block belongs to. Only
1062 valid if allocated from a
1063 discontiguous block group */
1065 struct ocfs2_xattr_header xb_header
; /* xattr header if this
1066 block contains xattr */
1067 struct ocfs2_xattr_tree_root xb_root
;/* xattr tree root if this
1073 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1074 #define OCFS2_XATTR_TYPE_MASK 0x7F
1075 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry
*xe
,
1079 xe
->xe_type
|= OCFS2_XATTR_ENTRY_LOCAL
;
1081 xe
->xe_type
&= ~OCFS2_XATTR_ENTRY_LOCAL
;
1084 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry
*xe
)
1086 return xe
->xe_type
& OCFS2_XATTR_ENTRY_LOCAL
;
1089 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry
*xe
, int type
)
1091 xe
->xe_type
|= type
& OCFS2_XATTR_TYPE_MASK
;
1094 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry
*xe
)
1096 return xe
->xe_type
& OCFS2_XATTR_TYPE_MASK
;
1100 * On disk structures for global quota file
1103 /* Magic numbers and known versions for global quota files */
1104 #define OCFS2_GLOBAL_QMAGICS {\
1105 0x0cf52470, /* USRQUOTA */ \
1106 0x0cf52471 /* GRPQUOTA */ \
1109 #define OCFS2_GLOBAL_QVERSIONS {\
1115 /* Each block of each quota file has a certain fixed number of bytes reserved
1116 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1117 * checksums, etc. */
1118 #define OCFS2_QBLK_RESERVED_SPACE 8
1120 /* Generic header of all quota files */
1121 struct ocfs2_disk_dqheader
{
1122 __le32 dqh_magic
; /* Magic number identifying file */
1123 __le32 dqh_version
; /* Quota format version */
1126 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1128 /* Information header of global quota file (immediately follows the generic
1130 struct ocfs2_global_disk_dqinfo
{
1131 /*00*/ __le32 dqi_bgrace
; /* Grace time for space softlimit excess */
1132 __le32 dqi_igrace
; /* Grace time for inode softlimit excess */
1133 __le32 dqi_syncms
; /* Time after which we sync local changes to
1134 * global quota file */
1135 __le32 dqi_blocks
; /* Number of blocks in quota file */
1136 /*10*/ __le32 dqi_free_blk
; /* First free block in quota file */
1137 __le32 dqi_free_entry
; /* First block with free dquot entry in quota
1141 /* Structure with global user / group information. We reserve some space
1142 * for future use. */
1143 struct ocfs2_global_disk_dqblk
{
1144 /*00*/ __le32 dqb_id
; /* ID the structure belongs to */
1145 __le32 dqb_use_count
; /* Number of nodes having reference to this structure */
1146 __le64 dqb_ihardlimit
; /* absolute limit on allocated inodes */
1147 /*10*/ __le64 dqb_isoftlimit
; /* preferred inode limit */
1148 __le64 dqb_curinodes
; /* current # allocated inodes */
1149 /*20*/ __le64 dqb_bhardlimit
; /* absolute limit on disk space */
1150 __le64 dqb_bsoftlimit
; /* preferred limit on disk space */
1151 /*30*/ __le64 dqb_curspace
; /* current space occupied */
1152 __le64 dqb_btime
; /* time limit for excessive disk use */
1153 /*40*/ __le64 dqb_itime
; /* time limit for excessive inode use */
1155 /*50*/ __le64 dqb_pad2
;
1159 * On-disk structures for local quota file
1162 /* Magic numbers and known versions for local quota files */
1163 #define OCFS2_LOCAL_QMAGICS {\
1164 0x0cf524c0, /* USRQUOTA */ \
1165 0x0cf524c1 /* GRPQUOTA */ \
1168 #define OCFS2_LOCAL_QVERSIONS {\
1173 /* Quota flags in dqinfo header */
1174 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1175 * quota has been cleanly turned off) */
1177 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1179 /* Information header of local quota file (immediately follows the generic
1181 struct ocfs2_local_disk_dqinfo
{
1182 __le32 dqi_flags
; /* Flags for quota file */
1183 __le32 dqi_chunks
; /* Number of chunks of quota structures
1185 __le32 dqi_blocks
; /* Number of blocks allocated for quota file */
1188 /* Header of one chunk of a quota file */
1189 struct ocfs2_local_disk_chunk
{
1190 __le32 dqc_free
; /* Number of free entries in the bitmap */
1191 __u8 dqc_bitmap
[0]; /* Bitmap of entries in the corresponding
1192 * chunk of quota file */
1195 /* One entry in local quota file */
1196 struct ocfs2_local_disk_dqblk
{
1197 /*00*/ __le64 dqb_id
; /* id this quota applies to */
1198 __le64 dqb_spacemod
; /* Change in the amount of used space */
1199 /*10*/ __le64 dqb_inodemod
; /* Change in the amount of used inodes */
1204 * The quota trailer lives at the end of each quota block.
1207 struct ocfs2_disk_dqtrailer
{
1208 /*00*/ struct ocfs2_block_check dq_check
; /* Error checking */
1209 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1212 static inline struct ocfs2_disk_dqtrailer
*ocfs2_block_dqtrailer(int blocksize
,
1216 ptr
+= blocksize
- OCFS2_QBLK_RESERVED_SPACE
;
1218 return (struct ocfs2_disk_dqtrailer
*)ptr
;
1222 static inline int ocfs2_fast_symlink_chars(struct super_block
*sb
)
1224 return sb
->s_blocksize
-
1225 offsetof(struct ocfs2_dinode
, id2
.i_symlink
);
1228 static inline int ocfs2_max_inline_data_with_xattr(struct super_block
*sb
,
1229 struct ocfs2_dinode
*di
)
1231 unsigned int xattrsize
= le16_to_cpu(di
->i_xattr_inline_size
);
1233 if (le16_to_cpu(di
->i_dyn_features
) & OCFS2_INLINE_XATTR_FL
)
1234 return sb
->s_blocksize
-
1235 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
) -
1238 return sb
->s_blocksize
-
1239 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
);
1242 static inline int ocfs2_extent_recs_per_inode(struct super_block
*sb
)
1246 size
= sb
->s_blocksize
-
1247 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1249 return size
/ sizeof(struct ocfs2_extent_rec
);
1252 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1253 struct super_block
*sb
,
1254 struct ocfs2_dinode
*di
)
1257 unsigned int xattrsize
= le16_to_cpu(di
->i_xattr_inline_size
);
1259 if (le16_to_cpu(di
->i_dyn_features
) & OCFS2_INLINE_XATTR_FL
)
1260 size
= sb
->s_blocksize
-
1261 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
) -
1264 size
= sb
->s_blocksize
-
1265 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1267 return size
/ sizeof(struct ocfs2_extent_rec
);
1270 static inline int ocfs2_extent_recs_per_dx_root(struct super_block
*sb
)
1274 size
= sb
->s_blocksize
-
1275 offsetof(struct ocfs2_dx_root_block
, dr_list
.l_recs
);
1277 return size
/ sizeof(struct ocfs2_extent_rec
);
1280 static inline int ocfs2_chain_recs_per_inode(struct super_block
*sb
)
1284 size
= sb
->s_blocksize
-
1285 offsetof(struct ocfs2_dinode
, id2
.i_chain
.cl_recs
);
1287 return size
/ sizeof(struct ocfs2_chain_rec
);
1290 static inline u16
ocfs2_extent_recs_per_eb(struct super_block
*sb
)
1294 size
= sb
->s_blocksize
-
1295 offsetof(struct ocfs2_extent_block
, h_list
.l_recs
);
1297 return size
/ sizeof(struct ocfs2_extent_rec
);
1300 static inline u16
ocfs2_extent_recs_per_gd(struct super_block
*sb
)
1304 size
= sb
->s_blocksize
-
1305 offsetof(struct ocfs2_group_desc
, bg_list
.l_recs
);
1307 return size
/ sizeof(struct ocfs2_extent_rec
);
1310 static inline int ocfs2_dx_entries_per_leaf(struct super_block
*sb
)
1314 size
= sb
->s_blocksize
-
1315 offsetof(struct ocfs2_dx_leaf
, dl_list
.de_entries
);
1317 return size
/ sizeof(struct ocfs2_dx_entry
);
1320 static inline int ocfs2_dx_entries_per_root(struct super_block
*sb
)
1324 size
= sb
->s_blocksize
-
1325 offsetof(struct ocfs2_dx_root_block
, dr_entries
.de_entries
);
1327 return size
/ sizeof(struct ocfs2_dx_entry
);
1330 static inline u16
ocfs2_local_alloc_size(struct super_block
*sb
)
1334 size
= sb
->s_blocksize
-
1335 offsetof(struct ocfs2_dinode
, id2
.i_lab
.la_bitmap
);
1340 static inline int ocfs2_group_bitmap_size(struct super_block
*sb
,
1342 u32 feature_incompat
)
1344 int size
= sb
->s_blocksize
-
1345 offsetof(struct ocfs2_group_desc
, bg_bitmap
);
1348 * The cluster allocator uses the entire block. Suballocators have
1349 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1350 * code expects bg_size set to the maximum. Thus we must keep
1351 * bg_size as-is unless discontig_bg is enabled.
1354 (feature_incompat
& OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG
))
1355 size
= OCFS2_MAX_BG_BITMAP_SIZE
;
1360 static inline int ocfs2_truncate_recs_per_inode(struct super_block
*sb
)
1364 size
= sb
->s_blocksize
-
1365 offsetof(struct ocfs2_dinode
, id2
.i_dealloc
.tl_recs
);
1367 return size
/ sizeof(struct ocfs2_truncate_rec
);
1370 static inline u64
ocfs2_backup_super_blkno(struct super_block
*sb
, int index
)
1372 u64 offset
= OCFS2_BACKUP_SB_START
;
1374 if (index
>= 0 && index
< OCFS2_MAX_BACKUP_SUPERBLOCKS
) {
1375 offset
<<= (2 * index
);
1376 offset
>>= sb
->s_blocksize_bits
;
1384 static inline u16
ocfs2_xattr_recs_per_xb(struct super_block
*sb
)
1388 size
= sb
->s_blocksize
-
1389 offsetof(struct ocfs2_xattr_block
,
1390 xb_attrs
.xb_root
.xt_list
.l_recs
);
1392 return size
/ sizeof(struct ocfs2_extent_rec
);
1395 static inline u16
ocfs2_extent_recs_per_rb(struct super_block
*sb
)
1399 size
= sb
->s_blocksize
-
1400 offsetof(struct ocfs2_refcount_block
, rf_list
.l_recs
);
1402 return size
/ sizeof(struct ocfs2_extent_rec
);
1405 static inline u16
ocfs2_refcount_recs_per_rb(struct super_block
*sb
)
1409 size
= sb
->s_blocksize
-
1410 offsetof(struct ocfs2_refcount_block
, rf_records
.rl_recs
);
1412 return size
/ sizeof(struct ocfs2_refcount_rec
);
1416 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec
*rec
)
1418 return le64_to_cpu(rec
->r_cpos
) & OCFS2_32BIT_POS_MASK
;
1421 static inline int ocfs2_fast_symlink_chars(int blocksize
)
1423 return blocksize
- offsetof(struct ocfs2_dinode
, id2
.i_symlink
);
1426 static inline int ocfs2_max_inline_data_with_xattr(int blocksize
,
1427 struct ocfs2_dinode
*di
)
1429 if (di
&& (di
->i_dyn_features
& OCFS2_INLINE_XATTR_FL
))
1431 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
) -
1432 di
->i_xattr_inline_size
;
1435 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
);
1438 static inline int ocfs2_extent_recs_per_inode(int blocksize
)
1443 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1445 return size
/ sizeof(struct ocfs2_extent_rec
);
1448 static inline int ocfs2_chain_recs_per_inode(int blocksize
)
1453 offsetof(struct ocfs2_dinode
, id2
.i_chain
.cl_recs
);
1455 return size
/ sizeof(struct ocfs2_chain_rec
);
1458 static inline int ocfs2_extent_recs_per_eb(int blocksize
)
1463 offsetof(struct ocfs2_extent_block
, h_list
.l_recs
);
1465 return size
/ sizeof(struct ocfs2_extent_rec
);
1468 static inline int ocfs2_extent_recs_per_gd(int blocksize
)
1473 offsetof(struct ocfs2_group_desc
, bg_list
.l_recs
);
1475 return size
/ sizeof(struct ocfs2_extent_rec
);
1478 static inline int ocfs2_local_alloc_size(int blocksize
)
1483 offsetof(struct ocfs2_dinode
, id2
.i_lab
.la_bitmap
);
1488 static inline int ocfs2_group_bitmap_size(int blocksize
,
1490 uint32_t feature_incompat
)
1492 int size
= sb
->s_blocksize
-
1493 offsetof(struct ocfs2_group_desc
, bg_bitmap
);
1496 * The cluster allocator uses the entire block. Suballocators have
1497 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1498 * code expects bg_size set to the maximum. Thus we must keep
1499 * bg_size as-is unless discontig_bg is enabled.
1502 (feature_incompat
& OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG
))
1503 size
= OCFS2_MAX_BG_BITMAP_SIZE
;
1508 static inline int ocfs2_truncate_recs_per_inode(int blocksize
)
1513 offsetof(struct ocfs2_dinode
, id2
.i_dealloc
.tl_recs
);
1515 return size
/ sizeof(struct ocfs2_truncate_rec
);
1518 static inline uint64_t ocfs2_backup_super_blkno(int blocksize
, int index
)
1520 uint64_t offset
= OCFS2_BACKUP_SB_START
;
1522 if (index
>= 0 && index
< OCFS2_MAX_BACKUP_SUPERBLOCKS
) {
1523 offset
<<= (2 * index
);
1524 offset
/= blocksize
;
1531 static inline int ocfs2_xattr_recs_per_xb(int blocksize
)
1536 offsetof(struct ocfs2_xattr_block
,
1537 xb_attrs
.xb_root
.xt_list
.l_recs
);
1539 return size
/ sizeof(struct ocfs2_extent_rec
);
1541 #endif /* __KERNEL__ */
1544 static inline int ocfs2_system_inode_is_global(int type
)
1546 return ((type
>= 0) &&
1547 (type
<= OCFS2_LAST_GLOBAL_SYSTEM_INODE
));
1550 static inline int ocfs2_sprintf_system_inode_name(char *buf
, int len
,
1556 * Global system inodes can only have one copy. Everything
1557 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1558 * list has a copy per slot.
1560 if (type
<= OCFS2_LAST_GLOBAL_SYSTEM_INODE
)
1561 chars
= snprintf(buf
, len
, "%s",
1562 ocfs2_system_inodes
[type
].si_name
);
1564 chars
= snprintf(buf
, len
,
1565 ocfs2_system_inodes
[type
].si_name
,
1571 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry
*de
,
1574 de
->file_type
= ocfs2_type_by_mode
[(mode
& S_IFMT
)>>S_SHIFT
];
1577 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc
*gd
)
1579 if ((offsetof(struct ocfs2_group_desc
, bg_bitmap
) +
1580 le16_to_cpu(gd
->bg_size
)) !=
1581 offsetof(struct ocfs2_group_desc
, bg_list
))
1584 * Only valid to check l_next_free_rec if
1585 * bg_bitmap + bg_size == bg_list.
1587 if (!gd
->bg_list
.l_next_free_rec
)
1591 #endif /* _OCFS2_FS_H */