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"
68 /* Compatibility flags */
69 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
70 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
71 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
72 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
73 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
74 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
75 #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
76 OCFS2_SB(sb)->s_feature_compat |= (mask)
77 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
78 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
79 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
80 OCFS2_SB(sb)->s_feature_incompat |= (mask)
81 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
82 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
83 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
84 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
85 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
88 #define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB
89 #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
90 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
91 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
92 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
93 #define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
96 * Heartbeat-only devices are missing journals and other files. The
97 * filesystem driver can't load them, but the library can. Never put
98 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
100 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
103 * tunefs sets this incompat flag before starting the resize and clears it
104 * at the end. This flag protects users from inadvertently mounting the fs
105 * after an aborted run without fsck-ing.
107 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
109 /* Used to denote a non-clustered volume */
110 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
112 /* Support for sparse allocation in b-trees */
113 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
116 * Tunefs sets this incompat flag before starting an operation which
117 * would require cleanup on abort. This is done to protect users from
118 * inadvertently mounting the fs after an aborted run without
121 * s_tunefs_flags on the super block describes precisely which
122 * operations were in progress.
124 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
126 /* Support for data packed into inode blocks */
127 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
129 /* Support for the extended slot map */
130 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
134 * backup superblock flag is used to indicate that this volume
135 * has backup superblocks.
137 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
140 * Unwritten extents support.
142 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
144 /* The byte offset of the first backup block will be 1G.
145 * The following will be 4G, 16G, 64G, 256G and 1T.
147 #define OCFS2_BACKUP_SB_START 1 << 30
149 /* the max backup superblock nums */
150 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
153 * Flags on ocfs2_super_block.s_tunefs_flags
155 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
158 * Flags on ocfs2_dinode.i_flags
160 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
161 #define OCFS2_UNUSED2_FL (0x00000002)
162 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
163 #define OCFS2_UNUSED3_FL (0x00000008)
164 /* System inode flags */
165 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
166 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
167 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
168 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
169 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
170 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
171 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
172 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
175 * Flags on ocfs2_dinode.i_dyn_features
177 * These can change much more often than i_flags. When adding flags,
178 * keep in mind that i_dyn_features is only 16 bits wide.
180 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
181 #define OCFS2_HAS_XATTR_FL (0x0002)
182 #define OCFS2_INLINE_XATTR_FL (0x0004)
183 #define OCFS2_INDEXED_DIR_FL (0x0008)
185 /* Inode attributes, keep in sync with EXT2 */
186 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
187 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
188 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
189 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
190 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
191 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
192 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
193 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
194 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
196 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
197 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
200 * Extent record flags (e_node.leaf.flags)
202 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
208 #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
209 #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
210 #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
211 #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
214 * Space reservation / allocation / free ioctls and argument structure
215 * are designed to be compatible with XFS.
217 * ALLOCSP* and FREESP* are not and will never be supported, but are
218 * included here for completeness.
220 struct ocfs2_space_resv {
224 __s64 l_len; /* len == 0 means until end of file */
227 __s32 l_pad[4]; /* reserve area */
230 #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
231 #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
232 #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
233 #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
234 #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
235 #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
236 #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
237 #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
239 /* Used to pass group descriptor data when online resize is done */
240 struct ocfs2_new_group_input {
241 __u64 group; /* Group descriptor's blkno. */
242 __u32 clusters; /* Total number of clusters in this group */
243 __u32 frees; /* Total free clusters in this group */
244 __u16 chain; /* Chain for this group */
249 #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
250 #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
251 #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
254 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
256 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
259 * superblock s_state flags
261 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
263 /* Limit of space in ocfs2_dir_entry */
264 #define OCFS2_MAX_FILENAME_LEN 255
266 /* Maximum slots on an ocfs2 file system */
267 #define OCFS2_MAX_SLOTS 255
269 /* Slot map indicator for an empty slot */
270 #define OCFS2_INVALID_SLOT -1
272 #define OCFS2_VOL_UUID_LEN 16
273 #define OCFS2_MAX_VOL_LABEL_LEN 64
275 /* Journal limits (in bytes) */
276 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
279 * Default local alloc size (in megabytes)
281 * The value chosen should be such that most allocations, including new
282 * block groups, use local alloc.
284 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
286 struct ocfs2_system_inode_info {
292 /* System file index */
294 BAD_BLOCK_SYSTEM_INODE = 0,
295 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
296 SLOT_MAP_SYSTEM_INODE,
297 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
298 HEARTBEAT_SYSTEM_INODE,
299 GLOBAL_BITMAP_SYSTEM_INODE,
300 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
301 ORPHAN_DIR_SYSTEM_INODE,
302 EXTENT_ALLOC_SYSTEM_INODE,
303 INODE_ALLOC_SYSTEM_INODE,
304 JOURNAL_SYSTEM_INODE,
305 LOCAL_ALLOC_SYSTEM_INODE,
306 TRUNCATE_LOG_SYSTEM_INODE,
310 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
311 /* Global system inodes (single copy) */
312 /* The first two are only used from userspace mfks/tunefs */
313 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
314 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
316 /* These are used by the running filesystem */
317 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
318 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
319 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
321 /* Slot-specific system inodes (one copy per slot) */
322 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
323 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
324 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
325 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
326 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
327 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
330 /* Parameter passed from mount.ocfs2 to module */
331 #define OCFS2_HB_NONE "heartbeat=none"
332 #define OCFS2_HB_LOCAL "heartbeat=local"
335 * OCFS2 directory file types. Only the low 3 bits are used. The
336 * other bits are reserved for now.
338 #define OCFS2_FT_UNKNOWN 0
339 #define OCFS2_FT_REG_FILE 1
340 #define OCFS2_FT_DIR 2
341 #define OCFS2_FT_CHRDEV 3
342 #define OCFS2_FT_BLKDEV 4
343 #define OCFS2_FT_FIFO 5
344 #define OCFS2_FT_SOCK 6
345 #define OCFS2_FT_SYMLINK 7
347 #define OCFS2_FT_MAX 8
350 * OCFS2_DIR_PAD defines the directory entries boundaries
352 * NOTE: It must be a multiple of 4
354 #define OCFS2_DIR_PAD 4
355 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
356 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
357 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
361 #define OCFS2_LINK_MAX 32000
364 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
365 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
366 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
367 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
368 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
369 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
370 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
371 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
378 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
381 * On disk extent record for OCFS2
382 * It describes a range of clusters on disk.
384 * Length fields are divided into interior and leaf node versions.
385 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
387 struct ocfs2_extent_rec {
388 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
390 __le32 e_int_clusters; /* Clusters covered by all children */
392 __le16 e_leaf_clusters; /* Clusters covered by this
395 __u8 e_flags; /* Extent flags */
398 __le64 e_blkno; /* Physical disk offset, in blocks */
402 struct ocfs2_chain_rec {
403 __le32 c_free; /* Number of free bits in this chain. */
404 __le32 c_total; /* Number of total bits in this chain */
405 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
408 struct ocfs2_truncate_rec {
409 __le32 t_start; /* 1st cluster in this log */
410 __le32 t_clusters; /* Number of total clusters covered */
414 * On disk extent list for OCFS2 (node in the tree). Note that this
415 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
416 * offsets are relative to ocfs2_dinode.id2.i_list or
417 * ocfs2_extent_block.h_list, respectively.
419 struct ocfs2_extent_list {
420 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
421 point. 0 means data extents
422 hang directly off this
424 NOTE: The high 8 bits cannot be
425 used - tree_depth is never that big.
427 __le16 l_count; /* Number of extent records */
428 __le16 l_next_free_rec; /* Next unused extent slot */
430 __le64 l_reserved2; /* Pad to
431 sizeof(ocfs2_extent_rec) */
432 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
436 * On disk allocation chain list for OCFS2. Note that this is
437 * contained inside ocfs2_dinode, so the offsets are relative to
438 * ocfs2_dinode.id2.i_chain.
440 struct ocfs2_chain_list {
441 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
442 __le16 cl_bpc; /* Bits per cluster */
443 __le16 cl_count; /* Total chains in this list */
444 __le16 cl_next_free_rec; /* Next unused chain slot */
446 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
450 * On disk deallocation log for OCFS2. Note that this is
451 * contained inside ocfs2_dinode, so the offsets are relative to
452 * ocfs2_dinode.id2.i_dealloc.
454 struct ocfs2_truncate_log {
455 /*00*/ __le16 tl_count; /* Total records in this log */
456 __le16 tl_used; /* Number of records in use */
458 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
462 * On disk extent block (indirect block) for OCFS2
464 struct ocfs2_extent_block
466 /*00*/ __u8 h_signature[8]; /* Signature for verification */
468 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
469 extent_header belongs to */
470 __le16 h_suballoc_bit; /* Bit offset in suballocator
472 __le32 h_fs_generation; /* Must match super block */
473 __le64 h_blkno; /* Offset on disk, in blocks */
474 /*20*/ __le64 h_reserved3;
475 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
476 of next leaf header pointing
478 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
479 /* Actual on-disk size is one block */
483 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
484 * system file. A slot is valid if it contains a node number >= 0. The
485 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
487 struct ocfs2_slot_map {
488 /*00*/ __le16 sm_slots[0];
490 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
491 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
495 struct ocfs2_extended_slot {
496 /*00*/ __u8 es_valid;
497 __u8 es_reserved1[3];
503 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
504 * is set. It separates out the valid marker from the node number, and
505 * has room to grow. Unlike the old slot map, this format is defined by
508 struct ocfs2_slot_map_extended {
509 /*00*/ struct ocfs2_extended_slot se_slots[0];
511 * Actual size is i_size of the slot_map system file. It should
512 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
517 * On disk superblock for OCFS2
518 * Note that it is contained inside an ocfs2_dinode, so all offsets
519 * are relative to the start of ocfs2_dinode.id2.
521 struct ocfs2_super_block {
522 /*00*/ __le16 s_major_rev_level;
523 __le16 s_minor_rev_level;
525 __le16 s_max_mnt_count;
526 __le16 s_state; /* File system state */
527 __le16 s_errors; /* Behaviour when detecting errors */
528 __le32 s_checkinterval; /* Max time between checks */
529 /*10*/ __le64 s_lastcheck; /* Time of last check */
530 __le32 s_creator_os; /* OS */
531 __le32 s_feature_compat; /* Compatible feature set */
532 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
533 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
534 __le64 s_root_blkno; /* Offset, in blocks, of root directory
536 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
538 __le32 s_blocksize_bits; /* Blocksize for this fs */
539 __le32 s_clustersize_bits; /* Clustersize for this fs */
540 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
541 before tunefs required */
542 __le16 s_tunefs_flag;
544 __le64 s_first_cluster_group; /* Block offset of 1st cluster
546 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
547 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
552 * Local allocation bitmap for OCFS2 slots
553 * Note that it exists inside an ocfs2_dinode, so all offsets are
554 * relative to the start of ocfs2_dinode.id2.
556 struct ocfs2_local_alloc
558 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
559 __le16 la_size; /* Size of included bitmap, in bytes */
562 /*10*/ __u8 la_bitmap[0];
566 * Data-in-inode header. This is only used if i_dyn_features has
567 * OCFS2_INLINE_DATA_FL set.
569 struct ocfs2_inline_data
571 /*00*/ __le16 id_count; /* Number of bytes that can be used
572 * for data, starting at id_data */
575 __u8 id_data[0]; /* Start of user data */
579 * On disk inode for OCFS2
581 struct ocfs2_dinode {
582 /*00*/ __u8 i_signature[8]; /* Signature for validation */
583 __le32 i_generation; /* Generation number */
584 __le16 i_suballoc_slot; /* Slot suballocator this inode
586 __le16 i_suballoc_bit; /* Bit offset in suballocator
588 /*10*/ __le32 i_reserved0;
589 __le32 i_clusters; /* Cluster count */
590 __le32 i_uid; /* Owner UID */
591 __le32 i_gid; /* Owning GID */
592 /*20*/ __le64 i_size; /* Size in bytes */
593 __le16 i_mode; /* File mode */
594 __le16 i_links_count; /* Links count */
595 __le32 i_flags; /* File flags */
596 /*30*/ __le64 i_atime; /* Access time */
597 __le64 i_ctime; /* Creation time */
598 /*40*/ __le64 i_mtime; /* Modification time */
599 __le64 i_dtime; /* Deletion time */
600 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
601 __le64 i_last_eb_blk; /* Pointer to last extent
603 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
608 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
609 was set in i_flags */
610 __le16 i_dyn_features;
611 /*70*/ __le64 i_reserved2[8];
613 __le64 i_pad1; /* Generic way to refer to this
616 __le64 i_rdev; /* Device number */
618 struct { /* Info for bitmap system
620 __le32 i_used; /* Bits (ie, clusters) used */
621 __le32 i_total; /* Total bits (clusters)
624 struct { /* Info for journal system
626 __le32 ij_flags; /* Mounted, version, etc. */
629 } id1; /* Inode type dependant 1 */
631 struct ocfs2_super_block i_super;
632 struct ocfs2_local_alloc i_lab;
633 struct ocfs2_chain_list i_chain;
634 struct ocfs2_extent_list i_list;
635 struct ocfs2_truncate_log i_dealloc;
636 struct ocfs2_inline_data i_data;
639 /* Actual on-disk size is one block */
643 * On-disk directory entry structure for OCFS2
645 * Packed as this structure could be accessed unaligned on 64-bit platforms
647 struct ocfs2_dir_entry {
648 /*00*/ __le64 inode; /* Inode number */
649 __le16 rec_len; /* Directory entry length */
650 __u8 name_len; /* Name length */
652 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
653 /* Actual on-disk length specified by rec_len */
654 } __attribute__ ((packed));
657 * On disk allocator group structure for OCFS2
659 struct ocfs2_group_desc
661 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
662 __le16 bg_size; /* Size of included bitmap in
664 __le16 bg_bits; /* Bits represented by this
666 __le16 bg_free_bits_count; /* Free bits count */
667 __le16 bg_chain; /* What chain I am in. */
668 /*10*/ __le32 bg_generation;
670 __le64 bg_next_group; /* Next group in my list, in
672 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
674 __le64 bg_blkno; /* Offset on disk, in blocks */
675 /*30*/ __le64 bg_reserved2[2];
676 /*40*/ __u8 bg_bitmap[0];
680 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
682 return sb->s_blocksize -
683 offsetof(struct ocfs2_dinode, id2.i_symlink);
686 static inline int ocfs2_max_inline_data(struct super_block *sb)
688 return sb->s_blocksize -
689 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
692 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
696 size = sb->s_blocksize -
697 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
699 return size / sizeof(struct ocfs2_extent_rec);
702 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
706 size = sb->s_blocksize -
707 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
709 return size / sizeof(struct ocfs2_chain_rec);
712 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
716 size = sb->s_blocksize -
717 offsetof(struct ocfs2_extent_block, h_list.l_recs);
719 return size / sizeof(struct ocfs2_extent_rec);
722 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
726 size = sb->s_blocksize -
727 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
732 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
736 size = sb->s_blocksize -
737 offsetof(struct ocfs2_group_desc, bg_bitmap);
742 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
746 size = sb->s_blocksize -
747 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
749 return size / sizeof(struct ocfs2_truncate_rec);
752 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
754 u64 offset = OCFS2_BACKUP_SB_START;
756 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
757 offset <<= (2 * index);
758 offset >>= sb->s_blocksize_bits;
766 static inline int ocfs2_fast_symlink_chars(int blocksize)
768 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
771 static inline int ocfs2_max_inline_data(int blocksize)
773 return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
776 static inline int ocfs2_extent_recs_per_inode(int blocksize)
781 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
783 return size / sizeof(struct ocfs2_extent_rec);
786 static inline int ocfs2_chain_recs_per_inode(int blocksize)
791 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
793 return size / sizeof(struct ocfs2_chain_rec);
796 static inline int ocfs2_extent_recs_per_eb(int blocksize)
801 offsetof(struct ocfs2_extent_block, h_list.l_recs);
803 return size / sizeof(struct ocfs2_extent_rec);
806 static inline int ocfs2_local_alloc_size(int blocksize)
811 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
816 static inline int ocfs2_group_bitmap_size(int blocksize)
821 offsetof(struct ocfs2_group_desc, bg_bitmap);
826 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
831 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
833 return size / sizeof(struct ocfs2_truncate_rec);
836 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
838 uint64_t offset = OCFS2_BACKUP_SB_START;
840 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
841 offset <<= (2 * index);
848 #endif /* __KERNEL__ */
851 static inline int ocfs2_system_inode_is_global(int type)
853 return ((type >= 0) &&
854 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
857 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
863 * Global system inodes can only have one copy. Everything
864 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
865 * list has a copy per slot.
867 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
868 chars = snprintf(buf, len,
869 ocfs2_system_inodes[type].si_name);
871 chars = snprintf(buf, len,
872 ocfs2_system_inodes[type].si_name,
878 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
881 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
884 #endif /* _OCFS2_FS_H */