sparc32: Remove #if 0'd code from sun4c_irq.c
[linux-2.6/libata-dev.git] / fs / ocfs2 / ocfs2_fs.h
blob4f619850ccf7fd8b80bf4888fc39849c6bb93d4b
1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
4 * ocfs2_fs.h
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.
25 #ifndef _OCFS2_FS_H
26 #define _OCFS2_FS_H
28 /* Version */
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
47 * grow if needed.
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 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
94 #define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
97 * Heartbeat-only devices are missing journals and other files. The
98 * filesystem driver can't load them, but the library can. Never put
99 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
101 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
104 * tunefs sets this incompat flag before starting the resize and clears it
105 * at the end. This flag protects users from inadvertently mounting the fs
106 * after an aborted run without fsck-ing.
108 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
110 /* Used to denote a non-clustered volume */
111 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
113 /* Support for sparse allocation in b-trees */
114 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
117 * Tunefs sets this incompat flag before starting an operation which
118 * would require cleanup on abort. This is done to protect users from
119 * inadvertently mounting the fs after an aborted run without
120 * fsck-ing.
122 * s_tunefs_flags on the super block describes precisely which
123 * operations were in progress.
125 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
127 /* Support for data packed into inode blocks */
128 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
130 /* Support for the extended slot map */
131 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
135 * Support for alternate, userspace cluster stacks. If set, the superblock
136 * field s_cluster_info contains a tag for the alternate stack in use as
137 * well as the name of the cluster being joined.
138 * mount.ocfs2 must pass in a matching stack name.
140 * If not set, the classic stack will be used. This is compatbile with
141 * all older versions.
143 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
146 * backup superblock flag is used to indicate that this volume
147 * has backup superblocks.
149 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
152 * Unwritten extents support.
154 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
156 /* The byte offset of the first backup block will be 1G.
157 * The following will be 4G, 16G, 64G, 256G and 1T.
159 #define OCFS2_BACKUP_SB_START 1 << 30
161 /* the max backup superblock nums */
162 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
165 * Flags on ocfs2_super_block.s_tunefs_flags
167 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
170 * Flags on ocfs2_dinode.i_flags
172 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
173 #define OCFS2_UNUSED2_FL (0x00000002)
174 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
175 #define OCFS2_UNUSED3_FL (0x00000008)
176 /* System inode flags */
177 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
178 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
179 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
180 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
181 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
182 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
183 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
184 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
187 * Flags on ocfs2_dinode.i_dyn_features
189 * These can change much more often than i_flags. When adding flags,
190 * keep in mind that i_dyn_features is only 16 bits wide.
192 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
193 #define OCFS2_HAS_XATTR_FL (0x0002)
194 #define OCFS2_INLINE_XATTR_FL (0x0004)
195 #define OCFS2_INDEXED_DIR_FL (0x0008)
197 /* Inode attributes, keep in sync with EXT2 */
198 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
199 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
200 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
201 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
202 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
203 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
204 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
205 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
206 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
208 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
209 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
212 * Extent record flags (e_node.leaf.flags)
214 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
215 * unwritten */
218 * ioctl commands
220 #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
221 #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
222 #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
223 #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
226 * Space reservation / allocation / free ioctls and argument structure
227 * are designed to be compatible with XFS.
229 * ALLOCSP* and FREESP* are not and will never be supported, but are
230 * included here for completeness.
232 struct ocfs2_space_resv {
233 __s16 l_type;
234 __s16 l_whence;
235 __s64 l_start;
236 __s64 l_len; /* len == 0 means until end of file */
237 __s32 l_sysid;
238 __u32 l_pid;
239 __s32 l_pad[4]; /* reserve area */
242 #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
243 #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
244 #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
245 #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
246 #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
247 #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
248 #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
249 #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
251 /* Used to pass group descriptor data when online resize is done */
252 struct ocfs2_new_group_input {
253 __u64 group; /* Group descriptor's blkno. */
254 __u32 clusters; /* Total number of clusters in this group */
255 __u32 frees; /* Total free clusters in this group */
256 __u16 chain; /* Chain for this group */
257 __u16 reserved1;
258 __u32 reserved2;
261 #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
262 #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
263 #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
266 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
268 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
271 * superblock s_state flags
273 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
275 /* Limit of space in ocfs2_dir_entry */
276 #define OCFS2_MAX_FILENAME_LEN 255
278 /* Maximum slots on an ocfs2 file system */
279 #define OCFS2_MAX_SLOTS 255
281 /* Slot map indicator for an empty slot */
282 #define OCFS2_INVALID_SLOT -1
284 #define OCFS2_VOL_UUID_LEN 16
285 #define OCFS2_MAX_VOL_LABEL_LEN 64
287 /* The alternate, userspace stack fields */
288 #define OCFS2_STACK_LABEL_LEN 4
289 #define OCFS2_CLUSTER_NAME_LEN 16
291 /* Journal limits (in bytes) */
292 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
295 * Default local alloc size (in megabytes)
297 * The value chosen should be such that most allocations, including new
298 * block groups, use local alloc.
300 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
302 struct ocfs2_system_inode_info {
303 char *si_name;
304 int si_iflags;
305 int si_mode;
308 /* System file index */
309 enum {
310 BAD_BLOCK_SYSTEM_INODE = 0,
311 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
312 SLOT_MAP_SYSTEM_INODE,
313 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
314 HEARTBEAT_SYSTEM_INODE,
315 GLOBAL_BITMAP_SYSTEM_INODE,
316 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
317 ORPHAN_DIR_SYSTEM_INODE,
318 EXTENT_ALLOC_SYSTEM_INODE,
319 INODE_ALLOC_SYSTEM_INODE,
320 JOURNAL_SYSTEM_INODE,
321 LOCAL_ALLOC_SYSTEM_INODE,
322 TRUNCATE_LOG_SYSTEM_INODE,
323 NUM_SYSTEM_INODES
326 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
327 /* Global system inodes (single copy) */
328 /* The first two are only used from userspace mfks/tunefs */
329 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
330 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
332 /* These are used by the running filesystem */
333 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
334 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
335 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
337 /* Slot-specific system inodes (one copy per slot) */
338 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
339 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
340 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
341 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
342 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
343 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_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 + \
374 OCFS2_DIR_ROUND) & \
375 ~OCFS2_DIR_ROUND)
377 #define OCFS2_LINK_MAX 32000
379 #define S_SHIFT 12
380 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
381 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
382 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
383 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
384 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
385 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
386 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
387 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
392 * Convenience casts
394 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
397 * On disk extent record for OCFS2
398 * It describes a range of clusters on disk.
400 * Length fields are divided into interior and leaf node versions.
401 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
403 struct ocfs2_extent_rec {
404 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
405 union {
406 __le32 e_int_clusters; /* Clusters covered by all children */
407 struct {
408 __le16 e_leaf_clusters; /* Clusters covered by this
409 extent */
410 __u8 e_reserved1;
411 __u8 e_flags; /* Extent flags */
414 __le64 e_blkno; /* Physical disk offset, in blocks */
415 /*10*/
418 struct ocfs2_chain_rec {
419 __le32 c_free; /* Number of free bits in this chain. */
420 __le32 c_total; /* Number of total bits in this chain */
421 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
424 struct ocfs2_truncate_rec {
425 __le32 t_start; /* 1st cluster in this log */
426 __le32 t_clusters; /* Number of total clusters covered */
430 * On disk extent list for OCFS2 (node in the tree). Note that this
431 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
432 * offsets are relative to ocfs2_dinode.id2.i_list or
433 * ocfs2_extent_block.h_list, respectively.
435 struct ocfs2_extent_list {
436 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
437 point. 0 means data extents
438 hang directly off this
439 header (a leaf)
440 NOTE: The high 8 bits cannot be
441 used - tree_depth is never that big.
443 __le16 l_count; /* Number of extent records */
444 __le16 l_next_free_rec; /* Next unused extent slot */
445 __le16 l_reserved1;
446 __le64 l_reserved2; /* Pad to
447 sizeof(ocfs2_extent_rec) */
448 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
452 * On disk allocation chain list for OCFS2. Note that this is
453 * contained inside ocfs2_dinode, so the offsets are relative to
454 * ocfs2_dinode.id2.i_chain.
456 struct ocfs2_chain_list {
457 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
458 __le16 cl_bpc; /* Bits per cluster */
459 __le16 cl_count; /* Total chains in this list */
460 __le16 cl_next_free_rec; /* Next unused chain slot */
461 __le64 cl_reserved1;
462 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
466 * On disk deallocation log for OCFS2. Note that this is
467 * contained inside ocfs2_dinode, so the offsets are relative to
468 * ocfs2_dinode.id2.i_dealloc.
470 struct ocfs2_truncate_log {
471 /*00*/ __le16 tl_count; /* Total records in this log */
472 __le16 tl_used; /* Number of records in use */
473 __le32 tl_reserved1;
474 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
478 * On disk extent block (indirect block) for OCFS2
480 struct ocfs2_extent_block
482 /*00*/ __u8 h_signature[8]; /* Signature for verification */
483 __le64 h_reserved1;
484 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
485 extent_header belongs to */
486 __le16 h_suballoc_bit; /* Bit offset in suballocator
487 block group */
488 __le32 h_fs_generation; /* Must match super block */
489 __le64 h_blkno; /* Offset on disk, in blocks */
490 /*20*/ __le64 h_reserved3;
491 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
492 of next leaf header pointing
493 to data */
494 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
495 /* Actual on-disk size is one block */
499 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
500 * system file. A slot is valid if it contains a node number >= 0. The
501 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
503 struct ocfs2_slot_map {
504 /*00*/ __le16 sm_slots[0];
506 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
507 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
511 struct ocfs2_extended_slot {
512 /*00*/ __u8 es_valid;
513 __u8 es_reserved1[3];
514 __le32 es_node_num;
515 /*10*/
519 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
520 * is set. It separates out the valid marker from the node number, and
521 * has room to grow. Unlike the old slot map, this format is defined by
522 * i_size.
524 struct ocfs2_slot_map_extended {
525 /*00*/ struct ocfs2_extended_slot se_slots[0];
527 * Actual size is i_size of the slot_map system file. It should
528 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
532 struct ocfs2_cluster_info {
533 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
534 __le32 ci_reserved;
535 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
536 /*18*/
540 * On disk superblock for OCFS2
541 * Note that it is contained inside an ocfs2_dinode, so all offsets
542 * are relative to the start of ocfs2_dinode.id2.
544 struct ocfs2_super_block {
545 /*00*/ __le16 s_major_rev_level;
546 __le16 s_minor_rev_level;
547 __le16 s_mnt_count;
548 __le16 s_max_mnt_count;
549 __le16 s_state; /* File system state */
550 __le16 s_errors; /* Behaviour when detecting errors */
551 __le32 s_checkinterval; /* Max time between checks */
552 /*10*/ __le64 s_lastcheck; /* Time of last check */
553 __le32 s_creator_os; /* OS */
554 __le32 s_feature_compat; /* Compatible feature set */
555 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
556 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
557 __le64 s_root_blkno; /* Offset, in blocks, of root directory
558 dinode */
559 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
560 directory dinode */
561 __le32 s_blocksize_bits; /* Blocksize for this fs */
562 __le32 s_clustersize_bits; /* Clustersize for this fs */
563 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
564 before tunefs required */
565 __le16 s_tunefs_flag;
566 __le32 s_reserved1;
567 __le64 s_first_cluster_group; /* Block offset of 1st cluster
568 * group header */
569 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
570 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
571 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
572 stack. Only valid
573 with INCOMPAT flag. */
574 /*B8*/ __le64 s_reserved2[17]; /* Fill out superblock */
575 /*140*/
578 * NOTE: As stated above, all offsets are relative to
579 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
580 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
581 * our smallest blocksize, which is 512 bytes. To ensure this,
582 * we reserve the space in s_reserved2. Anything past s_reserved2
583 * will not be available on the smallest blocksize.
588 * Local allocation bitmap for OCFS2 slots
589 * Note that it exists inside an ocfs2_dinode, so all offsets are
590 * relative to the start of ocfs2_dinode.id2.
592 struct ocfs2_local_alloc
594 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
595 __le16 la_size; /* Size of included bitmap, in bytes */
596 __le16 la_reserved1;
597 __le64 la_reserved2;
598 /*10*/ __u8 la_bitmap[0];
602 * Data-in-inode header. This is only used if i_dyn_features has
603 * OCFS2_INLINE_DATA_FL set.
605 struct ocfs2_inline_data
607 /*00*/ __le16 id_count; /* Number of bytes that can be used
608 * for data, starting at id_data */
609 __le16 id_reserved0;
610 __le32 id_reserved1;
611 __u8 id_data[0]; /* Start of user data */
615 * On disk inode for OCFS2
617 struct ocfs2_dinode {
618 /*00*/ __u8 i_signature[8]; /* Signature for validation */
619 __le32 i_generation; /* Generation number */
620 __le16 i_suballoc_slot; /* Slot suballocator this inode
621 belongs to */
622 __le16 i_suballoc_bit; /* Bit offset in suballocator
623 block group */
624 /*10*/ __le32 i_reserved0;
625 __le32 i_clusters; /* Cluster count */
626 __le32 i_uid; /* Owner UID */
627 __le32 i_gid; /* Owning GID */
628 /*20*/ __le64 i_size; /* Size in bytes */
629 __le16 i_mode; /* File mode */
630 __le16 i_links_count; /* Links count */
631 __le32 i_flags; /* File flags */
632 /*30*/ __le64 i_atime; /* Access time */
633 __le64 i_ctime; /* Creation time */
634 /*40*/ __le64 i_mtime; /* Modification time */
635 __le64 i_dtime; /* Deletion time */
636 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
637 __le64 i_last_eb_blk; /* Pointer to last extent
638 block */
639 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
640 __le32 i_atime_nsec;
641 __le32 i_ctime_nsec;
642 __le32 i_mtime_nsec;
643 __le32 i_attr;
644 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
645 was set in i_flags */
646 __le16 i_dyn_features;
647 /*70*/ __le64 i_reserved2[8];
648 /*B8*/ union {
649 __le64 i_pad1; /* Generic way to refer to this
650 64bit union */
651 struct {
652 __le64 i_rdev; /* Device number */
653 } dev1;
654 struct { /* Info for bitmap system
655 inodes */
656 __le32 i_used; /* Bits (ie, clusters) used */
657 __le32 i_total; /* Total bits (clusters)
658 available */
659 } bitmap1;
660 struct { /* Info for journal system
661 inodes */
662 __le32 ij_flags; /* Mounted, version, etc. */
663 __le32 ij_recovery_generation; /* Incremented when the
664 journal is recovered
665 after an unclean
666 shutdown */
667 } journal1;
668 } id1; /* Inode type dependant 1 */
669 /*C0*/ union {
670 struct ocfs2_super_block i_super;
671 struct ocfs2_local_alloc i_lab;
672 struct ocfs2_chain_list i_chain;
673 struct ocfs2_extent_list i_list;
674 struct ocfs2_truncate_log i_dealloc;
675 struct ocfs2_inline_data i_data;
676 __u8 i_symlink[0];
677 } id2;
678 /* Actual on-disk size is one block */
682 * On-disk directory entry structure for OCFS2
684 * Packed as this structure could be accessed unaligned on 64-bit platforms
686 struct ocfs2_dir_entry {
687 /*00*/ __le64 inode; /* Inode number */
688 __le16 rec_len; /* Directory entry length */
689 __u8 name_len; /* Name length */
690 __u8 file_type;
691 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
692 /* Actual on-disk length specified by rec_len */
693 } __attribute__ ((packed));
696 * On disk allocator group structure for OCFS2
698 struct ocfs2_group_desc
700 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
701 __le16 bg_size; /* Size of included bitmap in
702 bytes. */
703 __le16 bg_bits; /* Bits represented by this
704 group. */
705 __le16 bg_free_bits_count; /* Free bits count */
706 __le16 bg_chain; /* What chain I am in. */
707 /*10*/ __le32 bg_generation;
708 __le32 bg_reserved1;
709 __le64 bg_next_group; /* Next group in my list, in
710 blocks */
711 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
712 blocks */
713 __le64 bg_blkno; /* Offset on disk, in blocks */
714 /*30*/ __le64 bg_reserved2[2];
715 /*40*/ __u8 bg_bitmap[0];
718 #ifdef __KERNEL__
719 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
721 return sb->s_blocksize -
722 offsetof(struct ocfs2_dinode, id2.i_symlink);
725 static inline int ocfs2_max_inline_data(struct super_block *sb)
727 return sb->s_blocksize -
728 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
731 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
733 int size;
735 size = sb->s_blocksize -
736 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
738 return size / sizeof(struct ocfs2_extent_rec);
741 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
743 int size;
745 size = sb->s_blocksize -
746 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
748 return size / sizeof(struct ocfs2_chain_rec);
751 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
753 int size;
755 size = sb->s_blocksize -
756 offsetof(struct ocfs2_extent_block, h_list.l_recs);
758 return size / sizeof(struct ocfs2_extent_rec);
761 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
763 u16 size;
765 size = sb->s_blocksize -
766 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
768 return size;
771 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
773 int size;
775 size = sb->s_blocksize -
776 offsetof(struct ocfs2_group_desc, bg_bitmap);
778 return size;
781 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
783 int size;
785 size = sb->s_blocksize -
786 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
788 return size / sizeof(struct ocfs2_truncate_rec);
791 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
793 u64 offset = OCFS2_BACKUP_SB_START;
795 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
796 offset <<= (2 * index);
797 offset >>= sb->s_blocksize_bits;
798 return offset;
801 return 0;
804 #else
805 static inline int ocfs2_fast_symlink_chars(int blocksize)
807 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
810 static inline int ocfs2_max_inline_data(int blocksize)
812 return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
815 static inline int ocfs2_extent_recs_per_inode(int blocksize)
817 int size;
819 size = blocksize -
820 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
822 return size / sizeof(struct ocfs2_extent_rec);
825 static inline int ocfs2_chain_recs_per_inode(int blocksize)
827 int size;
829 size = blocksize -
830 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
832 return size / sizeof(struct ocfs2_chain_rec);
835 static inline int ocfs2_extent_recs_per_eb(int blocksize)
837 int size;
839 size = blocksize -
840 offsetof(struct ocfs2_extent_block, h_list.l_recs);
842 return size / sizeof(struct ocfs2_extent_rec);
845 static inline int ocfs2_local_alloc_size(int blocksize)
847 int size;
849 size = blocksize -
850 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
852 return size;
855 static inline int ocfs2_group_bitmap_size(int blocksize)
857 int size;
859 size = blocksize -
860 offsetof(struct ocfs2_group_desc, bg_bitmap);
862 return size;
865 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
867 int size;
869 size = blocksize -
870 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
872 return size / sizeof(struct ocfs2_truncate_rec);
875 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
877 uint64_t offset = OCFS2_BACKUP_SB_START;
879 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
880 offset <<= (2 * index);
881 offset /= blocksize;
882 return offset;
885 return 0;
887 #endif /* __KERNEL__ */
890 static inline int ocfs2_system_inode_is_global(int type)
892 return ((type >= 0) &&
893 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
896 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
897 int type, int slot)
899 int chars;
902 * Global system inodes can only have one copy. Everything
903 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
904 * list has a copy per slot.
906 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
907 chars = snprintf(buf, len, "%s",
908 ocfs2_system_inodes[type].si_name);
909 else
910 chars = snprintf(buf, len,
911 ocfs2_system_inodes[type].si_name,
912 slot);
914 return chars;
917 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
918 umode_t mode)
920 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
923 #endif /* _OCFS2_FS_H */