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
169 * backup superblock flag is used to indicate that this volume
170 * has backup superblocks.
172 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
175 * The filesystem will correctly handle journal feature bits.
177 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
180 * Unwritten extents support.
182 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
185 * Maintain quota information for this filesystem
187 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
188 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
190 /* The byte offset of the first backup block will be 1G.
191 * The following will be 4G, 16G, 64G, 256G and 1T.
193 #define OCFS2_BACKUP_SB_START 1 << 30
195 /* the max backup superblock nums */
196 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
199 * Flags on ocfs2_super_block.s_tunefs_flags
201 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
204 * Flags on ocfs2_dinode.i_flags
206 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
207 #define OCFS2_UNUSED2_FL (0x00000002)
208 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
209 #define OCFS2_UNUSED3_FL (0x00000008)
210 /* System inode flags */
211 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
212 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
213 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
214 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
215 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
216 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
217 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
218 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
219 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
222 * Flags on ocfs2_dinode.i_dyn_features
224 * These can change much more often than i_flags. When adding flags,
225 * keep in mind that i_dyn_features is only 16 bits wide.
227 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
228 #define OCFS2_HAS_XATTR_FL (0x0002)
229 #define OCFS2_INLINE_XATTR_FL (0x0004)
230 #define OCFS2_INDEXED_DIR_FL (0x0008)
231 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
233 /* Inode attributes, keep in sync with EXT2 */
234 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
235 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
236 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
237 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
238 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
239 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
240 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
241 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
242 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
244 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
245 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
248 * Extent record flags (e_node.leaf.flags)
250 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
252 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
253 * counted in an associated
257 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
259 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
262 * superblock s_state flags
264 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
266 /* Limit of space in ocfs2_dir_entry */
267 #define OCFS2_MAX_FILENAME_LEN 255
269 /* Maximum slots on an ocfs2 file system */
270 #define OCFS2_MAX_SLOTS 255
272 /* Slot map indicator for an empty slot */
273 #define OCFS2_INVALID_SLOT -1
275 #define OCFS2_VOL_UUID_LEN 16
276 #define OCFS2_MAX_VOL_LABEL_LEN 64
278 /* The alternate, userspace stack fields */
279 #define OCFS2_STACK_LABEL_LEN 4
280 #define OCFS2_CLUSTER_NAME_LEN 16
282 /* Journal limits (in bytes) */
283 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
286 * Default local alloc size (in megabytes)
288 * The value chosen should be such that most allocations, including new
289 * block groups, use local alloc.
291 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
294 * Inline extended attribute size (in bytes)
295 * The value chosen should be aligned to 16 byte boundaries.
297 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
299 struct ocfs2_system_inode_info
{
305 /* System file index */
307 BAD_BLOCK_SYSTEM_INODE
= 0,
308 GLOBAL_INODE_ALLOC_SYSTEM_INODE
,
309 SLOT_MAP_SYSTEM_INODE
,
310 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
311 HEARTBEAT_SYSTEM_INODE
,
312 GLOBAL_BITMAP_SYSTEM_INODE
,
313 USER_QUOTA_SYSTEM_INODE
,
314 GROUP_QUOTA_SYSTEM_INODE
,
315 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
316 ORPHAN_DIR_SYSTEM_INODE
,
317 EXTENT_ALLOC_SYSTEM_INODE
,
318 INODE_ALLOC_SYSTEM_INODE
,
319 JOURNAL_SYSTEM_INODE
,
320 LOCAL_ALLOC_SYSTEM_INODE
,
321 TRUNCATE_LOG_SYSTEM_INODE
,
322 LOCAL_USER_QUOTA_SYSTEM_INODE
,
323 LOCAL_GROUP_QUOTA_SYSTEM_INODE
,
327 static struct ocfs2_system_inode_info ocfs2_system_inodes
[NUM_SYSTEM_INODES
] = {
328 /* Global system inodes (single copy) */
329 /* The first two are only used from userspace mfks/tunefs */
330 [BAD_BLOCK_SYSTEM_INODE
] = { "bad_blocks", 0, S_IFREG
| 0644 },
331 [GLOBAL_INODE_ALLOC_SYSTEM_INODE
] = { "global_inode_alloc", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
333 /* These are used by the running filesystem */
334 [SLOT_MAP_SYSTEM_INODE
] = { "slot_map", 0, S_IFREG
| 0644 },
335 [HEARTBEAT_SYSTEM_INODE
] = { "heartbeat", OCFS2_HEARTBEAT_FL
, S_IFREG
| 0644 },
336 [GLOBAL_BITMAP_SYSTEM_INODE
] = { "global_bitmap", 0, S_IFREG
| 0644 },
337 [USER_QUOTA_SYSTEM_INODE
] = { "aquota.user", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
338 [GROUP_QUOTA_SYSTEM_INODE
] = { "aquota.group", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
340 /* Slot-specific system inodes (one copy per slot) */
341 [ORPHAN_DIR_SYSTEM_INODE
] = { "orphan_dir:%04d", 0, S_IFDIR
| 0755 },
342 [EXTENT_ALLOC_SYSTEM_INODE
] = { "extent_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
343 [INODE_ALLOC_SYSTEM_INODE
] = { "inode_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_CHAIN_FL
, S_IFREG
| 0644 },
344 [JOURNAL_SYSTEM_INODE
] = { "journal:%04d", OCFS2_JOURNAL_FL
, S_IFREG
| 0644 },
345 [LOCAL_ALLOC_SYSTEM_INODE
] = { "local_alloc:%04d", OCFS2_BITMAP_FL
| OCFS2_LOCAL_ALLOC_FL
, S_IFREG
| 0644 },
346 [TRUNCATE_LOG_SYSTEM_INODE
] = { "truncate_log:%04d", OCFS2_DEALLOC_FL
, S_IFREG
| 0644 },
347 [LOCAL_USER_QUOTA_SYSTEM_INODE
] = { "aquota.user:%04d", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
348 [LOCAL_GROUP_QUOTA_SYSTEM_INODE
] = { "aquota.group:%04d", OCFS2_QUOTA_FL
, S_IFREG
| 0644 },
351 /* Parameter passed from mount.ocfs2 to module */
352 #define OCFS2_HB_NONE "heartbeat=none"
353 #define OCFS2_HB_LOCAL "heartbeat=local"
356 * OCFS2 directory file types. Only the low 3 bits are used. The
357 * other bits are reserved for now.
359 #define OCFS2_FT_UNKNOWN 0
360 #define OCFS2_FT_REG_FILE 1
361 #define OCFS2_FT_DIR 2
362 #define OCFS2_FT_CHRDEV 3
363 #define OCFS2_FT_BLKDEV 4
364 #define OCFS2_FT_FIFO 5
365 #define OCFS2_FT_SOCK 6
366 #define OCFS2_FT_SYMLINK 7
368 #define OCFS2_FT_MAX 8
371 * OCFS2_DIR_PAD defines the directory entries boundaries
373 * NOTE: It must be a multiple of 4
375 #define OCFS2_DIR_PAD 4
376 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
377 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
378 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
381 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
383 #define OCFS2_LINK_MAX 32000
384 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
385 #define OCFS2_LINKS_HI_SHIFT 16
386 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
389 static unsigned char ocfs2_type_by_mode
[S_IFMT
>> S_SHIFT
] = {
390 [S_IFREG
>> S_SHIFT
] = OCFS2_FT_REG_FILE
,
391 [S_IFDIR
>> S_SHIFT
] = OCFS2_FT_DIR
,
392 [S_IFCHR
>> S_SHIFT
] = OCFS2_FT_CHRDEV
,
393 [S_IFBLK
>> S_SHIFT
] = OCFS2_FT_BLKDEV
,
394 [S_IFIFO
>> S_SHIFT
] = OCFS2_FT_FIFO
,
395 [S_IFSOCK
>> S_SHIFT
] = OCFS2_FT_SOCK
,
396 [S_IFLNK
>> S_SHIFT
] = OCFS2_FT_SYMLINK
,
403 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
406 * Block checking structure. This is used in metadata to validate the
407 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
410 struct ocfs2_block_check
{
411 /*00*/ __le32 bc_crc32e
; /* 802.3 Ethernet II CRC32 */
412 __le16 bc_ecc
; /* Single-error-correction parity vector.
413 This is a simple Hamming code dependant
414 on the blocksize. OCFS2's maximum
415 blocksize, 4K, requires 16 parity bits,
416 so we fit in __le16. */
422 * On disk extent record for OCFS2
423 * It describes a range of clusters on disk.
425 * Length fields are divided into interior and leaf node versions.
426 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
428 struct ocfs2_extent_rec
{
429 /*00*/ __le32 e_cpos
; /* Offset into the file, in clusters */
431 __le32 e_int_clusters
; /* Clusters covered by all children */
433 __le16 e_leaf_clusters
; /* Clusters covered by this
436 __u8 e_flags
; /* Extent flags */
439 __le64 e_blkno
; /* Physical disk offset, in blocks */
443 struct ocfs2_chain_rec
{
444 __le32 c_free
; /* Number of free bits in this chain. */
445 __le32 c_total
; /* Number of total bits in this chain */
446 __le64 c_blkno
; /* Physical disk offset (blocks) of 1st group */
449 struct ocfs2_truncate_rec
{
450 __le32 t_start
; /* 1st cluster in this log */
451 __le32 t_clusters
; /* Number of total clusters covered */
455 * On disk extent list for OCFS2 (node in the tree). Note that this
456 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
457 * offsets are relative to ocfs2_dinode.id2.i_list or
458 * ocfs2_extent_block.h_list, respectively.
460 struct ocfs2_extent_list
{
461 /*00*/ __le16 l_tree_depth
; /* Extent tree depth from this
462 point. 0 means data extents
463 hang directly off this
465 NOTE: The high 8 bits cannot be
466 used - tree_depth is never that big.
468 __le16 l_count
; /* Number of extent records */
469 __le16 l_next_free_rec
; /* Next unused extent slot */
471 __le64 l_reserved2
; /* Pad to
472 sizeof(ocfs2_extent_rec) */
473 /*10*/ struct ocfs2_extent_rec l_recs
[0]; /* Extent records */
477 * On disk allocation chain list for OCFS2. Note that this is
478 * contained inside ocfs2_dinode, so the offsets are relative to
479 * ocfs2_dinode.id2.i_chain.
481 struct ocfs2_chain_list
{
482 /*00*/ __le16 cl_cpg
; /* Clusters per Block Group */
483 __le16 cl_bpc
; /* Bits per cluster */
484 __le16 cl_count
; /* Total chains in this list */
485 __le16 cl_next_free_rec
; /* Next unused chain slot */
487 /*10*/ struct ocfs2_chain_rec cl_recs
[0]; /* Chain records */
491 * On disk deallocation log for OCFS2. Note that this is
492 * contained inside ocfs2_dinode, so the offsets are relative to
493 * ocfs2_dinode.id2.i_dealloc.
495 struct ocfs2_truncate_log
{
496 /*00*/ __le16 tl_count
; /* Total records in this log */
497 __le16 tl_used
; /* Number of records in use */
499 /*08*/ struct ocfs2_truncate_rec tl_recs
[0]; /* Truncate records */
503 * On disk extent block (indirect block) for OCFS2
505 struct ocfs2_extent_block
507 /*00*/ __u8 h_signature
[8]; /* Signature for verification */
508 struct ocfs2_block_check h_check
; /* Error checking */
509 /*10*/ __le16 h_suballoc_slot
; /* Slot suballocator this
510 extent_header belongs to */
511 __le16 h_suballoc_bit
; /* Bit offset in suballocator
513 __le32 h_fs_generation
; /* Must match super block */
514 __le64 h_blkno
; /* Offset on disk, in blocks */
515 /*20*/ __le64 h_reserved3
;
516 __le64 h_next_leaf_blk
; /* Offset on disk, in blocks,
517 of next leaf header pointing
519 /*30*/ struct ocfs2_extent_list h_list
; /* Extent record list */
520 /* Actual on-disk size is one block */
524 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
525 * system file. A slot is valid if it contains a node number >= 0. The
526 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
528 struct ocfs2_slot_map
{
529 /*00*/ __le16 sm_slots
[0];
531 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
532 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
536 struct ocfs2_extended_slot
{
537 /*00*/ __u8 es_valid
;
538 __u8 es_reserved1
[3];
544 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
545 * is set. It separates out the valid marker from the node number, and
546 * has room to grow. Unlike the old slot map, this format is defined by
549 struct ocfs2_slot_map_extended
{
550 /*00*/ struct ocfs2_extended_slot se_slots
[0];
552 * Actual size is i_size of the slot_map system file. It should
553 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
557 struct ocfs2_cluster_info
{
558 /*00*/ __u8 ci_stack
[OCFS2_STACK_LABEL_LEN
];
560 /*08*/ __u8 ci_cluster
[OCFS2_CLUSTER_NAME_LEN
];
565 * On disk superblock for OCFS2
566 * Note that it is contained inside an ocfs2_dinode, so all offsets
567 * are relative to the start of ocfs2_dinode.id2.
569 struct ocfs2_super_block
{
570 /*00*/ __le16 s_major_rev_level
;
571 __le16 s_minor_rev_level
;
573 __le16 s_max_mnt_count
;
574 __le16 s_state
; /* File system state */
575 __le16 s_errors
; /* Behaviour when detecting errors */
576 __le32 s_checkinterval
; /* Max time between checks */
577 /*10*/ __le64 s_lastcheck
; /* Time of last check */
578 __le32 s_creator_os
; /* OS */
579 __le32 s_feature_compat
; /* Compatible feature set */
580 /*20*/ __le32 s_feature_incompat
; /* Incompatible feature set */
581 __le32 s_feature_ro_compat
; /* Readonly-compatible feature set */
582 __le64 s_root_blkno
; /* Offset, in blocks, of root directory
584 /*30*/ __le64 s_system_dir_blkno
; /* Offset, in blocks, of system
586 __le32 s_blocksize_bits
; /* Blocksize for this fs */
587 __le32 s_clustersize_bits
; /* Clustersize for this fs */
588 /*40*/ __le16 s_max_slots
; /* Max number of simultaneous mounts
589 before tunefs required */
590 __le16 s_tunefs_flag
;
591 __le32 s_uuid_hash
; /* hash value of uuid */
592 __le64 s_first_cluster_group
; /* Block offset of 1st cluster
594 /*50*/ __u8 s_label
[OCFS2_MAX_VOL_LABEL_LEN
]; /* Label for mounting, etc. */
595 /*90*/ __u8 s_uuid
[OCFS2_VOL_UUID_LEN
]; /* 128-bit uuid */
596 /*A0*/ struct ocfs2_cluster_info s_cluster_info
; /* Selected userspace
598 with INCOMPAT flag. */
599 /*B8*/ __le16 s_xattr_inline_size
; /* extended attribute inline size
602 __le32 s_dx_seed
[3]; /* seed[0-2] for dx dir hash.
603 * s_uuid_hash serves as seed[3]. */
604 /*C0*/ __le64 s_reserved2
[15]; /* Fill out superblock */
608 * NOTE: As stated above, all offsets are relative to
609 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
610 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
611 * our smallest blocksize, which is 512 bytes. To ensure this,
612 * we reserve the space in s_reserved2. Anything past s_reserved2
613 * will not be available on the smallest blocksize.
618 * Local allocation bitmap for OCFS2 slots
619 * Note that it exists inside an ocfs2_dinode, so all offsets are
620 * relative to the start of ocfs2_dinode.id2.
622 struct ocfs2_local_alloc
624 /*00*/ __le32 la_bm_off
; /* Starting bit offset in main bitmap */
625 __le16 la_size
; /* Size of included bitmap, in bytes */
628 /*10*/ __u8 la_bitmap
[0];
632 * Data-in-inode header. This is only used if i_dyn_features has
633 * OCFS2_INLINE_DATA_FL set.
635 struct ocfs2_inline_data
637 /*00*/ __le16 id_count
; /* Number of bytes that can be used
638 * for data, starting at id_data */
641 __u8 id_data
[0]; /* Start of user data */
645 * On disk inode for OCFS2
647 struct ocfs2_dinode
{
648 /*00*/ __u8 i_signature
[8]; /* Signature for validation */
649 __le32 i_generation
; /* Generation number */
650 __le16 i_suballoc_slot
; /* Slot suballocator this inode
652 __le16 i_suballoc_bit
; /* Bit offset in suballocator
654 /*10*/ __le16 i_links_count_hi
; /* High 16 bits of links count */
655 __le16 i_xattr_inline_size
;
656 __le32 i_clusters
; /* Cluster count */
657 __le32 i_uid
; /* Owner UID */
658 __le32 i_gid
; /* Owning GID */
659 /*20*/ __le64 i_size
; /* Size in bytes */
660 __le16 i_mode
; /* File mode */
661 __le16 i_links_count
; /* Links count */
662 __le32 i_flags
; /* File flags */
663 /*30*/ __le64 i_atime
; /* Access time */
664 __le64 i_ctime
; /* Creation time */
665 /*40*/ __le64 i_mtime
; /* Modification time */
666 __le64 i_dtime
; /* Deletion time */
667 /*50*/ __le64 i_blkno
; /* Offset on disk, in blocks */
668 __le64 i_last_eb_blk
; /* Pointer to last extent
670 /*60*/ __le32 i_fs_generation
; /* Generation per fs-instance */
674 /*70*/ __le32 i_attr
;
675 __le16 i_orphaned_slot
; /* Only valid when OCFS2_ORPHANED_FL
676 was set in i_flags */
677 __le16 i_dyn_features
;
679 /*80*/ struct ocfs2_block_check i_check
; /* Error checking */
680 /*88*/ __le64 i_dx_root
; /* Pointer to dir index root block */
681 /*90*/ __le64 i_refcount_loc
;
682 __le64 i_reserved2
[4];
684 __le64 i_pad1
; /* Generic way to refer to this
687 __le64 i_rdev
; /* Device number */
689 struct { /* Info for bitmap system
691 __le32 i_used
; /* Bits (ie, clusters) used */
692 __le32 i_total
; /* Total bits (clusters)
695 struct { /* Info for journal system
697 __le32 ij_flags
; /* Mounted, version, etc. */
698 __le32 ij_recovery_generation
; /* Incremented when the
703 } id1
; /* Inode type dependant 1 */
705 struct ocfs2_super_block i_super
;
706 struct ocfs2_local_alloc i_lab
;
707 struct ocfs2_chain_list i_chain
;
708 struct ocfs2_extent_list i_list
;
709 struct ocfs2_truncate_log i_dealloc
;
710 struct ocfs2_inline_data i_data
;
713 /* Actual on-disk size is one block */
717 * On-disk directory entry structure for OCFS2
719 * Packed as this structure could be accessed unaligned on 64-bit platforms
721 struct ocfs2_dir_entry
{
722 /*00*/ __le64 inode
; /* Inode number */
723 __le16 rec_len
; /* Directory entry length */
724 __u8 name_len
; /* Name length */
726 /*0C*/ char name
[OCFS2_MAX_FILENAME_LEN
]; /* File name */
727 /* Actual on-disk length specified by rec_len */
728 } __attribute__ ((packed
));
731 * Per-block record for the unindexed directory btree. This is carefully
732 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
733 * mirrored. That way, the directory manipulation code needs a minimal amount
736 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
738 struct ocfs2_dir_block_trailer
{
739 /*00*/ __le64 db_compat_inode
; /* Always zero. Was inode */
741 __le16 db_compat_rec_len
; /* Backwards compatible with
742 * ocfs2_dir_entry. */
743 __u8 db_compat_name_len
; /* Always zero. Was name_len */
746 __le16 db_free_rec_len
; /* Size of largest empty hole
747 * in this block. (unused) */
748 /*10*/ __u8 db_signature
[8]; /* Signature for verification */
750 __le64 db_free_next
; /* Next block in list (unused) */
751 /*20*/ __le64 db_blkno
; /* Offset on disk, in blocks */
752 __le64 db_parent_dinode
; /* dinode which owns me, in
754 /*30*/ struct ocfs2_block_check db_check
; /* Error checking */
759 * A directory entry in the indexed tree. We don't store the full name here,
760 * but instead provide a pointer to the full dirent in the unindexed tree.
762 * We also store name_len here so as to reduce the number of leaf blocks we
763 * need to search in case of collisions.
765 struct ocfs2_dx_entry
{
766 __le32 dx_major_hash
; /* Used to find logical
767 * cluster in index */
768 __le32 dx_minor_hash
; /* Lower bits used to find
769 * block in cluster */
770 __le64 dx_dirent_blk
; /* Physical block in unindexed
771 * tree holding this dirent. */
774 struct ocfs2_dx_entry_list
{
776 __le16 de_count
; /* Maximum number of entries
777 * possible in de_entries */
778 __le16 de_num_used
; /* Current number of
779 * de_entries entries */
780 struct ocfs2_dx_entry de_entries
[0]; /* Indexed dir entries
781 * in a packed array of
782 * length de_num_used */
785 #define OCFS2_DX_FLAG_INLINE 0x01
788 * A directory indexing block. Each indexed directory has one of these,
789 * pointed to by ocfs2_dinode.
791 * This block stores an indexed btree root, and a set of free space
792 * start-of-list pointers.
794 struct ocfs2_dx_root_block
{
795 __u8 dr_signature
[8]; /* Signature for verification */
796 struct ocfs2_block_check dr_check
; /* Error checking */
797 __le16 dr_suballoc_slot
; /* Slot suballocator this
798 * block belongs to. */
799 __le16 dr_suballoc_bit
; /* Bit offset in suballocator
801 __le32 dr_fs_generation
; /* Must match super block */
802 __le64 dr_blkno
; /* Offset on disk, in blocks */
803 __le64 dr_last_eb_blk
; /* Pointer to last
805 __le32 dr_clusters
; /* Clusters allocated
806 * to the indexed tree. */
807 __u8 dr_flags
; /* OCFS2_DX_FLAG_* flags */
810 __le64 dr_dir_blkno
; /* Pointer to parent inode */
811 __le32 dr_num_entries
; /* Total number of
815 __le64 dr_free_blk
; /* Pointer to head of free
816 * unindexed block list. */
817 __le64 dr_reserved3
[15];
819 struct ocfs2_extent_list dr_list
; /* Keep this aligned to 128
820 * bits for maximum space
822 struct ocfs2_dx_entry_list dr_entries
; /* In-root-block list of
823 * entries. We grow out
830 * The header of a leaf block in the indexed tree.
832 struct ocfs2_dx_leaf
{
833 __u8 dl_signature
[8];/* Signature for verification */
834 struct ocfs2_block_check dl_check
; /* Error checking */
835 __le64 dl_blkno
; /* Offset on disk, in blocks */
836 __le32 dl_fs_generation
;/* Must match super block */
839 struct ocfs2_dx_entry_list dl_list
;
843 * On disk allocator group structure for OCFS2
845 struct ocfs2_group_desc
847 /*00*/ __u8 bg_signature
[8]; /* Signature for validation */
848 __le16 bg_size
; /* Size of included bitmap in
850 __le16 bg_bits
; /* Bits represented by this
852 __le16 bg_free_bits_count
; /* Free bits count */
853 __le16 bg_chain
; /* What chain I am in. */
854 /*10*/ __le32 bg_generation
;
856 __le64 bg_next_group
; /* Next group in my list, in
858 /*20*/ __le64 bg_parent_dinode
; /* dinode which owns me, in
860 __le64 bg_blkno
; /* Offset on disk, in blocks */
861 /*30*/ struct ocfs2_block_check bg_check
; /* Error checking */
863 /*40*/ __u8 bg_bitmap
[0];
866 struct ocfs2_refcount_rec
{
867 /*00*/ __le64 r_cpos
; /* Physical offset, in clusters */
868 __le32 r_clusters
; /* Clusters covered by this extent */
869 __le32 r_refcount
; /* Reference count of this extent */
872 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
874 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
875 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
877 struct ocfs2_refcount_list
{
878 /*00*/ __le16 rl_count
; /* Maximum number of entries possible
880 __le16 rl_used
; /* Current number of used records */
882 __le64 rl_reserved1
; /* Pad to sizeof(ocfs2_refcount_record) */
883 /*10*/ struct ocfs2_refcount_rec rl_recs
[0]; /* Refcount records */
887 struct ocfs2_refcount_block
{
888 /*00*/ __u8 rf_signature
[8]; /* Signature for verification */
889 __le16 rf_suballoc_slot
; /* Slot suballocator this block
891 __le16 rf_suballoc_bit
; /* Bit offset in suballocator
893 __le32 rf_fs_generation
; /* Must match superblock */
894 /*10*/ __le64 rf_blkno
; /* Offset on disk, in blocks */
895 __le64 rf_parent
; /* Parent block, only valid if
896 OCFS2_REFCOUNT_LEAF_FL is set in
898 /*20*/ struct ocfs2_block_check rf_check
; /* Error checking */
899 __le64 rf_last_eb_blk
; /* Pointer to last extent block */
900 /*30*/ __le32 rf_count
; /* Number of inodes sharing this
902 __le32 rf_flags
; /* See the flags above */
903 __le32 rf_clusters
; /* clusters covered by refcount tree. */
904 __le32 rf_cpos
; /* cluster offset in refcount tree.*/
905 /*40*/ __le32 rf_generation
; /* generation number. all be the same
906 * for the same refcount tree. */
908 __le64 rf_reserved1
[7];
910 struct ocfs2_refcount_list rf_records
; /* List of refcount
912 struct ocfs2_extent_list rf_list
; /* Extent record list,
914 OCFS2_REFCOUNT_TREE_FL
915 is set in rf_flags */
917 /* Actual on-disk size is one block */
921 * On disk extended attribute structure for OCFS2.
925 * ocfs2_xattr_entry indicates one extend attribute.
927 * Note that it can be stored in inode, one block or one xattr bucket.
929 struct ocfs2_xattr_entry
{
930 __le32 xe_name_hash
; /* hash value of xattr prefix+suffix. */
931 __le16 xe_name_offset
; /* byte offset from the 1st entry in the
932 local xattr storage(inode, xattr block or
934 __u8 xe_name_len
; /* xattr name len, does't include prefix. */
935 __u8 xe_type
; /* the low 7 bits indicate the name prefix
936 * type and the highest bit indicates whether
937 * the EA is stored in the local storage. */
938 __le64 xe_value_size
; /* real xattr value length. */
942 * On disk structure for xattr header.
944 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
945 * the local xattr storage.
947 struct ocfs2_xattr_header
{
948 __le16 xh_count
; /* contains the count of how
949 many records are in the
950 local xattr storage. */
951 __le16 xh_free_start
; /* current offset for storing
953 __le16 xh_name_value_len
; /* total length of name/value
954 length in this bucket. */
955 __le16 xh_num_buckets
; /* Number of xattr buckets
956 in this extent record,
957 only valid in the first
959 struct ocfs2_block_check xh_check
; /* Error checking
962 buckets. A block uses
964 this field to zero.) */
965 struct ocfs2_xattr_entry xh_entries
[0]; /* xattr entry list. */
969 * On disk structure for xattr value root.
971 * When an xattr's value is large enough, it is stored in an external
972 * b-tree like file data. The xattr value root points to this structure.
974 struct ocfs2_xattr_value_root
{
975 /*00*/ __le32 xr_clusters
; /* clusters covered by xattr value. */
977 __le64 xr_last_eb_blk
; /* Pointer to last extent block */
978 /*10*/ struct ocfs2_extent_list xr_list
; /* Extent record list */
982 * On disk structure for xattr tree root.
984 * It is used when there are too many extended attributes for one file. These
985 * attributes will be organized and stored in an indexed-btree.
987 struct ocfs2_xattr_tree_root
{
988 /*00*/ __le32 xt_clusters
; /* clusters covered by xattr. */
990 __le64 xt_last_eb_blk
; /* Pointer to last extent block */
991 /*10*/ struct ocfs2_extent_list xt_list
; /* Extent record list */
994 #define OCFS2_XATTR_INDEXED 0x1
995 #define OCFS2_HASH_SHIFT 5
996 #define OCFS2_XATTR_ROUND 3
997 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
998 ~(OCFS2_XATTR_ROUND))
1000 #define OCFS2_XATTR_BUCKET_SIZE 4096
1001 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1002 / OCFS2_MIN_BLOCKSIZE)
1005 * On disk structure for xattr block.
1007 struct ocfs2_xattr_block
{
1008 /*00*/ __u8 xb_signature
[8]; /* Signature for verification */
1009 __le16 xb_suballoc_slot
; /* Slot suballocator this
1010 block belongs to. */
1011 __le16 xb_suballoc_bit
; /* Bit offset in suballocator
1013 __le32 xb_fs_generation
; /* Must match super block */
1014 /*10*/ __le64 xb_blkno
; /* Offset on disk, in blocks */
1015 struct ocfs2_block_check xb_check
; /* Error checking */
1016 /*20*/ __le16 xb_flags
; /* Indicates whether this block contains
1017 real xattr or a xattr tree. */
1018 __le16 xb_reserved0
;
1019 __le32 xb_reserved1
;
1020 __le64 xb_reserved2
;
1022 struct ocfs2_xattr_header xb_header
; /* xattr header if this
1023 block contains xattr */
1024 struct ocfs2_xattr_tree_root xb_root
;/* xattr tree root if this
1030 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1031 #define OCFS2_XATTR_TYPE_MASK 0x7F
1032 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry
*xe
,
1036 xe
->xe_type
|= OCFS2_XATTR_ENTRY_LOCAL
;
1038 xe
->xe_type
&= ~OCFS2_XATTR_ENTRY_LOCAL
;
1041 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry
*xe
)
1043 return xe
->xe_type
& OCFS2_XATTR_ENTRY_LOCAL
;
1046 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry
*xe
, int type
)
1048 xe
->xe_type
|= type
& OCFS2_XATTR_TYPE_MASK
;
1051 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry
*xe
)
1053 return xe
->xe_type
& OCFS2_XATTR_TYPE_MASK
;
1057 * On disk structures for global quota file
1060 /* Magic numbers and known versions for global quota files */
1061 #define OCFS2_GLOBAL_QMAGICS {\
1062 0x0cf52470, /* USRQUOTA */ \
1063 0x0cf52471 /* GRPQUOTA */ \
1066 #define OCFS2_GLOBAL_QVERSIONS {\
1072 /* Each block of each quota file has a certain fixed number of bytes reserved
1073 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1074 * checksums, etc. */
1075 #define OCFS2_QBLK_RESERVED_SPACE 8
1077 /* Generic header of all quota files */
1078 struct ocfs2_disk_dqheader
{
1079 __le32 dqh_magic
; /* Magic number identifying file */
1080 __le32 dqh_version
; /* Quota format version */
1083 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1085 /* Information header of global quota file (immediately follows the generic
1087 struct ocfs2_global_disk_dqinfo
{
1088 /*00*/ __le32 dqi_bgrace
; /* Grace time for space softlimit excess */
1089 __le32 dqi_igrace
; /* Grace time for inode softlimit excess */
1090 __le32 dqi_syncms
; /* Time after which we sync local changes to
1091 * global quota file */
1092 __le32 dqi_blocks
; /* Number of blocks in quota file */
1093 /*10*/ __le32 dqi_free_blk
; /* First free block in quota file */
1094 __le32 dqi_free_entry
; /* First block with free dquot entry in quota
1098 /* Structure with global user / group information. We reserve some space
1099 * for future use. */
1100 struct ocfs2_global_disk_dqblk
{
1101 /*00*/ __le32 dqb_id
; /* ID the structure belongs to */
1102 __le32 dqb_use_count
; /* Number of nodes having reference to this structure */
1103 __le64 dqb_ihardlimit
; /* absolute limit on allocated inodes */
1104 /*10*/ __le64 dqb_isoftlimit
; /* preferred inode limit */
1105 __le64 dqb_curinodes
; /* current # allocated inodes */
1106 /*20*/ __le64 dqb_bhardlimit
; /* absolute limit on disk space */
1107 __le64 dqb_bsoftlimit
; /* preferred limit on disk space */
1108 /*30*/ __le64 dqb_curspace
; /* current space occupied */
1109 __le64 dqb_btime
; /* time limit for excessive disk use */
1110 /*40*/ __le64 dqb_itime
; /* time limit for excessive inode use */
1112 /*50*/ __le64 dqb_pad2
;
1116 * On-disk structures for local quota file
1119 /* Magic numbers and known versions for local quota files */
1120 #define OCFS2_LOCAL_QMAGICS {\
1121 0x0cf524c0, /* USRQUOTA */ \
1122 0x0cf524c1 /* GRPQUOTA */ \
1125 #define OCFS2_LOCAL_QVERSIONS {\
1130 /* Quota flags in dqinfo header */
1131 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1132 * quota has been cleanly turned off) */
1134 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1136 /* Information header of local quota file (immediately follows the generic
1138 struct ocfs2_local_disk_dqinfo
{
1139 __le32 dqi_flags
; /* Flags for quota file */
1140 __le32 dqi_chunks
; /* Number of chunks of quota structures
1142 __le32 dqi_blocks
; /* Number of blocks allocated for quota file */
1145 /* Header of one chunk of a quota file */
1146 struct ocfs2_local_disk_chunk
{
1147 __le32 dqc_free
; /* Number of free entries in the bitmap */
1148 __u8 dqc_bitmap
[0]; /* Bitmap of entries in the corresponding
1149 * chunk of quota file */
1152 /* One entry in local quota file */
1153 struct ocfs2_local_disk_dqblk
{
1154 /*00*/ __le64 dqb_id
; /* id this quota applies to */
1155 __le64 dqb_spacemod
; /* Change in the amount of used space */
1156 /*10*/ __le64 dqb_inodemod
; /* Change in the amount of used inodes */
1161 * The quota trailer lives at the end of each quota block.
1164 struct ocfs2_disk_dqtrailer
{
1165 /*00*/ struct ocfs2_block_check dq_check
; /* Error checking */
1166 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1169 static inline struct ocfs2_disk_dqtrailer
*ocfs2_block_dqtrailer(int blocksize
,
1173 ptr
+= blocksize
- OCFS2_QBLK_RESERVED_SPACE
;
1175 return (struct ocfs2_disk_dqtrailer
*)ptr
;
1179 static inline int ocfs2_fast_symlink_chars(struct super_block
*sb
)
1181 return sb
->s_blocksize
-
1182 offsetof(struct ocfs2_dinode
, id2
.i_symlink
);
1185 static inline int ocfs2_max_inline_data_with_xattr(struct super_block
*sb
,
1186 struct ocfs2_dinode
*di
)
1188 unsigned int xattrsize
= le16_to_cpu(di
->i_xattr_inline_size
);
1190 if (le16_to_cpu(di
->i_dyn_features
) & OCFS2_INLINE_XATTR_FL
)
1191 return sb
->s_blocksize
-
1192 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
) -
1195 return sb
->s_blocksize
-
1196 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
);
1199 static inline int ocfs2_extent_recs_per_inode(struct super_block
*sb
)
1203 size
= sb
->s_blocksize
-
1204 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1206 return size
/ sizeof(struct ocfs2_extent_rec
);
1209 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1210 struct super_block
*sb
,
1211 struct ocfs2_dinode
*di
)
1214 unsigned int xattrsize
= le16_to_cpu(di
->i_xattr_inline_size
);
1216 if (le16_to_cpu(di
->i_dyn_features
) & OCFS2_INLINE_XATTR_FL
)
1217 size
= sb
->s_blocksize
-
1218 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
) -
1221 size
= sb
->s_blocksize
-
1222 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1224 return size
/ sizeof(struct ocfs2_extent_rec
);
1227 static inline int ocfs2_extent_recs_per_dx_root(struct super_block
*sb
)
1231 size
= sb
->s_blocksize
-
1232 offsetof(struct ocfs2_dx_root_block
, dr_list
.l_recs
);
1234 return size
/ sizeof(struct ocfs2_extent_rec
);
1237 static inline int ocfs2_chain_recs_per_inode(struct super_block
*sb
)
1241 size
= sb
->s_blocksize
-
1242 offsetof(struct ocfs2_dinode
, id2
.i_chain
.cl_recs
);
1244 return size
/ sizeof(struct ocfs2_chain_rec
);
1247 static inline u16
ocfs2_extent_recs_per_eb(struct super_block
*sb
)
1251 size
= sb
->s_blocksize
-
1252 offsetof(struct ocfs2_extent_block
, h_list
.l_recs
);
1254 return size
/ sizeof(struct ocfs2_extent_rec
);
1257 static inline int ocfs2_dx_entries_per_leaf(struct super_block
*sb
)
1261 size
= sb
->s_blocksize
-
1262 offsetof(struct ocfs2_dx_leaf
, dl_list
.de_entries
);
1264 return size
/ sizeof(struct ocfs2_dx_entry
);
1267 static inline int ocfs2_dx_entries_per_root(struct super_block
*sb
)
1271 size
= sb
->s_blocksize
-
1272 offsetof(struct ocfs2_dx_root_block
, dr_entries
.de_entries
);
1274 return size
/ sizeof(struct ocfs2_dx_entry
);
1277 static inline u16
ocfs2_local_alloc_size(struct super_block
*sb
)
1281 size
= sb
->s_blocksize
-
1282 offsetof(struct ocfs2_dinode
, id2
.i_lab
.la_bitmap
);
1287 static inline int ocfs2_group_bitmap_size(struct super_block
*sb
)
1291 size
= sb
->s_blocksize
-
1292 offsetof(struct ocfs2_group_desc
, bg_bitmap
);
1297 static inline int ocfs2_truncate_recs_per_inode(struct super_block
*sb
)
1301 size
= sb
->s_blocksize
-
1302 offsetof(struct ocfs2_dinode
, id2
.i_dealloc
.tl_recs
);
1304 return size
/ sizeof(struct ocfs2_truncate_rec
);
1307 static inline u64
ocfs2_backup_super_blkno(struct super_block
*sb
, int index
)
1309 u64 offset
= OCFS2_BACKUP_SB_START
;
1311 if (index
>= 0 && index
< OCFS2_MAX_BACKUP_SUPERBLOCKS
) {
1312 offset
<<= (2 * index
);
1313 offset
>>= sb
->s_blocksize_bits
;
1321 static inline u16
ocfs2_xattr_recs_per_xb(struct super_block
*sb
)
1325 size
= sb
->s_blocksize
-
1326 offsetof(struct ocfs2_xattr_block
,
1327 xb_attrs
.xb_root
.xt_list
.l_recs
);
1329 return size
/ sizeof(struct ocfs2_extent_rec
);
1332 static inline u16
ocfs2_extent_recs_per_rb(struct super_block
*sb
)
1336 size
= sb
->s_blocksize
-
1337 offsetof(struct ocfs2_refcount_block
, rf_list
.l_recs
);
1339 return size
/ sizeof(struct ocfs2_extent_rec
);
1342 static inline u16
ocfs2_refcount_recs_per_rb(struct super_block
*sb
)
1346 size
= sb
->s_blocksize
-
1347 offsetof(struct ocfs2_refcount_block
, rf_records
.rl_recs
);
1349 return size
/ sizeof(struct ocfs2_refcount_rec
);
1353 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec
*rec
)
1355 return le64_to_cpu(rec
->r_cpos
) & OCFS2_32BIT_POS_MASK
;
1358 static inline int ocfs2_fast_symlink_chars(int blocksize
)
1360 return blocksize
- offsetof(struct ocfs2_dinode
, id2
.i_symlink
);
1363 static inline int ocfs2_max_inline_data_with_xattr(int blocksize
,
1364 struct ocfs2_dinode
*di
)
1366 if (di
&& (di
->i_dyn_features
& OCFS2_INLINE_XATTR_FL
))
1368 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
) -
1369 di
->i_xattr_inline_size
;
1372 offsetof(struct ocfs2_dinode
, id2
.i_data
.id_data
);
1375 static inline int ocfs2_extent_recs_per_inode(int blocksize
)
1380 offsetof(struct ocfs2_dinode
, id2
.i_list
.l_recs
);
1382 return size
/ sizeof(struct ocfs2_extent_rec
);
1385 static inline int ocfs2_chain_recs_per_inode(int blocksize
)
1390 offsetof(struct ocfs2_dinode
, id2
.i_chain
.cl_recs
);
1392 return size
/ sizeof(struct ocfs2_chain_rec
);
1395 static inline int ocfs2_extent_recs_per_eb(int blocksize
)
1400 offsetof(struct ocfs2_extent_block
, h_list
.l_recs
);
1402 return size
/ sizeof(struct ocfs2_extent_rec
);
1405 static inline int ocfs2_local_alloc_size(int blocksize
)
1410 offsetof(struct ocfs2_dinode
, id2
.i_lab
.la_bitmap
);
1415 static inline int ocfs2_group_bitmap_size(int blocksize
)
1420 offsetof(struct ocfs2_group_desc
, bg_bitmap
);
1425 static inline int ocfs2_truncate_recs_per_inode(int blocksize
)
1430 offsetof(struct ocfs2_dinode
, id2
.i_dealloc
.tl_recs
);
1432 return size
/ sizeof(struct ocfs2_truncate_rec
);
1435 static inline uint64_t ocfs2_backup_super_blkno(int blocksize
, int index
)
1437 uint64_t offset
= OCFS2_BACKUP_SB_START
;
1439 if (index
>= 0 && index
< OCFS2_MAX_BACKUP_SUPERBLOCKS
) {
1440 offset
<<= (2 * index
);
1441 offset
/= blocksize
;
1448 static inline int ocfs2_xattr_recs_per_xb(int blocksize
)
1453 offsetof(struct ocfs2_xattr_block
,
1454 xb_attrs
.xb_root
.xt_list
.l_recs
);
1456 return size
/ sizeof(struct ocfs2_extent_rec
);
1458 #endif /* __KERNEL__ */
1461 static inline int ocfs2_system_inode_is_global(int type
)
1463 return ((type
>= 0) &&
1464 (type
<= OCFS2_LAST_GLOBAL_SYSTEM_INODE
));
1467 static inline int ocfs2_sprintf_system_inode_name(char *buf
, int len
,
1473 * Global system inodes can only have one copy. Everything
1474 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1475 * list has a copy per slot.
1477 if (type
<= OCFS2_LAST_GLOBAL_SYSTEM_INODE
)
1478 chars
= snprintf(buf
, len
, "%s",
1479 ocfs2_system_inodes
[type
].si_name
);
1481 chars
= snprintf(buf
, len
,
1482 ocfs2_system_inodes
[type
].si_name
,
1488 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry
*de
,
1491 de
->file_type
= ocfs2_type_by_mode
[(mode
& S_IFMT
)>>S_SHIFT
];
1494 #endif /* _OCFS2_FS_H */