iop-adma: cleanup iop_adma_run_tx_complete_actions
[linux/fpc-iii.git] / fs / ocfs2 / ocfs2_fs.h
blobc7ae45aaa36cd5fa9bc8644dc92ab36a3d6aea55
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"
70 /* Compatibility flags */
71 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
72 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
73 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
74 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
75 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
76 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
77 #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
78 OCFS2_SB(sb)->s_feature_compat |= (mask)
79 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
80 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
81 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
82 OCFS2_SB(sb)->s_feature_incompat |= (mask)
83 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
84 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
85 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
86 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
87 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
88 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
90 #define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \
91 | OCFS2_FEATURE_COMPAT_JBD2_SB)
92 #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
93 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
94 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
95 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
96 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
97 | OCFS2_FEATURE_INCOMPAT_XATTR \
98 | OCFS2_FEATURE_INCOMPAT_META_ECC)
99 #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
100 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
101 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
104 * Heartbeat-only devices are missing journals and other files. The
105 * filesystem driver can't load them, but the library can. Never put
106 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
108 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
111 * tunefs sets this incompat flag before starting the resize and clears it
112 * at the end. This flag protects users from inadvertently mounting the fs
113 * after an aborted run without fsck-ing.
115 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
117 /* Used to denote a non-clustered volume */
118 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
120 /* Support for sparse allocation in b-trees */
121 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
124 * Tunefs sets this incompat flag before starting an operation which
125 * would require cleanup on abort. This is done to protect users from
126 * inadvertently mounting the fs after an aborted run without
127 * fsck-ing.
129 * s_tunefs_flags on the super block describes precisely which
130 * operations were in progress.
132 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
134 /* Support for data packed into inode blocks */
135 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
138 * Support for alternate, userspace cluster stacks. If set, the superblock
139 * field s_cluster_info contains a tag for the alternate stack in use as
140 * well as the name of the cluster being joined.
141 * mount.ocfs2 must pass in a matching stack name.
143 * If not set, the classic stack will be used. This is compatbile with
144 * all older versions.
146 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
148 /* Support for the extended slot map */
149 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
151 /* Support for extended attributes */
152 #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
154 /* Metadata checksum and error correction */
155 #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
158 * backup superblock flag is used to indicate that this volume
159 * has backup superblocks.
161 #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
164 * The filesystem will correctly handle journal feature bits.
166 #define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
169 * Unwritten extents support.
171 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
174 * Maintain quota information for this filesystem
176 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
177 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
179 /* The byte offset of the first backup block will be 1G.
180 * The following will be 4G, 16G, 64G, 256G and 1T.
182 #define OCFS2_BACKUP_SB_START 1 << 30
184 /* the max backup superblock nums */
185 #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
188 * Flags on ocfs2_super_block.s_tunefs_flags
190 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
193 * Flags on ocfs2_dinode.i_flags
195 #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
196 #define OCFS2_UNUSED2_FL (0x00000002)
197 #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
198 #define OCFS2_UNUSED3_FL (0x00000008)
199 /* System inode flags */
200 #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
201 #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
202 #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
203 #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
204 #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
205 #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
206 #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
207 #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
208 #define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
211 * Flags on ocfs2_dinode.i_dyn_features
213 * These can change much more often than i_flags. When adding flags,
214 * keep in mind that i_dyn_features is only 16 bits wide.
216 #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
217 #define OCFS2_HAS_XATTR_FL (0x0002)
218 #define OCFS2_INLINE_XATTR_FL (0x0004)
219 #define OCFS2_INDEXED_DIR_FL (0x0008)
221 /* Inode attributes, keep in sync with EXT2 */
222 #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
223 #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
224 #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
225 #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
226 #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
227 #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
228 #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
229 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
230 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
232 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
233 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
236 * Extent record flags (e_node.leaf.flags)
238 #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
239 * unwritten */
242 * ioctl commands
244 #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
245 #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
246 #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
247 #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
250 * Space reservation / allocation / free ioctls and argument structure
251 * are designed to be compatible with XFS.
253 * ALLOCSP* and FREESP* are not and will never be supported, but are
254 * included here for completeness.
256 struct ocfs2_space_resv {
257 __s16 l_type;
258 __s16 l_whence;
259 __s64 l_start;
260 __s64 l_len; /* len == 0 means until end of file */
261 __s32 l_sysid;
262 __u32 l_pid;
263 __s32 l_pad[4]; /* reserve area */
266 #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
267 #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
268 #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
269 #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
270 #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
271 #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
272 #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
273 #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
275 /* Used to pass group descriptor data when online resize is done */
276 struct ocfs2_new_group_input {
277 __u64 group; /* Group descriptor's blkno. */
278 __u32 clusters; /* Total number of clusters in this group */
279 __u32 frees; /* Total free clusters in this group */
280 __u16 chain; /* Chain for this group */
281 __u16 reserved1;
282 __u32 reserved2;
285 #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
286 #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
287 #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
290 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
292 #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
295 * superblock s_state flags
297 #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
299 /* Limit of space in ocfs2_dir_entry */
300 #define OCFS2_MAX_FILENAME_LEN 255
302 /* Maximum slots on an ocfs2 file system */
303 #define OCFS2_MAX_SLOTS 255
305 /* Slot map indicator for an empty slot */
306 #define OCFS2_INVALID_SLOT -1
308 #define OCFS2_VOL_UUID_LEN 16
309 #define OCFS2_MAX_VOL_LABEL_LEN 64
311 /* The alternate, userspace stack fields */
312 #define OCFS2_STACK_LABEL_LEN 4
313 #define OCFS2_CLUSTER_NAME_LEN 16
315 /* Journal limits (in bytes) */
316 #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
319 * Default local alloc size (in megabytes)
321 * The value chosen should be such that most allocations, including new
322 * block groups, use local alloc.
324 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
327 * Inline extended attribute size (in bytes)
328 * The value chosen should be aligned to 16 byte boundaries.
330 #define OCFS2_MIN_XATTR_INLINE_SIZE 256
332 struct ocfs2_system_inode_info {
333 char *si_name;
334 int si_iflags;
335 int si_mode;
338 /* System file index */
339 enum {
340 BAD_BLOCK_SYSTEM_INODE = 0,
341 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
342 SLOT_MAP_SYSTEM_INODE,
343 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
344 HEARTBEAT_SYSTEM_INODE,
345 GLOBAL_BITMAP_SYSTEM_INODE,
346 USER_QUOTA_SYSTEM_INODE,
347 GROUP_QUOTA_SYSTEM_INODE,
348 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
349 ORPHAN_DIR_SYSTEM_INODE,
350 EXTENT_ALLOC_SYSTEM_INODE,
351 INODE_ALLOC_SYSTEM_INODE,
352 JOURNAL_SYSTEM_INODE,
353 LOCAL_ALLOC_SYSTEM_INODE,
354 TRUNCATE_LOG_SYSTEM_INODE,
355 LOCAL_USER_QUOTA_SYSTEM_INODE,
356 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
357 NUM_SYSTEM_INODES
360 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
361 /* Global system inodes (single copy) */
362 /* The first two are only used from userspace mfks/tunefs */
363 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
364 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
366 /* These are used by the running filesystem */
367 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
368 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
369 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
370 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
371 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
373 /* Slot-specific system inodes (one copy per slot) */
374 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
375 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
376 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
377 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
378 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
379 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
380 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
381 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
384 /* Parameter passed from mount.ocfs2 to module */
385 #define OCFS2_HB_NONE "heartbeat=none"
386 #define OCFS2_HB_LOCAL "heartbeat=local"
389 * OCFS2 directory file types. Only the low 3 bits are used. The
390 * other bits are reserved for now.
392 #define OCFS2_FT_UNKNOWN 0
393 #define OCFS2_FT_REG_FILE 1
394 #define OCFS2_FT_DIR 2
395 #define OCFS2_FT_CHRDEV 3
396 #define OCFS2_FT_BLKDEV 4
397 #define OCFS2_FT_FIFO 5
398 #define OCFS2_FT_SOCK 6
399 #define OCFS2_FT_SYMLINK 7
401 #define OCFS2_FT_MAX 8
404 * OCFS2_DIR_PAD defines the directory entries boundaries
406 * NOTE: It must be a multiple of 4
408 #define OCFS2_DIR_PAD 4
409 #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
410 #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
411 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
412 OCFS2_DIR_ROUND) & \
413 ~OCFS2_DIR_ROUND)
415 #define OCFS2_LINK_MAX 32000
417 #define S_SHIFT 12
418 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
419 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
420 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
421 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
422 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
423 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
424 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
425 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
430 * Convenience casts
432 #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
435 * Block checking structure. This is used in metadata to validate the
436 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
437 * zeros.
439 struct ocfs2_block_check {
440 /*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
441 __le16 bc_ecc; /* Single-error-correction parity vector.
442 This is a simple Hamming code dependant
443 on the blocksize. OCFS2's maximum
444 blocksize, 4K, requires 16 parity bits,
445 so we fit in __le16. */
446 __le16 bc_reserved1;
447 /*08*/
451 * On disk extent record for OCFS2
452 * It describes a range of clusters on disk.
454 * Length fields are divided into interior and leaf node versions.
455 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
457 struct ocfs2_extent_rec {
458 /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
459 union {
460 __le32 e_int_clusters; /* Clusters covered by all children */
461 struct {
462 __le16 e_leaf_clusters; /* Clusters covered by this
463 extent */
464 __u8 e_reserved1;
465 __u8 e_flags; /* Extent flags */
468 __le64 e_blkno; /* Physical disk offset, in blocks */
469 /*10*/
472 struct ocfs2_chain_rec {
473 __le32 c_free; /* Number of free bits in this chain. */
474 __le32 c_total; /* Number of total bits in this chain */
475 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
478 struct ocfs2_truncate_rec {
479 __le32 t_start; /* 1st cluster in this log */
480 __le32 t_clusters; /* Number of total clusters covered */
484 * On disk extent list for OCFS2 (node in the tree). Note that this
485 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
486 * offsets are relative to ocfs2_dinode.id2.i_list or
487 * ocfs2_extent_block.h_list, respectively.
489 struct ocfs2_extent_list {
490 /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
491 point. 0 means data extents
492 hang directly off this
493 header (a leaf)
494 NOTE: The high 8 bits cannot be
495 used - tree_depth is never that big.
497 __le16 l_count; /* Number of extent records */
498 __le16 l_next_free_rec; /* Next unused extent slot */
499 __le16 l_reserved1;
500 __le64 l_reserved2; /* Pad to
501 sizeof(ocfs2_extent_rec) */
502 /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
506 * On disk allocation chain list for OCFS2. Note that this is
507 * contained inside ocfs2_dinode, so the offsets are relative to
508 * ocfs2_dinode.id2.i_chain.
510 struct ocfs2_chain_list {
511 /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
512 __le16 cl_bpc; /* Bits per cluster */
513 __le16 cl_count; /* Total chains in this list */
514 __le16 cl_next_free_rec; /* Next unused chain slot */
515 __le64 cl_reserved1;
516 /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
520 * On disk deallocation log for OCFS2. Note that this is
521 * contained inside ocfs2_dinode, so the offsets are relative to
522 * ocfs2_dinode.id2.i_dealloc.
524 struct ocfs2_truncate_log {
525 /*00*/ __le16 tl_count; /* Total records in this log */
526 __le16 tl_used; /* Number of records in use */
527 __le32 tl_reserved1;
528 /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
532 * On disk extent block (indirect block) for OCFS2
534 struct ocfs2_extent_block
536 /*00*/ __u8 h_signature[8]; /* Signature for verification */
537 struct ocfs2_block_check h_check; /* Error checking */
538 /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
539 extent_header belongs to */
540 __le16 h_suballoc_bit; /* Bit offset in suballocator
541 block group */
542 __le32 h_fs_generation; /* Must match super block */
543 __le64 h_blkno; /* Offset on disk, in blocks */
544 /*20*/ __le64 h_reserved3;
545 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
546 of next leaf header pointing
547 to data */
548 /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
549 /* Actual on-disk size is one block */
553 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
554 * system file. A slot is valid if it contains a node number >= 0. The
555 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
557 struct ocfs2_slot_map {
558 /*00*/ __le16 sm_slots[0];
560 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
561 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
565 struct ocfs2_extended_slot {
566 /*00*/ __u8 es_valid;
567 __u8 es_reserved1[3];
568 __le32 es_node_num;
569 /*10*/
573 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
574 * is set. It separates out the valid marker from the node number, and
575 * has room to grow. Unlike the old slot map, this format is defined by
576 * i_size.
578 struct ocfs2_slot_map_extended {
579 /*00*/ struct ocfs2_extended_slot se_slots[0];
581 * Actual size is i_size of the slot_map system file. It should
582 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
586 struct ocfs2_cluster_info {
587 /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
588 __le32 ci_reserved;
589 /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
590 /*18*/
594 * On disk superblock for OCFS2
595 * Note that it is contained inside an ocfs2_dinode, so all offsets
596 * are relative to the start of ocfs2_dinode.id2.
598 struct ocfs2_super_block {
599 /*00*/ __le16 s_major_rev_level;
600 __le16 s_minor_rev_level;
601 __le16 s_mnt_count;
602 __le16 s_max_mnt_count;
603 __le16 s_state; /* File system state */
604 __le16 s_errors; /* Behaviour when detecting errors */
605 __le32 s_checkinterval; /* Max time between checks */
606 /*10*/ __le64 s_lastcheck; /* Time of last check */
607 __le32 s_creator_os; /* OS */
608 __le32 s_feature_compat; /* Compatible feature set */
609 /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
610 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
611 __le64 s_root_blkno; /* Offset, in blocks, of root directory
612 dinode */
613 /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
614 directory dinode */
615 __le32 s_blocksize_bits; /* Blocksize for this fs */
616 __le32 s_clustersize_bits; /* Clustersize for this fs */
617 /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
618 before tunefs required */
619 __le16 s_tunefs_flag;
620 __le32 s_uuid_hash; /* hash value of uuid */
621 __le64 s_first_cluster_group; /* Block offset of 1st cluster
622 * group header */
623 /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
624 /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
625 /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
626 stack. Only valid
627 with INCOMPAT flag. */
628 /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
629 for this fs*/
630 __le16 s_reserved0;
631 __le32 s_reserved1;
632 /*C0*/ __le64 s_reserved2[16]; /* Fill out superblock */
633 /*140*/
636 * NOTE: As stated above, all offsets are relative to
637 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
638 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
639 * our smallest blocksize, which is 512 bytes. To ensure this,
640 * we reserve the space in s_reserved2. Anything past s_reserved2
641 * will not be available on the smallest blocksize.
646 * Local allocation bitmap for OCFS2 slots
647 * Note that it exists inside an ocfs2_dinode, so all offsets are
648 * relative to the start of ocfs2_dinode.id2.
650 struct ocfs2_local_alloc
652 /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
653 __le16 la_size; /* Size of included bitmap, in bytes */
654 __le16 la_reserved1;
655 __le64 la_reserved2;
656 /*10*/ __u8 la_bitmap[0];
660 * Data-in-inode header. This is only used if i_dyn_features has
661 * OCFS2_INLINE_DATA_FL set.
663 struct ocfs2_inline_data
665 /*00*/ __le16 id_count; /* Number of bytes that can be used
666 * for data, starting at id_data */
667 __le16 id_reserved0;
668 __le32 id_reserved1;
669 __u8 id_data[0]; /* Start of user data */
673 * On disk inode for OCFS2
675 struct ocfs2_dinode {
676 /*00*/ __u8 i_signature[8]; /* Signature for validation */
677 __le32 i_generation; /* Generation number */
678 __le16 i_suballoc_slot; /* Slot suballocator this inode
679 belongs to */
680 __le16 i_suballoc_bit; /* Bit offset in suballocator
681 block group */
682 /*10*/ __le16 i_reserved0;
683 __le16 i_xattr_inline_size;
684 __le32 i_clusters; /* Cluster count */
685 __le32 i_uid; /* Owner UID */
686 __le32 i_gid; /* Owning GID */
687 /*20*/ __le64 i_size; /* Size in bytes */
688 __le16 i_mode; /* File mode */
689 __le16 i_links_count; /* Links count */
690 __le32 i_flags; /* File flags */
691 /*30*/ __le64 i_atime; /* Access time */
692 __le64 i_ctime; /* Creation time */
693 /*40*/ __le64 i_mtime; /* Modification time */
694 __le64 i_dtime; /* Deletion time */
695 /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
696 __le64 i_last_eb_blk; /* Pointer to last extent
697 block */
698 /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
699 __le32 i_atime_nsec;
700 __le32 i_ctime_nsec;
701 __le32 i_mtime_nsec;
702 /*70*/ __le32 i_attr;
703 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
704 was set in i_flags */
705 __le16 i_dyn_features;
706 __le64 i_xattr_loc;
707 /*80*/ struct ocfs2_block_check i_check; /* Error checking */
708 /*88*/ __le64 i_reserved2[6];
709 /*B8*/ union {
710 __le64 i_pad1; /* Generic way to refer to this
711 64bit union */
712 struct {
713 __le64 i_rdev; /* Device number */
714 } dev1;
715 struct { /* Info for bitmap system
716 inodes */
717 __le32 i_used; /* Bits (ie, clusters) used */
718 __le32 i_total; /* Total bits (clusters)
719 available */
720 } bitmap1;
721 struct { /* Info for journal system
722 inodes */
723 __le32 ij_flags; /* Mounted, version, etc. */
724 __le32 ij_recovery_generation; /* Incremented when the
725 journal is recovered
726 after an unclean
727 shutdown */
728 } journal1;
729 } id1; /* Inode type dependant 1 */
730 /*C0*/ union {
731 struct ocfs2_super_block i_super;
732 struct ocfs2_local_alloc i_lab;
733 struct ocfs2_chain_list i_chain;
734 struct ocfs2_extent_list i_list;
735 struct ocfs2_truncate_log i_dealloc;
736 struct ocfs2_inline_data i_data;
737 __u8 i_symlink[0];
738 } id2;
739 /* Actual on-disk size is one block */
743 * On-disk directory entry structure for OCFS2
745 * Packed as this structure could be accessed unaligned on 64-bit platforms
747 struct ocfs2_dir_entry {
748 /*00*/ __le64 inode; /* Inode number */
749 __le16 rec_len; /* Directory entry length */
750 __u8 name_len; /* Name length */
751 __u8 file_type;
752 /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
753 /* Actual on-disk length specified by rec_len */
754 } __attribute__ ((packed));
757 * Per-block record for the unindexed directory btree. This is carefully
758 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
759 * mirrored. That way, the directory manipulation code needs a minimal amount
760 * of update.
762 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
764 struct ocfs2_dir_block_trailer {
765 /*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
767 __le16 db_compat_rec_len; /* Backwards compatible with
768 * ocfs2_dir_entry. */
769 __u8 db_compat_name_len; /* Always zero. Was name_len */
770 __u8 db_reserved0;
771 __le16 db_reserved1;
772 __le16 db_free_rec_len; /* Size of largest empty hole
773 * in this block. (unused) */
774 /*10*/ __u8 db_signature[8]; /* Signature for verification */
775 __le64 db_reserved2;
776 __le64 db_free_next; /* Next block in list (unused) */
777 /*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
778 __le64 db_parent_dinode; /* dinode which owns me, in
779 blocks */
780 /*30*/ struct ocfs2_block_check db_check; /* Error checking */
781 /*40*/
785 * On disk allocator group structure for OCFS2
787 struct ocfs2_group_desc
789 /*00*/ __u8 bg_signature[8]; /* Signature for validation */
790 __le16 bg_size; /* Size of included bitmap in
791 bytes. */
792 __le16 bg_bits; /* Bits represented by this
793 group. */
794 __le16 bg_free_bits_count; /* Free bits count */
795 __le16 bg_chain; /* What chain I am in. */
796 /*10*/ __le32 bg_generation;
797 __le32 bg_reserved1;
798 __le64 bg_next_group; /* Next group in my list, in
799 blocks */
800 /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
801 blocks */
802 __le64 bg_blkno; /* Offset on disk, in blocks */
803 /*30*/ struct ocfs2_block_check bg_check; /* Error checking */
804 __le64 bg_reserved2;
805 /*40*/ __u8 bg_bitmap[0];
809 * On disk extended attribute structure for OCFS2.
813 * ocfs2_xattr_entry indicates one extend attribute.
815 * Note that it can be stored in inode, one block or one xattr bucket.
817 struct ocfs2_xattr_entry {
818 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
819 __le16 xe_name_offset; /* byte offset from the 1st entry in the
820 local xattr storage(inode, xattr block or
821 xattr bucket). */
822 __u8 xe_name_len; /* xattr name len, does't include prefix. */
823 __u8 xe_type; /* the low 7 bits indicate the name prefix
824 * type and the highest bit indicates whether
825 * the EA is stored in the local storage. */
826 __le64 xe_value_size; /* real xattr value length. */
830 * On disk structure for xattr header.
832 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
833 * the local xattr storage.
835 struct ocfs2_xattr_header {
836 __le16 xh_count; /* contains the count of how
837 many records are in the
838 local xattr storage. */
839 __le16 xh_free_start; /* current offset for storing
840 xattr. */
841 __le16 xh_name_value_len; /* total length of name/value
842 length in this bucket. */
843 __le16 xh_num_buckets; /* Number of xattr buckets
844 in this extent record,
845 only valid in the first
846 bucket. */
847 struct ocfs2_block_check xh_check; /* Error checking
848 (Note, this is only
849 used for xattr
850 buckets. A block uses
851 xb_check and sets
852 this field to zero.) */
853 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
857 * On disk structure for xattr value root.
859 * When an xattr's value is large enough, it is stored in an external
860 * b-tree like file data. The xattr value root points to this structure.
862 struct ocfs2_xattr_value_root {
863 /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
864 __le32 xr_reserved0;
865 __le64 xr_last_eb_blk; /* Pointer to last extent block */
866 /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
870 * On disk structure for xattr tree root.
872 * It is used when there are too many extended attributes for one file. These
873 * attributes will be organized and stored in an indexed-btree.
875 struct ocfs2_xattr_tree_root {
876 /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
877 __le32 xt_reserved0;
878 __le64 xt_last_eb_blk; /* Pointer to last extent block */
879 /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
882 #define OCFS2_XATTR_INDEXED 0x1
883 #define OCFS2_HASH_SHIFT 5
884 #define OCFS2_XATTR_ROUND 3
885 #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
886 ~(OCFS2_XATTR_ROUND))
888 #define OCFS2_XATTR_BUCKET_SIZE 4096
889 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
890 / OCFS2_MIN_BLOCKSIZE)
893 * On disk structure for xattr block.
895 struct ocfs2_xattr_block {
896 /*00*/ __u8 xb_signature[8]; /* Signature for verification */
897 __le16 xb_suballoc_slot; /* Slot suballocator this
898 block belongs to. */
899 __le16 xb_suballoc_bit; /* Bit offset in suballocator
900 block group */
901 __le32 xb_fs_generation; /* Must match super block */
902 /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
903 struct ocfs2_block_check xb_check; /* Error checking */
904 /*20*/ __le16 xb_flags; /* Indicates whether this block contains
905 real xattr or a xattr tree. */
906 __le16 xb_reserved0;
907 __le32 xb_reserved1;
908 __le64 xb_reserved2;
909 /*30*/ union {
910 struct ocfs2_xattr_header xb_header; /* xattr header if this
911 block contains xattr */
912 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
913 block cotains xattr
914 tree. */
915 } xb_attrs;
918 #define OCFS2_XATTR_ENTRY_LOCAL 0x80
919 #define OCFS2_XATTR_TYPE_MASK 0x7F
920 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
921 int local)
923 if (local)
924 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
925 else
926 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
929 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
931 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
934 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
936 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
939 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
941 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
945 * On disk structures for global quota file
948 /* Magic numbers and known versions for global quota files */
949 #define OCFS2_GLOBAL_QMAGICS {\
950 0x0cf52470, /* USRQUOTA */ \
951 0x0cf52471 /* GRPQUOTA */ \
954 #define OCFS2_GLOBAL_QVERSIONS {\
955 0, \
956 0, \
960 /* Each block of each quota file has a certain fixed number of bytes reserved
961 * for OCFS2 internal use at its end. OCFS2 can use it for things like
962 * checksums, etc. */
963 #define OCFS2_QBLK_RESERVED_SPACE 8
965 /* Generic header of all quota files */
966 struct ocfs2_disk_dqheader {
967 __le32 dqh_magic; /* Magic number identifying file */
968 __le32 dqh_version; /* Quota format version */
971 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
973 /* Information header of global quota file (immediately follows the generic
974 * header) */
975 struct ocfs2_global_disk_dqinfo {
976 /*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
977 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
978 __le32 dqi_syncms; /* Time after which we sync local changes to
979 * global quota file */
980 __le32 dqi_blocks; /* Number of blocks in quota file */
981 /*10*/ __le32 dqi_free_blk; /* First free block in quota file */
982 __le32 dqi_free_entry; /* First block with free dquot entry in quota
983 * file */
986 /* Structure with global user / group information. We reserve some space
987 * for future use. */
988 struct ocfs2_global_disk_dqblk {
989 /*00*/ __le32 dqb_id; /* ID the structure belongs to */
990 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
991 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
992 /*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
993 __le64 dqb_curinodes; /* current # allocated inodes */
994 /*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
995 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
996 /*30*/ __le64 dqb_curspace; /* current space occupied */
997 __le64 dqb_btime; /* time limit for excessive disk use */
998 /*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
999 __le64 dqb_pad1;
1000 /*50*/ __le64 dqb_pad2;
1004 * On-disk structures for local quota file
1007 /* Magic numbers and known versions for local quota files */
1008 #define OCFS2_LOCAL_QMAGICS {\
1009 0x0cf524c0, /* USRQUOTA */ \
1010 0x0cf524c1 /* GRPQUOTA */ \
1013 #define OCFS2_LOCAL_QVERSIONS {\
1014 0, \
1015 0, \
1018 /* Quota flags in dqinfo header */
1019 #define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1020 * quota has been cleanly turned off) */
1022 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1024 /* Information header of local quota file (immediately follows the generic
1025 * header) */
1026 struct ocfs2_local_disk_dqinfo {
1027 __le32 dqi_flags; /* Flags for quota file */
1028 __le32 dqi_chunks; /* Number of chunks of quota structures
1029 * with a bitmap */
1030 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1033 /* Header of one chunk of a quota file */
1034 struct ocfs2_local_disk_chunk {
1035 __le32 dqc_free; /* Number of free entries in the bitmap */
1036 u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1037 * chunk of quota file */
1040 /* One entry in local quota file */
1041 struct ocfs2_local_disk_dqblk {
1042 /*00*/ __le64 dqb_id; /* id this quota applies to */
1043 __le64 dqb_spacemod; /* Change in the amount of used space */
1044 /*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1049 * The quota trailer lives at the end of each quota block.
1052 struct ocfs2_disk_dqtrailer {
1053 /*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1054 /*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1057 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1058 void *buf)
1060 char *ptr = buf;
1061 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1063 return (struct ocfs2_disk_dqtrailer *)ptr;
1066 #ifdef __KERNEL__
1067 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1069 return sb->s_blocksize -
1070 offsetof(struct ocfs2_dinode, id2.i_symlink);
1073 static inline int ocfs2_max_inline_data(struct super_block *sb)
1075 return sb->s_blocksize -
1076 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1079 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1080 struct ocfs2_dinode *di)
1082 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1084 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1085 return sb->s_blocksize -
1086 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1087 xattrsize;
1088 else
1089 return sb->s_blocksize -
1090 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1093 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1095 int size;
1097 size = sb->s_blocksize -
1098 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1100 return size / sizeof(struct ocfs2_extent_rec);
1103 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1104 struct super_block *sb,
1105 struct ocfs2_dinode *di)
1107 int size;
1108 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1110 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1111 size = sb->s_blocksize -
1112 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1113 xattrsize;
1114 else
1115 size = sb->s_blocksize -
1116 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1118 return size / sizeof(struct ocfs2_extent_rec);
1121 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1123 int size;
1125 size = sb->s_blocksize -
1126 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1128 return size / sizeof(struct ocfs2_chain_rec);
1131 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1133 int size;
1135 size = sb->s_blocksize -
1136 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1138 return size / sizeof(struct ocfs2_extent_rec);
1141 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1143 u16 size;
1145 size = sb->s_blocksize -
1146 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1148 return size;
1151 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
1153 int size;
1155 size = sb->s_blocksize -
1156 offsetof(struct ocfs2_group_desc, bg_bitmap);
1158 return size;
1161 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1163 int size;
1165 size = sb->s_blocksize -
1166 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1168 return size / sizeof(struct ocfs2_truncate_rec);
1171 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1173 u64 offset = OCFS2_BACKUP_SB_START;
1175 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1176 offset <<= (2 * index);
1177 offset >>= sb->s_blocksize_bits;
1178 return offset;
1181 return 0;
1185 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1187 int size;
1189 size = sb->s_blocksize -
1190 offsetof(struct ocfs2_xattr_block,
1191 xb_attrs.xb_root.xt_list.l_recs);
1193 return size / sizeof(struct ocfs2_extent_rec);
1195 #else
1196 static inline int ocfs2_fast_symlink_chars(int blocksize)
1198 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1201 static inline int ocfs2_max_inline_data(int blocksize)
1203 return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1206 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1208 int size;
1210 size = blocksize -
1211 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1213 return size / sizeof(struct ocfs2_extent_rec);
1216 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1218 int size;
1220 size = blocksize -
1221 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1223 return size / sizeof(struct ocfs2_chain_rec);
1226 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1228 int size;
1230 size = blocksize -
1231 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1233 return size / sizeof(struct ocfs2_extent_rec);
1236 static inline int ocfs2_local_alloc_size(int blocksize)
1238 int size;
1240 size = blocksize -
1241 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1243 return size;
1246 static inline int ocfs2_group_bitmap_size(int blocksize)
1248 int size;
1250 size = blocksize -
1251 offsetof(struct ocfs2_group_desc, bg_bitmap);
1253 return size;
1256 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1258 int size;
1260 size = blocksize -
1261 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1263 return size / sizeof(struct ocfs2_truncate_rec);
1266 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1268 uint64_t offset = OCFS2_BACKUP_SB_START;
1270 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1271 offset <<= (2 * index);
1272 offset /= blocksize;
1273 return offset;
1276 return 0;
1279 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1281 int size;
1283 size = blocksize -
1284 offsetof(struct ocfs2_xattr_block,
1285 xb_attrs.xb_root.xt_list.l_recs);
1287 return size / sizeof(struct ocfs2_extent_rec);
1289 #endif /* __KERNEL__ */
1292 static inline int ocfs2_system_inode_is_global(int type)
1294 return ((type >= 0) &&
1295 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1298 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1299 int type, int slot)
1301 int chars;
1304 * Global system inodes can only have one copy. Everything
1305 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1306 * list has a copy per slot.
1308 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1309 chars = snprintf(buf, len, "%s",
1310 ocfs2_system_inodes[type].si_name);
1311 else
1312 chars = snprintf(buf, len,
1313 ocfs2_system_inodes[type].si_name,
1314 slot);
1316 return chars;
1319 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1320 umode_t mode)
1322 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1325 #endif /* _OCFS2_FS_H */