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 #define OCFS2_FEATURE_RO_COMPAT_SUPP 0
93 * Heartbeat-only devices are missing journals and other files. The
94 * filesystem driver can't load them, but the library can. Never put
95 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
97 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
100 * tunefs sets this incompat flag before starting the resize and clears it
101 * at the end. This flag protects users from inadvertently mounting the fs
102 * after an aborted run without fsck-ing.
104 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
106 /* Used to denote a non-clustered volume */
107 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
109 /* Support for sparse allocation in b-trees */
110 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
113 * backup superblock flag is used to indicate that this volume
114 * has backup superblocks.
116 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
118 /* The byte offset of the first backup block will be 1G.
119 * The following will be 4G, 16G, 64G, 256G and 1T.
121 #define OCFS2_BACKUP_SB_START 1 << 30
123 /* the max backup superblock nums */
124 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
127 * Flags on ocfs2_dinode.i_flags
129 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
130 #define OCFS2_UNUSED2_FL (0x00000002)
131 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
132 #define OCFS2_UNUSED3_FL (0x00000008)
133 /* System inode flags */
134 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
135 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
136 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
137 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
138 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
139 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
140 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
141 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
143 /* Inode attributes, keep in sync with EXT2 */
144 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
145 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
146 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
147 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
148 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
149 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
150 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
151 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
152 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
154 #define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
155 #define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
157 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
158 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
159 #define OCFS2_FL_MASK (0x0F0100FF)
164 #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
165 #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
168 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
170 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
173 * superblock s_state flags
175 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
177 /* Limit of space in ocfs2_dir_entry */
178 #define OCFS2_MAX_FILENAME_LEN 255
180 /* Maximum slots on an ocfs2 file system */
181 #define OCFS2_MAX_SLOTS 255
183 /* Slot map indicator for an empty slot */
184 #define OCFS2_INVALID_SLOT -1
186 #define OCFS2_VOL_UUID_LEN 16
187 #define OCFS2_MAX_VOL_LABEL_LEN 64
189 /* Journal limits (in bytes) */
190 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
192 struct ocfs2_system_inode_info {
198 /* System file index */
200 BAD_BLOCK_SYSTEM_INODE = 0,
201 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
202 SLOT_MAP_SYSTEM_INODE,
203 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
204 HEARTBEAT_SYSTEM_INODE,
205 GLOBAL_BITMAP_SYSTEM_INODE,
206 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
207 ORPHAN_DIR_SYSTEM_INODE,
208 EXTENT_ALLOC_SYSTEM_INODE,
209 INODE_ALLOC_SYSTEM_INODE,
210 JOURNAL_SYSTEM_INODE,
211 LOCAL_ALLOC_SYSTEM_INODE,
212 TRUNCATE_LOG_SYSTEM_INODE,
216 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
217 /* Global system inodes (single copy) */
218 /* The first two are only used from userspace mfks/tunefs */
219 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
220 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
222 /* These are used by the running filesystem */
223 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
224 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
225 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
227 /* Slot-specific system inodes (one copy per slot) */
228 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
229 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
230 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
231 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
232 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
233 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
236 /* Parameter passed from mount.ocfs2 to module */
237 #define OCFS2_HB_NONE "heartbeat=none"
238 #define OCFS2_HB_LOCAL "heartbeat=local"
241 * OCFS2 directory file types. Only the low 3 bits are used. The
242 * other bits are reserved for now.
244 #define OCFS2_FT_UNKNOWN 0
245 #define OCFS2_FT_REG_FILE 1
246 #define OCFS2_FT_DIR 2
247 #define OCFS2_FT_CHRDEV 3
248 #define OCFS2_FT_BLKDEV 4
249 #define OCFS2_FT_FIFO 5
250 #define OCFS2_FT_SOCK 6
251 #define OCFS2_FT_SYMLINK 7
253 #define OCFS2_FT_MAX 8
256 * OCFS2_DIR_PAD defines the directory entries boundaries
258 * NOTE: It must be a multiple of 4
260 #define OCFS2_DIR_PAD 4
261 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
262 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
263 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
267 #define OCFS2_LINK_MAX 32000
270 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
271 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
272 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
273 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
274 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
275 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
276 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
277 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
284 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
287 * On disk extent record for OCFS2
288 * It describes a range of clusters on disk.
290 struct ocfs2_extent_rec {
291 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
292 __le32 e_clusters; /* Clusters covered by this extent */
293 __le64 e_blkno; /* Physical disk offset, in blocks */
297 struct ocfs2_chain_rec {
298 __le32 c_free; /* Number of free bits in this chain. */
299 __le32 c_total; /* Number of total bits in this chain */
300 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
303 struct ocfs2_truncate_rec {
304 __le32 t_start; /* 1st cluster in this log */
305 __le32 t_clusters; /* Number of total clusters covered */
309 * On disk extent list for OCFS2 (node in the tree). Note that this
310 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
311 * offsets are relative to ocfs2_dinode.id2.i_list or
312 * ocfs2_extent_block.h_list, respectively.
314 struct ocfs2_extent_list {
315 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
316 point. 0 means data extents
317 hang directly off this
319 __le16 l_count; /* Number of extent records */
320 __le16 l_next_free_rec; /* Next unused extent slot */
322 __le64 l_reserved2; /* Pad to
323 sizeof(ocfs2_extent_rec) */
324 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
328 * On disk allocation chain list for OCFS2. Note that this is
329 * contained inside ocfs2_dinode, so the offsets are relative to
330 * ocfs2_dinode.id2.i_chain.
332 struct ocfs2_chain_list {
333 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
334 __le16 cl_bpc; /* Bits per cluster */
335 __le16 cl_count; /* Total chains in this list */
336 __le16 cl_next_free_rec; /* Next unused chain slot */
338 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
342 * On disk deallocation log for OCFS2. Note that this is
343 * contained inside ocfs2_dinode, so the offsets are relative to
344 * ocfs2_dinode.id2.i_dealloc.
346 struct ocfs2_truncate_log {
347 /*00*/ __le16 tl_count; /* Total records in this log */
348 __le16 tl_used; /* Number of records in use */
350 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
354 * On disk extent block (indirect block) for OCFS2
356 struct ocfs2_extent_block
358 /*00*/ __u8 h_signature[8]; /* Signature for verification */
360 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
361 extent_header belongs to */
362 __le16 h_suballoc_bit; /* Bit offset in suballocator
364 __le32 h_fs_generation; /* Must match super block */
365 __le64 h_blkno; /* Offset on disk, in blocks */
366 /*20*/ __le64 h_reserved3;
367 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
368 of next leaf header pointing
370 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
371 /* Actual on-disk size is one block */
375 * On disk superblock for OCFS2
376 * Note that it is contained inside an ocfs2_dinode, so all offsets
377 * are relative to the start of ocfs2_dinode.id2.
379 struct ocfs2_super_block {
380 /*00*/ __le16 s_major_rev_level;
381 __le16 s_minor_rev_level;
383 __le16 s_max_mnt_count;
384 __le16 s_state; /* File system state */
385 __le16 s_errors; /* Behaviour when detecting errors */
386 __le32 s_checkinterval; /* Max time between checks */
387 /*10*/ __le64 s_lastcheck; /* Time of last check */
388 __le32 s_creator_os; /* OS */
389 __le32 s_feature_compat; /* Compatible feature set */
390 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
391 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
392 __le64 s_root_blkno; /* Offset, in blocks, of root directory
394 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
396 __le32 s_blocksize_bits; /* Blocksize for this fs */
397 __le32 s_clustersize_bits; /* Clustersize for this fs */
398 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
399 before tunefs required */
402 __le64 s_first_cluster_group; /* Block offset of 1st cluster
404 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
405 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
410 * Local allocation bitmap for OCFS2 slots
411 * Note that it exists inside an ocfs2_dinode, so all offsets are
412 * relative to the start of ocfs2_dinode.id2.
414 struct ocfs2_local_alloc
416 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
417 __le16 la_size; /* Size of included bitmap, in bytes */
420 /*10*/ __u8 la_bitmap[0];
424 * On disk inode for OCFS2
426 struct ocfs2_dinode {
427 /*00*/ __u8 i_signature[8]; /* Signature for validation */
428 __le32 i_generation; /* Generation number */
429 __le16 i_suballoc_slot; /* Slot suballocator this inode
431 __le16 i_suballoc_bit; /* Bit offset in suballocator
433 /*10*/ __le32 i_reserved0;
434 __le32 i_clusters; /* Cluster count */
435 __le32 i_uid; /* Owner UID */
436 __le32 i_gid; /* Owning GID */
437 /*20*/ __le64 i_size; /* Size in bytes */
438 __le16 i_mode; /* File mode */
439 __le16 i_links_count; /* Links count */
440 __le32 i_flags; /* File flags */
441 /*30*/ __le64 i_atime; /* Access time */
442 __le64 i_ctime; /* Creation time */
443 /*40*/ __le64 i_mtime; /* Modification time */
444 __le64 i_dtime; /* Deletion time */
445 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
446 __le64 i_last_eb_blk; /* Pointer to last extent
448 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
454 /*70*/ __le64 i_reserved2[8];
456 __le64 i_pad1; /* Generic way to refer to this
459 __le64 i_rdev; /* Device number */
461 struct { /* Info for bitmap system
463 __le32 i_used; /* Bits (ie, clusters) used */
464 __le32 i_total; /* Total bits (clusters)
467 struct { /* Info for journal system
469 __le32 ij_flags; /* Mounted, version, etc. */
472 } id1; /* Inode type dependant 1 */
474 struct ocfs2_super_block i_super;
475 struct ocfs2_local_alloc i_lab;
476 struct ocfs2_chain_list i_chain;
477 struct ocfs2_extent_list i_list;
478 struct ocfs2_truncate_log i_dealloc;
481 /* Actual on-disk size is one block */
485 * On-disk directory entry structure for OCFS2
487 * Packed as this structure could be accessed unaligned on 64-bit platforms
489 struct ocfs2_dir_entry {
490 /*00*/ __le64 inode; /* Inode number */
491 __le16 rec_len; /* Directory entry length */
492 __u8 name_len; /* Name length */
494 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
495 /* Actual on-disk length specified by rec_len */
496 } __attribute__ ((packed));
499 * On disk allocator group structure for OCFS2
501 struct ocfs2_group_desc
503 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
504 __le16 bg_size; /* Size of included bitmap in
506 __le16 bg_bits; /* Bits represented by this
508 __le16 bg_free_bits_count; /* Free bits count */
509 __le16 bg_chain; /* What chain I am in. */
510 /*10*/ __le32 bg_generation;
512 __le64 bg_next_group; /* Next group in my list, in
514 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
516 __le64 bg_blkno; /* Offset on disk, in blocks */
517 /*30*/ __le64 bg_reserved2[2];
518 /*40*/ __u8 bg_bitmap[0];
522 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
524 return sb->s_blocksize -
525 offsetof(struct ocfs2_dinode, id2.i_symlink);
528 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
532 size = sb->s_blocksize -
533 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
535 return size / sizeof(struct ocfs2_extent_rec);
538 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
542 size = sb->s_blocksize -
543 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
545 return size / sizeof(struct ocfs2_chain_rec);
548 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
552 size = sb->s_blocksize -
553 offsetof(struct ocfs2_extent_block, h_list.l_recs);
555 return size / sizeof(struct ocfs2_extent_rec);
558 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
562 size = sb->s_blocksize -
563 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
568 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
572 size = sb->s_blocksize -
573 offsetof(struct ocfs2_group_desc, bg_bitmap);
578 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
582 size = sb->s_blocksize -
583 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
585 return size / sizeof(struct ocfs2_truncate_rec);
588 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
590 u64 offset = OCFS2_BACKUP_SB_START;
592 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
593 offset <<= (2 * index);
594 offset >>= sb->s_blocksize_bits;
602 static inline int ocfs2_fast_symlink_chars(int blocksize)
604 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
607 static inline int ocfs2_extent_recs_per_inode(int blocksize)
612 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
614 return size / sizeof(struct ocfs2_extent_rec);
617 static inline int ocfs2_chain_recs_per_inode(int blocksize)
622 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
624 return size / sizeof(struct ocfs2_chain_rec);
627 static inline int ocfs2_extent_recs_per_eb(int blocksize)
632 offsetof(struct ocfs2_extent_block, h_list.l_recs);
634 return size / sizeof(struct ocfs2_extent_rec);
637 static inline int ocfs2_local_alloc_size(int blocksize)
642 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
647 static inline int ocfs2_group_bitmap_size(int blocksize)
652 offsetof(struct ocfs2_group_desc, bg_bitmap);
657 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
662 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
664 return size / sizeof(struct ocfs2_truncate_rec);
667 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
669 uint64_t offset = OCFS2_BACKUP_SB_START;
671 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
672 offset <<= (2 * index);
679 #endif /* __KERNEL__ */
682 static inline int ocfs2_system_inode_is_global(int type)
684 return ((type >= 0) &&
685 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
688 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
694 * Global system inodes can only have one copy. Everything
695 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
696 * list has a copy per slot.
698 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
699 chars = snprintf(buf, len,
700 ocfs2_system_inodes[type].si_name);
702 chars = snprintf(buf, len,
703 ocfs2_system_inodes[type].si_name,
709 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
712 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
715 #endif /* _OCFS2_FS_H */