Staging: line6: needs to select SND_PCM
[linux-kbuild.git] / fs / ocfs2 / ocfs2_fs.h
blob33f1c9a8258d1d4de5a17fe1ebf1d0d39c4098c3
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"
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 | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)
105 #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
106 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
107 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
110 * Heartbeat-only devices are missing journals and other files. The
111 * filesystem driver can't load them, but the library can. Never put
112 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
114 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
117 * tunefs sets this incompat flag before starting the resize and clears it
118 * at the end. This flag protects users from inadvertently mounting the fs
119 * after an aborted run without fsck-ing.
121 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
123 /* Used to denote a non-clustered volume */
124 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
126 /* Support for sparse allocation in b-trees */
127 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
130 * Tunefs sets this incompat flag before starting an operation which
131 * would require cleanup on abort. This is done to protect users from
132 * inadvertently mounting the fs after an aborted run without
133 * fsck-ing.
135 * s_tunefs_flags on the super block describes precisely which
136 * operations were in progress.
138 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
140 /* Support for data packed into inode blocks */
141 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
144 * Support for alternate, userspace cluster stacks. If set, the superblock
145 * field s_cluster_info contains a tag for the alternate stack in use as
146 * well as the name of the cluster being joined.
147 * mount.ocfs2 must pass in a matching stack name.
149 * If not set, the classic stack will be used. This is compatbile with
150 * all older versions.
152 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
154 /* Support for the extended slot map */
155 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
157 /* Support for extended attributes */
158 #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
160 /* Support for indexed directores */
161 #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
163 /* Metadata checksum and error correction */
164 #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
166 /* Refcount tree support */
167 #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
169 /* Discontigous block groups */
170 #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
173 * backup superblock flag is used to indicate that this volume
174 * has backup superblocks.
176 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
179 * The filesystem will correctly handle journal feature bits.
181 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
184 * Unwritten extents support.
186 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
189 * Maintain quota information for this filesystem
191 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
192 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
194 /* The byte offset of the first backup block will be 1G.
195 * The following will be 4G, 16G, 64G, 256G and 1T.
197 #define OCFS2_BACKUP_SB_START 1 << 30
199 /* the max backup superblock nums */
200 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
203 * Flags on ocfs2_super_block.s_tunefs_flags
205 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
208 * Flags on ocfs2_dinode.i_flags
210 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
211 #define OCFS2_UNUSED2_FL (0x00000002)
212 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
213 #define OCFS2_UNUSED3_FL (0x00000008)
214 /* System inode flags */
215 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
216 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
217 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
218 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
219 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
220 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
221 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
222 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
223 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
226 * Flags on ocfs2_dinode.i_dyn_features
228 * These can change much more often than i_flags. When adding flags,
229 * keep in mind that i_dyn_features is only 16 bits wide.
231 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
232 #define OCFS2_HAS_XATTR_FL (0x0002)
233 #define OCFS2_INLINE_XATTR_FL (0x0004)
234 #define OCFS2_INDEXED_DIR_FL (0x0008)
235 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
237 /* Inode attributes, keep in sync with EXT2 */
238 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
239 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
240 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
241 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
242 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
243 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
244 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
245 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
246 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
248 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
249 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
252 * Extent record flags (e_node.leaf.flags)
254 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
255 * unwritten */
256 #define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
257 * counted in an associated
258 * refcount tree */
261 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
263 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
266 * superblock s_state flags
268 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
270 /* Limit of space in ocfs2_dir_entry */
271 #define OCFS2_MAX_FILENAME_LEN 255
273 /* Maximum slots on an ocfs2 file system */
274 #define OCFS2_MAX_SLOTS 255
276 /* Slot map indicator for an empty slot */
277 #define OCFS2_INVALID_SLOT -1
279 #define OCFS2_VOL_UUID_LEN 16
280 #define OCFS2_MAX_VOL_LABEL_LEN 64
282 /* The alternate, userspace stack fields */
283 #define OCFS2_STACK_LABEL_LEN 4
284 #define OCFS2_CLUSTER_NAME_LEN 16
286 /* Journal limits (in bytes) */
287 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
290 * Inline extended attribute size (in bytes)
291 * The value chosen should be aligned to 16 byte boundaries.
293 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
295 struct ocfs2_system_inode_info {
296 char *si_name;
297 int si_iflags;
298 int si_mode;
301 /* System file index */
302 enum {
303 BAD_BLOCK_SYSTEM_INODE = 0,
304 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
305 SLOT_MAP_SYSTEM_INODE,
306 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
307 HEARTBEAT_SYSTEM_INODE,
308 GLOBAL_BITMAP_SYSTEM_INODE,
309 USER_QUOTA_SYSTEM_INODE,
310 GROUP_QUOTA_SYSTEM_INODE,
311 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
312 ORPHAN_DIR_SYSTEM_INODE,
313 EXTENT_ALLOC_SYSTEM_INODE,
314 INODE_ALLOC_SYSTEM_INODE,
315 JOURNAL_SYSTEM_INODE,
316 LOCAL_ALLOC_SYSTEM_INODE,
317 TRUNCATE_LOG_SYSTEM_INODE,
318 LOCAL_USER_QUOTA_SYSTEM_INODE,
319 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
320 NUM_SYSTEM_INODES
323 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
324 /* Global system inodes (single copy) */
325 /* The first two are only used from userspace mfks/tunefs */
326 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
327 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
329 /* These are used by the running filesystem */
330 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
331 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
332 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
333 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
334 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
336 /* Slot-specific system inodes (one copy per slot) */
337 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
338 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
339 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
340 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
341 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
342 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
343 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
344 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
347 /* Parameter passed from mount.ocfs2 to module */
348 #define OCFS2_HB_NONE "heartbeat=none"
349 #define OCFS2_HB_LOCAL "heartbeat=local"
352 * OCFS2 directory file types. Only the low 3 bits are used. The
353 * other bits are reserved for now.
355 #define OCFS2_FT_UNKNOWN 0
356 #define OCFS2_FT_REG_FILE 1
357 #define OCFS2_FT_DIR 2
358 #define OCFS2_FT_CHRDEV 3
359 #define OCFS2_FT_BLKDEV 4
360 #define OCFS2_FT_FIFO 5
361 #define OCFS2_FT_SOCK 6
362 #define OCFS2_FT_SYMLINK 7
364 #define OCFS2_FT_MAX 8
367 * OCFS2_DIR_PAD defines the directory entries boundaries
369 * NOTE: It must be a multiple of 4
371 #define OCFS2_DIR_PAD 4
372 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
373 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
374 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
375 OCFS2_DIR_ROUND) & \
376 ~OCFS2_DIR_ROUND)
377 #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
379 #define OCFS2_LINK_MAX 32000
380 #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
381 #define OCFS2_LINKS_HI_SHIFT 16
382 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
384 #define S_SHIFT 12
385 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
386 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
387 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
388 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
389 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
390 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
391 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
392 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
397 * Convenience casts
399 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
402 * Block checking structure. This is used in metadata to validate the
403 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
404 * zeros.
406 struct ocfs2_block_check {
407 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
408 __le16 bc_ecc; /* Single-error-correction parity vector.
409 This is a simple Hamming code dependant
410 on the blocksize. OCFS2's maximum
411 blocksize, 4K, requires 16 parity bits,
412 so we fit in __le16. */
413 __le16 bc_reserved1;
414 /*08*/
418 * On disk extent record for OCFS2
419 * It describes a range of clusters on disk.
421 * Length fields are divided into interior and leaf node versions.
422 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
424 struct ocfs2_extent_rec {
425 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
426 union {
427 __le32 e_int_clusters; /* Clusters covered by all children */
428 struct {
429 __le16 e_leaf_clusters; /* Clusters covered by this
430 extent */
431 __u8 e_reserved1;
432 __u8 e_flags; /* Extent flags */
435 __le64 e_blkno; /* Physical disk offset, in blocks */
436 /*10*/
439 struct ocfs2_chain_rec {
440 __le32 c_free; /* Number of free bits in this chain. */
441 __le32 c_total; /* Number of total bits in this chain */
442 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
445 struct ocfs2_truncate_rec {
446 __le32 t_start; /* 1st cluster in this log */
447 __le32 t_clusters; /* Number of total clusters covered */
451 * On disk extent list for OCFS2 (node in the tree). Note that this
452 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
453 * offsets are relative to ocfs2_dinode.id2.i_list or
454 * ocfs2_extent_block.h_list, respectively.
456 struct ocfs2_extent_list {
457 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
458 point. 0 means data extents
459 hang directly off this
460 header (a leaf)
461 NOTE: The high 8 bits cannot be
462 used - tree_depth is never that big.
464 __le16 l_count; /* Number of extent records */
465 __le16 l_next_free_rec; /* Next unused extent slot */
466 __le16 l_reserved1;
467 __le64 l_reserved2; /* Pad to
468 sizeof(ocfs2_extent_rec) */
469 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
473 * On disk allocation chain list for OCFS2. Note that this is
474 * contained inside ocfs2_dinode, so the offsets are relative to
475 * ocfs2_dinode.id2.i_chain.
477 struct ocfs2_chain_list {
478 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
479 __le16 cl_bpc; /* Bits per cluster */
480 __le16 cl_count; /* Total chains in this list */
481 __le16 cl_next_free_rec; /* Next unused chain slot */
482 __le64 cl_reserved1;
483 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
487 * On disk deallocation log for OCFS2. Note that this is
488 * contained inside ocfs2_dinode, so the offsets are relative to
489 * ocfs2_dinode.id2.i_dealloc.
491 struct ocfs2_truncate_log {
492 /*00*/ __le16 tl_count; /* Total records in this log */
493 __le16 tl_used; /* Number of records in use */
494 __le32 tl_reserved1;
495 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
499 * On disk extent block (indirect block) for OCFS2
501 struct ocfs2_extent_block
503 /*00*/ __u8 h_signature[8]; /* Signature for verification */
504 struct ocfs2_block_check h_check; /* Error checking */
505 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
506 extent_header belongs to */
507 __le16 h_suballoc_bit; /* Bit offset in suballocator
508 block group */
509 __le32 h_fs_generation; /* Must match super block */
510 __le64 h_blkno; /* Offset on disk, in blocks */
511 /*20*/ __le64 h_suballoc_loc; /* Suballocator block group this
512 eb belongs to. Only valid
513 if allocated from a
514 discontiguous block group */
515 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
516 of next leaf header pointing
517 to data */
518 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
519 /* Actual on-disk size is one block */
523 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
524 * system file. A slot is valid if it contains a node number >= 0. The
525 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
527 struct ocfs2_slot_map {
528 /*00*/ __le16 sm_slots[0];
530 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
531 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
535 struct ocfs2_extended_slot {
536 /*00*/ __u8 es_valid;
537 __u8 es_reserved1[3];
538 __le32 es_node_num;
539 /*10*/
543 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
544 * is set. It separates out the valid marker from the node number, and
545 * has room to grow. Unlike the old slot map, this format is defined by
546 * i_size.
548 struct ocfs2_slot_map_extended {
549 /*00*/ struct ocfs2_extended_slot se_slots[0];
551 * Actual size is i_size of the slot_map system file. It should
552 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
556 struct ocfs2_cluster_info {
557 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
558 __le32 ci_reserved;
559 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
560 /*18*/
564 * On disk superblock for OCFS2
565 * Note that it is contained inside an ocfs2_dinode, so all offsets
566 * are relative to the start of ocfs2_dinode.id2.
568 struct ocfs2_super_block {
569 /*00*/ __le16 s_major_rev_level;
570 __le16 s_minor_rev_level;
571 __le16 s_mnt_count;
572 __le16 s_max_mnt_count;
573 __le16 s_state; /* File system state */
574 __le16 s_errors; /* Behaviour when detecting errors */
575 __le32 s_checkinterval; /* Max time between checks */
576 /*10*/ __le64 s_lastcheck; /* Time of last check */
577 __le32 s_creator_os; /* OS */
578 __le32 s_feature_compat; /* Compatible feature set */
579 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
580 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
581 __le64 s_root_blkno; /* Offset, in blocks, of root directory
582 dinode */
583 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
584 directory dinode */
585 __le32 s_blocksize_bits; /* Blocksize for this fs */
586 __le32 s_clustersize_bits; /* Clustersize for this fs */
587 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
588 before tunefs required */
589 __le16 s_tunefs_flag;
590 __le32 s_uuid_hash; /* hash value of uuid */
591 __le64 s_first_cluster_group; /* Block offset of 1st cluster
592 * group header */
593 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
594 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
595 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
596 stack. Only valid
597 with INCOMPAT flag. */
598 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
599 for this fs*/
600 __le16 s_reserved0;
601 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
602 * s_uuid_hash serves as seed[3]. */
603 /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
604 /*140*/
607 * NOTE: As stated above, all offsets are relative to
608 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
609 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
610 * our smallest blocksize, which is 512 bytes. To ensure this,
611 * we reserve the space in s_reserved2. Anything past s_reserved2
612 * will not be available on the smallest blocksize.
617 * Local allocation bitmap for OCFS2 slots
618 * Note that it exists inside an ocfs2_dinode, so all offsets are
619 * relative to the start of ocfs2_dinode.id2.
621 struct ocfs2_local_alloc
623 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
624 __le16 la_size; /* Size of included bitmap, in bytes */
625 __le16 la_reserved1;
626 __le64 la_reserved2;
627 /*10*/ __u8 la_bitmap[0];
631 * Data-in-inode header. This is only used if i_dyn_features has
632 * OCFS2_INLINE_DATA_FL set.
634 struct ocfs2_inline_data
636 /*00*/ __le16 id_count; /* Number of bytes that can be used
637 * for data, starting at id_data */
638 __le16 id_reserved0;
639 __le32 id_reserved1;
640 __u8 id_data[0]; /* Start of user data */
644 * On disk inode for OCFS2
646 struct ocfs2_dinode {
647 /*00*/ __u8 i_signature[8]; /* Signature for validation */
648 __le32 i_generation; /* Generation number */
649 __le16 i_suballoc_slot; /* Slot suballocator this inode
650 belongs to */
651 __le16 i_suballoc_bit; /* Bit offset in suballocator
652 block group */
653 /*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
654 __le16 i_xattr_inline_size;
655 __le32 i_clusters; /* Cluster count */
656 __le32 i_uid; /* Owner UID */
657 __le32 i_gid; /* Owning GID */
658 /*20*/ __le64 i_size; /* Size in bytes */
659 __le16 i_mode; /* File mode */
660 __le16 i_links_count; /* Links count */
661 __le32 i_flags; /* File flags */
662 /*30*/ __le64 i_atime; /* Access time */
663 __le64 i_ctime; /* Creation time */
664 /*40*/ __le64 i_mtime; /* Modification time */
665 __le64 i_dtime; /* Deletion time */
666 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
667 __le64 i_last_eb_blk; /* Pointer to last extent
668 block */
669 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
670 __le32 i_atime_nsec;
671 __le32 i_ctime_nsec;
672 __le32 i_mtime_nsec;
673 /*70*/ __le32 i_attr;
674 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
675 was set in i_flags */
676 __le16 i_dyn_features;
677 __le64 i_xattr_loc;
678 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
679 /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
680 /*90*/ __le64 i_refcount_loc;
681 __le64 i_suballoc_loc; /* Suballocator block group this
682 inode belongs to. Only valid
683 if allocated from a
684 discontiguous block group */
685 /*A0*/ __le64 i_reserved2[3];
686 /*B8*/ union {
687 __le64 i_pad1; /* Generic way to refer to this
688 64bit union */
689 struct {
690 __le64 i_rdev; /* Device number */
691 } dev1;
692 struct { /* Info for bitmap system
693 inodes */
694 __le32 i_used; /* Bits (ie, clusters) used */
695 __le32 i_total; /* Total bits (clusters)
696 available */
697 } bitmap1;
698 struct { /* Info for journal system
699 inodes */
700 __le32 ij_flags; /* Mounted, version, etc. */
701 __le32 ij_recovery_generation; /* Incremented when the
702 journal is recovered
703 after an unclean
704 shutdown */
705 } journal1;
706 } id1; /* Inode type dependant 1 */
707 /*C0*/ union {
708 struct ocfs2_super_block i_super;
709 struct ocfs2_local_alloc i_lab;
710 struct ocfs2_chain_list i_chain;
711 struct ocfs2_extent_list i_list;
712 struct ocfs2_truncate_log i_dealloc;
713 struct ocfs2_inline_data i_data;
714 __u8 i_symlink[0];
715 } id2;
716 /* Actual on-disk size is one block */
720 * On-disk directory entry structure for OCFS2
722 * Packed as this structure could be accessed unaligned on 64-bit platforms
724 struct ocfs2_dir_entry {
725 /*00*/ __le64 inode; /* Inode number */
726 __le16 rec_len; /* Directory entry length */
727 __u8 name_len; /* Name length */
728 __u8 file_type;
729 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
730 /* Actual on-disk length specified by rec_len */
731 } __attribute__ ((packed));
734 * Per-block record for the unindexed directory btree. This is carefully
735 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
736 * mirrored. That way, the directory manipulation code needs a minimal amount
737 * of update.
739 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
741 struct ocfs2_dir_block_trailer {
742 /*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
744 __le16 db_compat_rec_len; /* Backwards compatible with
745 * ocfs2_dir_entry. */
746 __u8 db_compat_name_len; /* Always zero. Was name_len */
747 __u8 db_reserved0;
748 __le16 db_reserved1;
749 __le16 db_free_rec_len; /* Size of largest empty hole
750 * in this block. (unused) */
751 /*10*/ __u8 db_signature[8]; /* Signature for verification */
752 __le64 db_reserved2;
753 __le64 db_free_next; /* Next block in list (unused) */
754 /*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
755 __le64 db_parent_dinode; /* dinode which owns me, in
756 blocks */
757 /*30*/ struct ocfs2_block_check db_check; /* Error checking */
758 /*40*/
762 * A directory entry in the indexed tree. We don't store the full name here,
763 * but instead provide a pointer to the full dirent in the unindexed tree.
765 * We also store name_len here so as to reduce the number of leaf blocks we
766 * need to search in case of collisions.
768 struct ocfs2_dx_entry {
769 __le32 dx_major_hash; /* Used to find logical
770 * cluster in index */
771 __le32 dx_minor_hash; /* Lower bits used to find
772 * block in cluster */
773 __le64 dx_dirent_blk; /* Physical block in unindexed
774 * tree holding this dirent. */
777 struct ocfs2_dx_entry_list {
778 __le32 de_reserved;
779 __le16 de_count; /* Maximum number of entries
780 * possible in de_entries */
781 __le16 de_num_used; /* Current number of
782 * de_entries entries */
783 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
784 * in a packed array of
785 * length de_num_used */
788 #define OCFS2_DX_FLAG_INLINE 0x01
791 * A directory indexing block. Each indexed directory has one of these,
792 * pointed to by ocfs2_dinode.
794 * This block stores an indexed btree root, and a set of free space
795 * start-of-list pointers.
797 struct ocfs2_dx_root_block {
798 __u8 dr_signature[8]; /* Signature for verification */
799 struct ocfs2_block_check dr_check; /* Error checking */
800 __le16 dr_suballoc_slot; /* Slot suballocator this
801 * block belongs to. */
802 __le16 dr_suballoc_bit; /* Bit offset in suballocator
803 * block group */
804 __le32 dr_fs_generation; /* Must match super block */
805 __le64 dr_blkno; /* Offset on disk, in blocks */
806 __le64 dr_last_eb_blk; /* Pointer to last
807 * extent block */
808 __le32 dr_clusters; /* Clusters allocated
809 * to the indexed tree. */
810 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
811 __u8 dr_reserved0;
812 __le16 dr_reserved1;
813 __le64 dr_dir_blkno; /* Pointer to parent inode */
814 __le32 dr_num_entries; /* Total number of
815 * names stored in
816 * this directory.*/
817 __le32 dr_reserved2;
818 __le64 dr_free_blk; /* Pointer to head of free
819 * unindexed block list. */
820 __le64 dr_suballoc_loc; /* Suballocator block group
821 this root belongs to.
822 Only valid if allocated
823 from a discontiguous
824 block group */
825 __le64 dr_reserved3[14];
826 union {
827 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
828 * bits for maximum space
829 * efficiency. */
830 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
831 * entries. We grow out
832 * to extents if this
833 * gets too big. */
838 * The header of a leaf block in the indexed tree.
840 struct ocfs2_dx_leaf {
841 __u8 dl_signature[8];/* Signature for verification */
842 struct ocfs2_block_check dl_check; /* Error checking */
843 __le64 dl_blkno; /* Offset on disk, in blocks */
844 __le32 dl_fs_generation;/* Must match super block */
845 __le32 dl_reserved0;
846 __le64 dl_reserved1;
847 struct ocfs2_dx_entry_list dl_list;
851 * Largest bitmap for a block (suballocator) group in bytes. This limit
852 * does not affect cluster groups (global allocator). Cluster group
853 * bitmaps run to the end of the block.
855 #define OCFS2_MAX_BG_BITMAP_SIZE 256
858 * On disk allocator group structure for OCFS2
860 struct ocfs2_group_desc
862 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
863 __le16 bg_size; /* Size of included bitmap in
864 bytes. */
865 __le16 bg_bits; /* Bits represented by this
866 group. */
867 __le16 bg_free_bits_count; /* Free bits count */
868 __le16 bg_chain; /* What chain I am in. */
869 /*10*/ __le32 bg_generation;
870 __le32 bg_reserved1;
871 __le64 bg_next_group; /* Next group in my list, in
872 blocks */
873 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
874 blocks */
875 __le64 bg_blkno; /* Offset on disk, in blocks */
876 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
877 __le64 bg_reserved2;
878 /*40*/ union {
879 __u8 bg_bitmap[0];
880 struct {
882 * Block groups may be discontiguous when
883 * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
884 * The extents of a discontigous block group are
885 * stored in bg_list. It is a flat list.
886 * l_tree_depth must always be zero. A
887 * discontiguous group is signified by a non-zero
888 * bg_list->l_next_free_rec. Only block groups
889 * can be discontiguous; Cluster groups cannot.
890 * We've never made a block group with more than
891 * 2048 blocks (256 bytes of bg_bitmap). This
892 * codifies that limit so that we can fit bg_list.
893 * bg_size of a discontiguous block group will
894 * be 256 to match bg_bitmap_filler.
896 __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
897 /*140*/ struct ocfs2_extent_list bg_list;
900 /* Actual on-disk size is one block */
903 struct ocfs2_refcount_rec {
904 /*00*/ __le64 r_cpos; /* Physical offset, in clusters */
905 __le32 r_clusters; /* Clusters covered by this extent */
906 __le32 r_refcount; /* Reference count of this extent */
907 /*10*/
909 #define OCFS2_32BIT_POS_MASK (0xffffffffULL)
911 #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
912 #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
914 struct ocfs2_refcount_list {
915 /*00*/ __le16 rl_count; /* Maximum number of entries possible
916 in rl_records */
917 __le16 rl_used; /* Current number of used records */
918 __le32 rl_reserved2;
919 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
920 /*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
924 struct ocfs2_refcount_block {
925 /*00*/ __u8 rf_signature[8]; /* Signature for verification */
926 __le16 rf_suballoc_slot; /* Slot suballocator this block
927 belongs to */
928 __le16 rf_suballoc_bit; /* Bit offset in suballocator
929 block group */
930 __le32 rf_fs_generation; /* Must match superblock */
931 /*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
932 __le64 rf_parent; /* Parent block, only valid if
933 OCFS2_REFCOUNT_LEAF_FL is set in
934 rf_flags */
935 /*20*/ struct ocfs2_block_check rf_check; /* Error checking */
936 __le64 rf_last_eb_blk; /* Pointer to last extent block */
937 /*30*/ __le32 rf_count; /* Number of inodes sharing this
938 refcount tree */
939 __le32 rf_flags; /* See the flags above */
940 __le32 rf_clusters; /* clusters covered by refcount tree. */
941 __le32 rf_cpos; /* cluster offset in refcount tree.*/
942 /*40*/ __le32 rf_generation; /* generation number. all be the same
943 * for the same refcount tree. */
944 __le32 rf_reserved0;
945 __le64 rf_suballoc_loc; /* Suballocator block group this
946 refcount block belongs to. Only
947 valid if allocated from a
948 discontiguous block group */
949 /*50*/ __le64 rf_reserved1[6];
950 /*80*/ union {
951 struct ocfs2_refcount_list rf_records; /* List of refcount
952 records */
953 struct ocfs2_extent_list rf_list; /* Extent record list,
954 only valid if
955 OCFS2_REFCOUNT_TREE_FL
956 is set in rf_flags */
958 /* Actual on-disk size is one block */
962 * On disk extended attribute structure for OCFS2.
966 * ocfs2_xattr_entry indicates one extend attribute.
968 * Note that it can be stored in inode, one block or one xattr bucket.
970 struct ocfs2_xattr_entry {
971 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
972 __le16 xe_name_offset; /* byte offset from the 1st entry in the
973 local xattr storage(inode, xattr block or
974 xattr bucket). */
975 __u8 xe_name_len; /* xattr name len, does't include prefix. */
976 __u8 xe_type; /* the low 7 bits indicate the name prefix
977 * type and the highest bit indicates whether
978 * the EA is stored in the local storage. */
979 __le64 xe_value_size; /* real xattr value length. */
983 * On disk structure for xattr header.
985 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
986 * the local xattr storage.
988 struct ocfs2_xattr_header {
989 __le16 xh_count; /* contains the count of how
990 many records are in the
991 local xattr storage. */
992 __le16 xh_free_start; /* current offset for storing
993 xattr. */
994 __le16 xh_name_value_len; /* total length of name/value
995 length in this bucket. */
996 __le16 xh_num_buckets; /* Number of xattr buckets
997 in this extent record,
998 only valid in the first
999 bucket. */
1000 struct ocfs2_block_check xh_check; /* Error checking
1001 (Note, this is only
1002 used for xattr
1003 buckets. A block uses
1004 xb_check and sets
1005 this field to zero.) */
1006 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
1010 * On disk structure for xattr value root.
1012 * When an xattr's value is large enough, it is stored in an external
1013 * b-tree like file data. The xattr value root points to this structure.
1015 struct ocfs2_xattr_value_root {
1016 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
1017 __le32 xr_reserved0;
1018 __le64 xr_last_eb_blk; /* Pointer to last extent block */
1019 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
1023 * On disk structure for xattr tree root.
1025 * It is used when there are too many extended attributes for one file. These
1026 * attributes will be organized and stored in an indexed-btree.
1028 struct ocfs2_xattr_tree_root {
1029 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
1030 __le32 xt_reserved0;
1031 __le64 xt_last_eb_blk; /* Pointer to last extent block */
1032 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
1035 #define OCFS2_XATTR_INDEXED 0x1
1036 #define OCFS2_HASH_SHIFT 5
1037 #define OCFS2_XATTR_ROUND 3
1038 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1039 ~(OCFS2_XATTR_ROUND))
1041 #define OCFS2_XATTR_BUCKET_SIZE 4096
1042 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1043 / OCFS2_MIN_BLOCKSIZE)
1046 * On disk structure for xattr block.
1048 struct ocfs2_xattr_block {
1049 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
1050 __le16 xb_suballoc_slot; /* Slot suballocator this
1051 block belongs to. */
1052 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1053 block group */
1054 __le32 xb_fs_generation; /* Must match super block */
1055 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
1056 struct ocfs2_block_check xb_check; /* Error checking */
1057 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
1058 real xattr or a xattr tree. */
1059 __le16 xb_reserved0;
1060 __le32 xb_reserved1;
1061 __le64 xb_suballoc_loc; /* Suballocator block group this
1062 xattr block belongs to. Only
1063 valid if allocated from a
1064 discontiguous block group */
1065 /*30*/ union {
1066 struct ocfs2_xattr_header xb_header; /* xattr header if this
1067 block contains xattr */
1068 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1069 block cotains xattr
1070 tree. */
1071 } xb_attrs;
1074 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
1075 #define OCFS2_XATTR_TYPE_MASK 0x7F
1076 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1077 int local)
1079 if (local)
1080 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1081 else
1082 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1085 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1087 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1090 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1092 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1095 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1097 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1101 * On disk structures for global quota file
1104 /* Magic numbers and known versions for global quota files */
1105 #define OCFS2_GLOBAL_QMAGICS {\
1106 0x0cf52470, /* USRQUOTA */ \
1107 0x0cf52471 /* GRPQUOTA */ \
1110 #define OCFS2_GLOBAL_QVERSIONS {\
1111 0, \
1112 0, \
1116 /* Each block of each quota file has a certain fixed number of bytes reserved
1117 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1118 * checksums, etc. */
1119 #define OCFS2_QBLK_RESERVED_SPACE 8
1121 /* Generic header of all quota files */
1122 struct ocfs2_disk_dqheader {
1123 __le32 dqh_magic; /* Magic number identifying file */
1124 __le32 dqh_version; /* Quota format version */
1127 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1129 /* Information header of global quota file (immediately follows the generic
1130 * header) */
1131 struct ocfs2_global_disk_dqinfo {
1132 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1133 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1134 __le32 dqi_syncms; /* Time after which we sync local changes to
1135 * global quota file */
1136 __le32 dqi_blocks; /* Number of blocks in quota file */
1137 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1138 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1139 * file */
1142 /* Structure with global user / group information. We reserve some space
1143 * for future use. */
1144 struct ocfs2_global_disk_dqblk {
1145 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
1146 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1147 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1148 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1149 __le64 dqb_curinodes; /* current # allocated inodes */
1150 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1151 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1152 /*30*/ __le64 dqb_curspace; /* current space occupied */
1153 __le64 dqb_btime; /* time limit for excessive disk use */
1154 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1155 __le64 dqb_pad1;
1156 /*50*/ __le64 dqb_pad2;
1160 * On-disk structures for local quota file
1163 /* Magic numbers and known versions for local quota files */
1164 #define OCFS2_LOCAL_QMAGICS {\
1165 0x0cf524c0, /* USRQUOTA */ \
1166 0x0cf524c1 /* GRPQUOTA */ \
1169 #define OCFS2_LOCAL_QVERSIONS {\
1170 0, \
1171 0, \
1174 /* Quota flags in dqinfo header */
1175 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1176 * quota has been cleanly turned off) */
1178 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1180 /* Information header of local quota file (immediately follows the generic
1181 * header) */
1182 struct ocfs2_local_disk_dqinfo {
1183 __le32 dqi_flags; /* Flags for quota file */
1184 __le32 dqi_chunks; /* Number of chunks of quota structures
1185 * with a bitmap */
1186 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1189 /* Header of one chunk of a quota file */
1190 struct ocfs2_local_disk_chunk {
1191 __le32 dqc_free; /* Number of free entries in the bitmap */
1192 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1193 * chunk of quota file */
1196 /* One entry in local quota file */
1197 struct ocfs2_local_disk_dqblk {
1198 /*00*/ __le64 dqb_id; /* id this quota applies to */
1199 __le64 dqb_spacemod; /* Change in the amount of used space */
1200 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1205 * The quota trailer lives at the end of each quota block.
1208 struct ocfs2_disk_dqtrailer {
1209 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1210 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1213 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1214 void *buf)
1216 char *ptr = buf;
1217 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1219 return (struct ocfs2_disk_dqtrailer *)ptr;
1222 #ifdef __KERNEL__
1223 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1225 return sb->s_blocksize -
1226 offsetof(struct ocfs2_dinode, id2.i_symlink);
1229 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1230 struct ocfs2_dinode *di)
1232 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1234 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1235 return sb->s_blocksize -
1236 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1237 xattrsize;
1238 else
1239 return sb->s_blocksize -
1240 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1243 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1245 int size;
1247 size = sb->s_blocksize -
1248 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1250 return size / sizeof(struct ocfs2_extent_rec);
1253 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1254 struct super_block *sb,
1255 struct ocfs2_dinode *di)
1257 int size;
1258 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1260 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1261 size = sb->s_blocksize -
1262 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1263 xattrsize;
1264 else
1265 size = sb->s_blocksize -
1266 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1268 return size / sizeof(struct ocfs2_extent_rec);
1271 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1273 int size;
1275 size = sb->s_blocksize -
1276 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1278 return size / sizeof(struct ocfs2_extent_rec);
1281 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1283 int size;
1285 size = sb->s_blocksize -
1286 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1288 return size / sizeof(struct ocfs2_chain_rec);
1291 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1293 int size;
1295 size = sb->s_blocksize -
1296 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1298 return size / sizeof(struct ocfs2_extent_rec);
1301 static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1303 int size;
1305 size = sb->s_blocksize -
1306 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1308 return size / sizeof(struct ocfs2_extent_rec);
1311 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1313 int size;
1315 size = sb->s_blocksize -
1316 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1318 return size / sizeof(struct ocfs2_dx_entry);
1321 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1323 int size;
1325 size = sb->s_blocksize -
1326 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1328 return size / sizeof(struct ocfs2_dx_entry);
1331 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1333 u16 size;
1335 size = sb->s_blocksize -
1336 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1338 return size;
1341 static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1342 int suballocator,
1343 u32 feature_incompat)
1345 int size = sb->s_blocksize -
1346 offsetof(struct ocfs2_group_desc, bg_bitmap);
1349 * The cluster allocator uses the entire block. Suballocators have
1350 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1351 * code expects bg_size set to the maximum. Thus we must keep
1352 * bg_size as-is unless discontig_bg is enabled.
1354 if (suballocator &&
1355 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1356 size = OCFS2_MAX_BG_BITMAP_SIZE;
1358 return size;
1361 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1363 int size;
1365 size = sb->s_blocksize -
1366 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1368 return size / sizeof(struct ocfs2_truncate_rec);
1371 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1373 u64 offset = OCFS2_BACKUP_SB_START;
1375 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1376 offset <<= (2 * index);
1377 offset >>= sb->s_blocksize_bits;
1378 return offset;
1381 return 0;
1385 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1387 int size;
1389 size = sb->s_blocksize -
1390 offsetof(struct ocfs2_xattr_block,
1391 xb_attrs.xb_root.xt_list.l_recs);
1393 return size / sizeof(struct ocfs2_extent_rec);
1396 static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1398 int size;
1400 size = sb->s_blocksize -
1401 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1403 return size / sizeof(struct ocfs2_extent_rec);
1406 static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1408 int size;
1410 size = sb->s_blocksize -
1411 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1413 return size / sizeof(struct ocfs2_refcount_rec);
1416 static inline u32
1417 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1419 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1421 #else
1422 static inline int ocfs2_fast_symlink_chars(int blocksize)
1424 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1427 static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1428 struct ocfs2_dinode *di)
1430 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1431 return blocksize -
1432 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1433 di->i_xattr_inline_size;
1434 else
1435 return blocksize -
1436 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1439 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1441 int size;
1443 size = blocksize -
1444 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1446 return size / sizeof(struct ocfs2_extent_rec);
1449 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1451 int size;
1453 size = blocksize -
1454 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1456 return size / sizeof(struct ocfs2_chain_rec);
1459 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1461 int size;
1463 size = blocksize -
1464 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1466 return size / sizeof(struct ocfs2_extent_rec);
1469 static inline int ocfs2_extent_recs_per_gd(int blocksize)
1471 int size;
1473 size = blocksize -
1474 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1476 return size / sizeof(struct ocfs2_extent_rec);
1479 static inline int ocfs2_local_alloc_size(int blocksize)
1481 int size;
1483 size = blocksize -
1484 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1486 return size;
1489 static inline int ocfs2_group_bitmap_size(int blocksize,
1490 int suballocator,
1491 uint32_t feature_incompat)
1493 int size = sb->s_blocksize -
1494 offsetof(struct ocfs2_group_desc, bg_bitmap);
1497 * The cluster allocator uses the entire block. Suballocators have
1498 * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older
1499 * code expects bg_size set to the maximum. Thus we must keep
1500 * bg_size as-is unless discontig_bg is enabled.
1502 if (suballocator &&
1503 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1504 size = OCFS2_MAX_BG_BITMAP_SIZE;
1506 return size;
1509 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1511 int size;
1513 size = blocksize -
1514 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1516 return size / sizeof(struct ocfs2_truncate_rec);
1519 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1521 uint64_t offset = OCFS2_BACKUP_SB_START;
1523 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1524 offset <<= (2 * index);
1525 offset /= blocksize;
1526 return offset;
1529 return 0;
1532 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1534 int size;
1536 size = blocksize -
1537 offsetof(struct ocfs2_xattr_block,
1538 xb_attrs.xb_root.xt_list.l_recs);
1540 return size / sizeof(struct ocfs2_extent_rec);
1542 #endif /* __KERNEL__ */
1545 static inline int ocfs2_system_inode_is_global(int type)
1547 return ((type >= 0) &&
1548 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1551 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1552 int type, int slot)
1554 int chars;
1557 * Global system inodes can only have one copy. Everything
1558 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1559 * list has a copy per slot.
1561 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1562 chars = snprintf(buf, len, "%s",
1563 ocfs2_system_inodes[type].si_name);
1564 else
1565 chars = snprintf(buf, len,
1566 ocfs2_system_inodes[type].si_name,
1567 slot);
1569 return chars;
1572 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1573 umode_t mode)
1575 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1578 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1580 if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1581 le16_to_cpu(gd->bg_size)) !=
1582 offsetof(struct ocfs2_group_desc, bg_list))
1583 return 0;
1585 * Only valid to check l_next_free_rec if
1586 * bg_bitmap + bg_size == bg_list.
1588 if (!gd->bg_list.l_next_free_rec)
1589 return 0;
1590 return 1;
1592 #endif /* _OCFS2_FS_H */