Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ocfs2_fs.h
0004  *
0005  * On-disk structures for OCFS2.
0006  *
0007  * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
0008  */
0009 
0010 #ifndef _OCFS2_FS_H
0011 #define _OCFS2_FS_H
0012 
0013 #include <linux/magic.h>
0014 
0015 /* Version */
0016 #define OCFS2_MAJOR_REV_LEVEL       0
0017 #define OCFS2_MINOR_REV_LEVEL           90
0018 
0019 /*
0020  * An OCFS2 volume starts this way:
0021  * Sector 0: Valid ocfs1_vol_disk_hdr that cleanly fails to mount OCFS.
0022  * Sector 1: Valid ocfs1_vol_label that cleanly fails to mount OCFS.
0023  * Block OCFS2_SUPER_BLOCK_BLKNO: OCFS2 superblock.
0024  *
0025  * All other structures are found from the superblock information.
0026  *
0027  * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors.  eg, for a
0028  * blocksize of 2K, it is 4096 bytes into disk.
0029  */
0030 #define OCFS2_SUPER_BLOCK_BLKNO     2
0031 
0032 /*
0033  * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could
0034  * grow if needed.
0035  */
0036 #define OCFS2_MIN_CLUSTERSIZE       4096
0037 #define OCFS2_MAX_CLUSTERSIZE       1048576
0038 
0039 /*
0040  * Blocks cannot be bigger than clusters, so the maximum blocksize is the
0041  * minimum cluster size.
0042  */
0043 #define OCFS2_MIN_BLOCKSIZE     512
0044 #define OCFS2_MAX_BLOCKSIZE     OCFS2_MIN_CLUSTERSIZE
0045 
0046 /* Object signatures */
0047 #define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
0048 #define OCFS2_INODE_SIGNATURE       "INODE01"
0049 #define OCFS2_EXTENT_BLOCK_SIGNATURE    "EXBLK01"
0050 #define OCFS2_GROUP_DESC_SIGNATURE      "GROUP01"
0051 #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
0052 #define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
0053 #define OCFS2_DX_ROOT_SIGNATURE     "DXDIR01"
0054 #define OCFS2_DX_LEAF_SIGNATURE     "DXLEAF1"
0055 #define OCFS2_REFCOUNT_BLOCK_SIGNATURE  "REFCNT1"
0056 
0057 /* Compatibility flags */
0058 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask)           \
0059     ( OCFS2_SB(sb)->s_feature_compat & (mask) )
0060 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask)            \
0061     ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
0062 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask)         \
0063     ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
0064 #define OCFS2_SET_COMPAT_FEATURE(sb,mask)           \
0065     OCFS2_SB(sb)->s_feature_compat |= (mask)
0066 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask)            \
0067     OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
0068 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask)         \
0069     OCFS2_SB(sb)->s_feature_incompat |= (mask)
0070 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask)         \
0071     OCFS2_SB(sb)->s_feature_compat &= ~(mask)
0072 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask)          \
0073     OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
0074 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask)           \
0075     OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
0076 
0077 #define OCFS2_FEATURE_COMPAT_SUPP   (OCFS2_FEATURE_COMPAT_BACKUP_SB \
0078                      | OCFS2_FEATURE_COMPAT_JBD2_SB)
0079 #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
0080                      | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
0081                      | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
0082                      | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
0083                      | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
0084                      | OCFS2_FEATURE_INCOMPAT_XATTR \
0085                      | OCFS2_FEATURE_INCOMPAT_META_ECC \
0086                      | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
0087                      | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
0088                      | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG  \
0089                      | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO \
0090                      | OCFS2_FEATURE_INCOMPAT_APPEND_DIO)
0091 #define OCFS2_FEATURE_RO_COMPAT_SUPP    (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
0092                      | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
0093                      | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
0094 
0095 /*
0096  * Heartbeat-only devices are missing journals and other files.  The
0097  * filesystem driver can't load them, but the library can.  Never put
0098  * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
0099  */
0100 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV    0x0002
0101 
0102 /*
0103  * tunefs sets this incompat flag before starting the resize and clears it
0104  * at the end. This flag protects users from inadvertently mounting the fs
0105  * after an aborted run without fsck-ing.
0106  */
0107 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG    0x0004
0108 
0109 /* Used to denote a non-clustered volume */
0110 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT  0x0008
0111 
0112 /* Support for sparse allocation in b-trees */
0113 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
0114 
0115 /*
0116  * Tunefs sets this incompat flag before starting an operation which
0117  * would require cleanup on abort. This is done to protect users from
0118  * inadvertently mounting the fs after an aborted run without
0119  * fsck-ing.
0120  *
0121  * s_tunefs_flags on the super block describes precisely which
0122  * operations were in progress.
0123  */
0124 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG    0x0020
0125 
0126 /* Support for data packed into inode blocks */
0127 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA  0x0040
0128 
0129 /*
0130  * Support for alternate, userspace cluster stacks.  If set, the superblock
0131  * field s_cluster_info contains a tag for the alternate stack in use as
0132  * well as the name of the cluster being joined.
0133  * mount.ocfs2 must pass in a matching stack name.
0134  *
0135  * If not set, the classic stack will be used.  This is compatbile with
0136  * all older versions.
0137  */
0138 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK  0x0080
0139 
0140 /* Support for the extended slot map */
0141 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
0142 
0143 /* Support for extended attributes */
0144 #define OCFS2_FEATURE_INCOMPAT_XATTR        0x0200
0145 
0146 /* Support for indexed directores */
0147 #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
0148 
0149 /* Metadata checksum and error correction */
0150 #define OCFS2_FEATURE_INCOMPAT_META_ECC     0x0800
0151 
0152 /* Refcount tree support */
0153 #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE    0x1000
0154 
0155 /* Discontiguous block groups */
0156 #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
0157 
0158 /*
0159  * Incompat bit to indicate useable clusterinfo with stackflags for all
0160  * cluster stacks (userspace adnd o2cb). If this bit is set,
0161  * INCOMPAT_USERSPACE_STACK becomes superfluous and thus should not be set.
0162  */
0163 #define OCFS2_FEATURE_INCOMPAT_CLUSTERINFO  0x4000
0164 
0165 /*
0166  * Append Direct IO support
0167  */
0168 #define OCFS2_FEATURE_INCOMPAT_APPEND_DIO   0x8000
0169 
0170 /*
0171  * backup superblock flag is used to indicate that this volume
0172  * has backup superblocks.
0173  */
0174 #define OCFS2_FEATURE_COMPAT_BACKUP_SB      0x0001
0175 
0176 /*
0177  * The filesystem will correctly handle journal feature bits.
0178  */
0179 #define OCFS2_FEATURE_COMPAT_JBD2_SB        0x0002
0180 
0181 /*
0182  * Unwritten extents support.
0183  */
0184 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN   0x0001
0185 
0186 /*
0187  * Maintain quota information for this filesystem
0188  */
0189 #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA    0x0002
0190 #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA    0x0004
0191 
0192 
0193 /* The byte offset of the first backup block will be 1G.
0194  * The following will be 4G, 16G, 64G, 256G and 1T.
0195  */
0196 #define OCFS2_BACKUP_SB_START           1 << 30
0197 
0198 /* the max backup superblock nums */
0199 #define OCFS2_MAX_BACKUP_SUPERBLOCKS    6
0200 
0201 /*
0202  * Flags on ocfs2_super_block.s_tunefs_flags
0203  */
0204 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT     0x0001  /* Removing slots */
0205 
0206 /*
0207  * Flags on ocfs2_dinode.i_flags
0208  */
0209 #define OCFS2_VALID_FL      (0x00000001)    /* Inode is valid */
0210 #define OCFS2_UNUSED2_FL    (0x00000002)
0211 #define OCFS2_ORPHANED_FL   (0x00000004)    /* On the orphan list */
0212 #define OCFS2_UNUSED3_FL    (0x00000008)
0213 /* System inode flags */
0214 #define OCFS2_SYSTEM_FL     (0x00000010)    /* System inode */
0215 #define OCFS2_SUPER_BLOCK_FL    (0x00000020)    /* Super block */
0216 #define OCFS2_LOCAL_ALLOC_FL    (0x00000040)    /* Slot local alloc bitmap */
0217 #define OCFS2_BITMAP_FL     (0x00000080)    /* Allocation bitmap */
0218 #define OCFS2_JOURNAL_FL    (0x00000100)    /* Slot local journal */
0219 #define OCFS2_HEARTBEAT_FL  (0x00000200)    /* Heartbeat area */
0220 #define OCFS2_CHAIN_FL      (0x00000400)    /* Chain allocator */
0221 #define OCFS2_DEALLOC_FL    (0x00000800)    /* Truncate log */
0222 #define OCFS2_QUOTA_FL      (0x00001000)    /* Quota file */
0223 #define OCFS2_DIO_ORPHANED_FL   (0X00002000)    /* On the orphan list especially
0224                          * for dio */
0225 
0226 /*
0227  * Flags on ocfs2_dinode.i_dyn_features
0228  *
0229  * These can change much more often than i_flags. When adding flags,
0230  * keep in mind that i_dyn_features is only 16 bits wide.
0231  */
0232 #define OCFS2_INLINE_DATA_FL    (0x0001)    /* Data stored in inode block */
0233 #define OCFS2_HAS_XATTR_FL  (0x0002)
0234 #define OCFS2_INLINE_XATTR_FL   (0x0004)
0235 #define OCFS2_INDEXED_DIR_FL    (0x0008)
0236 #define OCFS2_HAS_REFCOUNT_FL   (0x0010)
0237 
0238 /* Inode attributes, keep in sync with EXT2 */
0239 #define OCFS2_SECRM_FL          FS_SECRM_FL /* Secure deletion */
0240 #define OCFS2_UNRM_FL           FS_UNRM_FL  /* Undelete */
0241 #define OCFS2_COMPR_FL          FS_COMPR_FL /* Compress file */
0242 #define OCFS2_SYNC_FL           FS_SYNC_FL  /* Synchronous updates */
0243 #define OCFS2_IMMUTABLE_FL      FS_IMMUTABLE_FL /* Immutable file */
0244 #define OCFS2_APPEND_FL         FS_APPEND_FL    /* writes to file may only append */
0245 #define OCFS2_NODUMP_FL         FS_NODUMP_FL    /* do not dump file */
0246 #define OCFS2_NOATIME_FL        FS_NOATIME_FL   /* do not update atime */
0247 /* Reserved for compression usage... */
0248 #define OCFS2_DIRTY_FL          FS_DIRTY_FL
0249 #define OCFS2_COMPRBLK_FL       FS_COMPRBLK_FL  /* One or more compressed clusters */
0250 #define OCFS2_NOCOMP_FL         FS_NOCOMP_FL    /* Don't compress */
0251 #define OCFS2_ECOMPR_FL         FS_ECOMPR_FL    /* Compression error */
0252 /* End compression flags --- maybe not all used */
0253 #define OCFS2_BTREE_FL          FS_BTREE_FL /* btree format dir */
0254 #define OCFS2_INDEX_FL          FS_INDEX_FL /* hash-indexed directory */
0255 #define OCFS2_IMAGIC_FL         FS_IMAGIC_FL    /* AFS directory */
0256 #define OCFS2_JOURNAL_DATA_FL       FS_JOURNAL_DATA_FL /* Reserved for ext3 */
0257 #define OCFS2_NOTAIL_FL         FS_NOTAIL_FL    /* file tail should not be merged */
0258 #define OCFS2_DIRSYNC_FL        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
0259 #define OCFS2_TOPDIR_FL         FS_TOPDIR_FL    /* Top of directory hierarchies*/
0260 #define OCFS2_RESERVED_FL       FS_RESERVED_FL  /* reserved for ext2 lib */
0261 
0262 #define OCFS2_FL_VISIBLE        FS_FL_USER_VISIBLE  /* User visible flags */
0263 #define OCFS2_FL_MODIFIABLE     FS_FL_USER_MODIFIABLE   /* User modifiable flags */
0264 
0265 /*
0266  * Extent record flags (e_node.leaf.flags)
0267  */
0268 #define OCFS2_EXT_UNWRITTEN     (0x01)  /* Extent is allocated but
0269                          * unwritten */
0270 #define OCFS2_EXT_REFCOUNTED        (0x02)  /* Extent is reference
0271                          * counted in an associated
0272                          * refcount tree */
0273 
0274 /*
0275  * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
0276  */
0277 #define OCFS2_JOURNAL_DIRTY_FL  (0x00000001)    /* Journal needs recovery */
0278 
0279 /*
0280  * superblock s_state flags
0281  */
0282 #define OCFS2_ERROR_FS      (0x00000001)    /* FS saw errors */
0283 
0284 /* Limit of space in ocfs2_dir_entry */
0285 #define OCFS2_MAX_FILENAME_LEN      255
0286 
0287 /* Maximum slots on an ocfs2 file system */
0288 #define OCFS2_MAX_SLOTS         255
0289 
0290 /* Slot map indicator for an empty slot */
0291 #define OCFS2_INVALID_SLOT      ((u16)-1)
0292 
0293 #define OCFS2_VOL_UUID_LEN      16
0294 #define OCFS2_MAX_VOL_LABEL_LEN     64
0295 
0296 /* The cluster stack fields */
0297 #define OCFS2_STACK_LABEL_LEN       4
0298 #define OCFS2_CLUSTER_NAME_LEN      16
0299 
0300 /* Classic (historically speaking) cluster stack */
0301 #define OCFS2_CLASSIC_CLUSTER_STACK "o2cb"
0302 
0303 /* Journal limits (in bytes) */
0304 #define OCFS2_MIN_JOURNAL_SIZE      (4 * 1024 * 1024)
0305 
0306 /*
0307  * Inline extended attribute size (in bytes)
0308  * The value chosen should be aligned to 16 byte boundaries.
0309  */
0310 #define OCFS2_MIN_XATTR_INLINE_SIZE     256
0311 
0312 /*
0313  * Cluster info flags (ocfs2_cluster_info.ci_stackflags)
0314  */
0315 #define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT (0x01)
0316 
0317 struct ocfs2_system_inode_info {
0318     char    *si_name;
0319     int si_iflags;
0320     int si_mode;
0321 };
0322 
0323 /* System file index */
0324 enum {
0325     BAD_BLOCK_SYSTEM_INODE = 0,
0326     GLOBAL_INODE_ALLOC_SYSTEM_INODE,
0327 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE GLOBAL_INODE_ALLOC_SYSTEM_INODE
0328     SLOT_MAP_SYSTEM_INODE,
0329     HEARTBEAT_SYSTEM_INODE,
0330     GLOBAL_BITMAP_SYSTEM_INODE,
0331     USER_QUOTA_SYSTEM_INODE,
0332     GROUP_QUOTA_SYSTEM_INODE,
0333 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
0334 #define OCFS2_FIRST_LOCAL_SYSTEM_INODE ORPHAN_DIR_SYSTEM_INODE
0335     ORPHAN_DIR_SYSTEM_INODE,
0336     EXTENT_ALLOC_SYSTEM_INODE,
0337     INODE_ALLOC_SYSTEM_INODE,
0338     JOURNAL_SYSTEM_INODE,
0339     LOCAL_ALLOC_SYSTEM_INODE,
0340     TRUNCATE_LOG_SYSTEM_INODE,
0341     LOCAL_USER_QUOTA_SYSTEM_INODE,
0342     LOCAL_GROUP_QUOTA_SYSTEM_INODE,
0343 #define OCFS2_LAST_LOCAL_SYSTEM_INODE LOCAL_GROUP_QUOTA_SYSTEM_INODE
0344     NUM_SYSTEM_INODES
0345 };
0346 #define NUM_GLOBAL_SYSTEM_INODES OCFS2_FIRST_LOCAL_SYSTEM_INODE
0347 #define NUM_LOCAL_SYSTEM_INODES \
0348         (NUM_SYSTEM_INODES - OCFS2_FIRST_LOCAL_SYSTEM_INODE)
0349 
0350 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
0351     /* Global system inodes (single copy) */
0352     /* The first two are only used from userspace mfks/tunefs */
0353     [BAD_BLOCK_SYSTEM_INODE]        = { "bad_blocks", 0, S_IFREG | 0644 },
0354     [GLOBAL_INODE_ALLOC_SYSTEM_INODE]   = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
0355 
0356     /* These are used by the running filesystem */
0357     [SLOT_MAP_SYSTEM_INODE]         = { "slot_map", 0, S_IFREG | 0644 },
0358     [HEARTBEAT_SYSTEM_INODE]        = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
0359     [GLOBAL_BITMAP_SYSTEM_INODE]        = { "global_bitmap", 0, S_IFREG | 0644 },
0360     [USER_QUOTA_SYSTEM_INODE]       = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
0361     [GROUP_QUOTA_SYSTEM_INODE]      = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
0362 
0363     /* Slot-specific system inodes (one copy per slot) */
0364     [ORPHAN_DIR_SYSTEM_INODE]       = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
0365     [EXTENT_ALLOC_SYSTEM_INODE]     = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
0366     [INODE_ALLOC_SYSTEM_INODE]      = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
0367     [JOURNAL_SYSTEM_INODE]          = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
0368     [LOCAL_ALLOC_SYSTEM_INODE]      = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
0369     [TRUNCATE_LOG_SYSTEM_INODE]     = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
0370     [LOCAL_USER_QUOTA_SYSTEM_INODE]     = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
0371     [LOCAL_GROUP_QUOTA_SYSTEM_INODE]    = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
0372 };
0373 
0374 /* Parameter passed from mount.ocfs2 to module */
0375 #define OCFS2_HB_NONE           "heartbeat=none"
0376 #define OCFS2_HB_LOCAL          "heartbeat=local"
0377 #define OCFS2_HB_GLOBAL         "heartbeat=global"
0378 
0379 /*
0380  * OCFS2_DIR_PAD defines the directory entries boundaries
0381  *
0382  * NOTE: It must be a multiple of 4
0383  */
0384 #define OCFS2_DIR_PAD           4
0385 #define OCFS2_DIR_ROUND         (OCFS2_DIR_PAD - 1)
0386 #define OCFS2_DIR_MEMBER_LEN        offsetof(struct ocfs2_dir_entry, name)
0387 #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
0388                                           OCFS2_DIR_ROUND) & \
0389                      ~OCFS2_DIR_ROUND)
0390 #define OCFS2_DIR_MIN_REC_LEN   OCFS2_DIR_REC_LEN(1)
0391 
0392 #define OCFS2_LINK_MAX      32000
0393 #define OCFS2_DX_LINK_MAX   ((1U << 31) - 1U)
0394 #define OCFS2_LINKS_HI_SHIFT    16
0395 #define OCFS2_DX_ENTRIES_MAX    (0xffffffffU)
0396 
0397 
0398 /*
0399  * Convenience casts
0400  */
0401 #define OCFS2_RAW_SB(dinode)        (&((dinode)->id2.i_super))
0402 
0403 /*
0404  * Block checking structure.  This is used in metadata to validate the
0405  * contents.  If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
0406  * zeros.
0407  */
0408 struct ocfs2_block_check {
0409 /*00*/  __le32 bc_crc32e;   /* 802.3 Ethernet II CRC32 */
0410     __le16 bc_ecc;      /* Single-error-correction parity vector.
0411                    This is a simple Hamming code dependent
0412                    on the blocksize.  OCFS2's maximum
0413                    blocksize, 4K, requires 16 parity bits,
0414                    so we fit in __le16. */
0415     __le16 bc_reserved1;
0416 /*08*/
0417 };
0418 
0419 /*
0420  * On disk extent record for OCFS2
0421  * It describes a range of clusters on disk.
0422  *
0423  * Length fields are divided into interior and leaf node versions.
0424  * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
0425  */
0426 struct ocfs2_extent_rec {
0427 /*00*/  __le32 e_cpos;      /* Offset into the file, in clusters */
0428     union {
0429         __le32 e_int_clusters; /* Clusters covered by all children */
0430         struct {
0431             __le16 e_leaf_clusters; /* Clusters covered by this
0432                            extent */
0433             __u8 e_reserved1;
0434             __u8 e_flags; /* Extent flags */
0435         };
0436     };
0437     __le64 e_blkno;     /* Physical disk offset, in blocks */
0438 /*10*/
0439 };
0440 
0441 struct ocfs2_chain_rec {
0442     __le32 c_free;  /* Number of free bits in this chain. */
0443     __le32 c_total; /* Number of total bits in this chain */
0444     __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
0445 };
0446 
0447 struct ocfs2_truncate_rec {
0448     __le32 t_start;     /* 1st cluster in this log */
0449     __le32 t_clusters;  /* Number of total clusters covered */
0450 };
0451 
0452 /*
0453  * On disk extent list for OCFS2 (node in the tree).  Note that this
0454  * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
0455  * offsets are relative to ocfs2_dinode.id2.i_list or
0456  * ocfs2_extent_block.h_list, respectively.
0457  */
0458 struct ocfs2_extent_list {
0459 /*00*/  __le16 l_tree_depth;        /* Extent tree depth from this
0460                        point.  0 means data extents
0461                        hang directly off this
0462                        header (a leaf)
0463                        NOTE: The high 8 bits cannot be
0464                        used - tree_depth is never that big.
0465                     */
0466     __le16 l_count;         /* Number of extent records */
0467     __le16 l_next_free_rec;     /* Next unused extent slot */
0468     __le16 l_reserved1;
0469     __le64 l_reserved2;     /* Pad to
0470                        sizeof(ocfs2_extent_rec) */
0471 /*10*/  struct ocfs2_extent_rec l_recs[];   /* Extent records */
0472 };
0473 
0474 /*
0475  * On disk allocation chain list for OCFS2.  Note that this is
0476  * contained inside ocfs2_dinode, so the offsets are relative to
0477  * ocfs2_dinode.id2.i_chain.
0478  */
0479 struct ocfs2_chain_list {
0480 /*00*/  __le16 cl_cpg;          /* Clusters per Block Group */
0481     __le16 cl_bpc;          /* Bits per cluster */
0482     __le16 cl_count;        /* Total chains in this list */
0483     __le16 cl_next_free_rec;    /* Next unused chain slot */
0484     __le64 cl_reserved1;
0485 /*10*/  struct ocfs2_chain_rec cl_recs[];   /* Chain records */
0486 };
0487 
0488 /*
0489  * On disk deallocation log for OCFS2.  Note that this is
0490  * contained inside ocfs2_dinode, so the offsets are relative to
0491  * ocfs2_dinode.id2.i_dealloc.
0492  */
0493 struct ocfs2_truncate_log {
0494 /*00*/  __le16 tl_count;        /* Total records in this log */
0495     __le16 tl_used;         /* Number of records in use */
0496     __le32 tl_reserved1;
0497 /*08*/  struct ocfs2_truncate_rec tl_recs[];    /* Truncate records */
0498 };
0499 
0500 /*
0501  * On disk extent block (indirect block) for OCFS2
0502  */
0503 struct ocfs2_extent_block
0504 {
0505 /*00*/  __u8 h_signature[8];        /* Signature for verification */
0506     struct ocfs2_block_check h_check;   /* Error checking */
0507 /*10*/  __le16 h_suballoc_slot;     /* Slot suballocator this
0508                        extent_header belongs to */
0509     __le16 h_suballoc_bit;      /* Bit offset in suballocator
0510                        block group */
0511     __le32 h_fs_generation;     /* Must match super block */
0512     __le64 h_blkno;         /* Offset on disk, in blocks */
0513 /*20*/  __le64 h_suballoc_loc;      /* Suballocator block group this
0514                        eb belongs to.  Only valid
0515                        if allocated from a
0516                        discontiguous block group */
0517     __le64 h_next_leaf_blk;     /* Offset on disk, in blocks,
0518                        of next leaf header pointing
0519                        to data */
0520 /*30*/  struct ocfs2_extent_list h_list;    /* Extent record list */
0521 /* Actual on-disk size is one block */
0522 };
0523 
0524 /*
0525  * On disk slot map for OCFS2.  This defines the contents of the "slot_map"
0526  * system file.  A slot is valid if it contains a node number >= 0.  The
0527  * value -1 (0xFFFF) is OCFS2_INVALID_SLOT.  This marks a slot empty.
0528  */
0529 struct ocfs2_slot_map {
0530 /*00*/  __le16 sm_slots[0];
0531 /*
0532  * Actual on-disk size is one block.  OCFS2_MAX_SLOTS is 255,
0533  * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
0534  */
0535 };
0536 
0537 struct ocfs2_extended_slot {
0538 /*00*/  __u8    es_valid;
0539     __u8    es_reserved1[3];
0540     __le32  es_node_num;
0541 /*08*/
0542 };
0543 
0544 /*
0545  * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
0546  * is set.  It separates out the valid marker from the node number, and
0547  * has room to grow.  Unlike the old slot map, this format is defined by
0548  * i_size.
0549  */
0550 struct ocfs2_slot_map_extended {
0551 /*00*/  struct ocfs2_extended_slot se_slots[0];
0552 /*
0553  * Actual size is i_size of the slot_map system file.  It should
0554  * match s_max_slots * sizeof(struct ocfs2_extended_slot)
0555  */
0556 };
0557 
0558 /*
0559  * ci_stackflags is only valid if the incompat bit
0560  * OCFS2_FEATURE_INCOMPAT_CLUSTERINFO is set.
0561  */
0562 struct ocfs2_cluster_info {
0563 /*00*/  __u8   ci_stack[OCFS2_STACK_LABEL_LEN];
0564     union {
0565         __le32 ci_reserved;
0566         struct {
0567             __u8 ci_stackflags;
0568             __u8 ci_reserved1;
0569             __u8 ci_reserved2;
0570             __u8 ci_reserved3;
0571         };
0572     };
0573 /*08*/  __u8   ci_cluster[OCFS2_CLUSTER_NAME_LEN];
0574 /*18*/
0575 };
0576 
0577 /*
0578  * On disk superblock for OCFS2
0579  * Note that it is contained inside an ocfs2_dinode, so all offsets
0580  * are relative to the start of ocfs2_dinode.id2.
0581  */
0582 struct ocfs2_super_block {
0583 /*00*/  __le16 s_major_rev_level;
0584     __le16 s_minor_rev_level;
0585     __le16 s_mnt_count;
0586     __le16 s_max_mnt_count;
0587     __le16 s_state;         /* File system state */
0588     __le16 s_errors;            /* Behaviour when detecting errors */
0589     __le32 s_checkinterval;     /* Max time between checks */
0590 /*10*/  __le64 s_lastcheck;     /* Time of last check */
0591     __le32 s_creator_os;        /* OS */
0592     __le32 s_feature_compat;        /* Compatible feature set */
0593 /*20*/  __le32 s_feature_incompat;  /* Incompatible feature set */
0594     __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
0595     __le64 s_root_blkno;        /* Offset, in blocks, of root directory
0596                        dinode */
0597 /*30*/  __le64 s_system_dir_blkno;  /* Offset, in blocks, of system
0598                        directory dinode */
0599     __le32 s_blocksize_bits;        /* Blocksize for this fs */
0600     __le32 s_clustersize_bits;  /* Clustersize for this fs */
0601 /*40*/  __le16 s_max_slots;     /* Max number of simultaneous mounts
0602                        before tunefs required */
0603     __le16 s_tunefs_flag;
0604     __le32 s_uuid_hash;     /* hash value of uuid */
0605     __le64 s_first_cluster_group;   /* Block offset of 1st cluster
0606                      * group header */
0607 /*50*/  __u8  s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
0608 /*90*/  __u8  s_uuid[OCFS2_VOL_UUID_LEN];   /* 128-bit uuid */
0609 /*A0*/  struct ocfs2_cluster_info s_cluster_info; /* Only valid if either
0610                              userspace or clusterinfo
0611                              INCOMPAT flag set. */
0612 /*B8*/  __le16 s_xattr_inline_size; /* extended attribute inline size
0613                        for this fs*/
0614     __le16 s_reserved0;
0615     __le32 s_dx_seed[3];        /* seed[0-2] for dx dir hash.
0616                      * s_uuid_hash serves as seed[3]. */
0617 /*C0*/  __le64 s_reserved2[15];     /* Fill out superblock */
0618 /*140*/
0619 
0620     /*
0621      * NOTE: As stated above, all offsets are relative to
0622      * ocfs2_dinode.id2, which is at 0xC0 in the inode.
0623      * 0xC0 + 0x140 = 0x200 or 512 bytes.  A superblock must fit within
0624      * our smallest blocksize, which is 512 bytes.  To ensure this,
0625      * we reserve the space in s_reserved2.  Anything past s_reserved2
0626      * will not be available on the smallest blocksize.
0627      */
0628 };
0629 
0630 /*
0631  * Local allocation bitmap for OCFS2 slots
0632  * Note that it exists inside an ocfs2_dinode, so all offsets are
0633  * relative to the start of ocfs2_dinode.id2.
0634  */
0635 struct ocfs2_local_alloc
0636 {
0637 /*00*/  __le32 la_bm_off;   /* Starting bit offset in main bitmap */
0638     __le16 la_size;     /* Size of included bitmap, in bytes */
0639     __le16 la_reserved1;
0640     __le64 la_reserved2;
0641 /*10*/  __u8   la_bitmap[];
0642 };
0643 
0644 /*
0645  * Data-in-inode header. This is only used if i_dyn_features has
0646  * OCFS2_INLINE_DATA_FL set.
0647  */
0648 struct ocfs2_inline_data
0649 {
0650 /*00*/  __le16  id_count;   /* Number of bytes that can be used
0651                  * for data, starting at id_data */
0652     __le16  id_reserved0;
0653     __le32  id_reserved1;
0654     __u8    id_data[];  /* Start of user data */
0655 };
0656 
0657 /*
0658  * On disk inode for OCFS2
0659  */
0660 struct ocfs2_dinode {
0661 /*00*/  __u8 i_signature[8];        /* Signature for validation */
0662     __le32 i_generation;        /* Generation number */
0663     __le16 i_suballoc_slot;     /* Slot suballocator this inode
0664                        belongs to */
0665     __le16 i_suballoc_bit;      /* Bit offset in suballocator
0666                        block group */
0667 /*10*/  __le16 i_links_count_hi;    /* High 16 bits of links count */
0668     __le16 i_xattr_inline_size;
0669     __le32 i_clusters;      /* Cluster count */
0670     __le32 i_uid;           /* Owner UID */
0671     __le32 i_gid;           /* Owning GID */
0672 /*20*/  __le64 i_size;          /* Size in bytes */
0673     __le16 i_mode;          /* File mode */
0674     __le16 i_links_count;       /* Links count */
0675     __le32 i_flags;         /* File flags */
0676 /*30*/  __le64 i_atime;         /* Access time */
0677     __le64 i_ctime;         /* Creation time */
0678 /*40*/  __le64 i_mtime;         /* Modification time */
0679     __le64 i_dtime;         /* Deletion time */
0680 /*50*/  __le64 i_blkno;         /* Offset on disk, in blocks */
0681     __le64 i_last_eb_blk;       /* Pointer to last extent
0682                        block */
0683 /*60*/  __le32 i_fs_generation;     /* Generation per fs-instance */
0684     __le32 i_atime_nsec;
0685     __le32 i_ctime_nsec;
0686     __le32 i_mtime_nsec;
0687 /*70*/  __le32 i_attr;
0688     __le16 i_orphaned_slot;     /* Only valid when OCFS2_ORPHANED_FL
0689                        was set in i_flags */
0690     __le16 i_dyn_features;
0691     __le64 i_xattr_loc;
0692 /*80*/  struct ocfs2_block_check i_check;   /* Error checking */
0693 /*88*/  __le64 i_dx_root;       /* Pointer to dir index root block */
0694 /*90*/  __le64 i_refcount_loc;
0695     __le64 i_suballoc_loc;      /* Suballocator block group this
0696                        inode belongs to.  Only valid
0697                        if allocated from a
0698                        discontiguous block group */
0699 /*A0*/  __le16 i_dio_orphaned_slot; /* only used for append dio write */
0700     __le16 i_reserved1[3];
0701     __le64 i_reserved2[2];
0702 /*B8*/  union {
0703         __le64 i_pad1;      /* Generic way to refer to this
0704                        64bit union */
0705         struct {
0706             __le64 i_rdev;  /* Device number */
0707         } dev1;
0708         struct {        /* Info for bitmap system
0709                        inodes */
0710             __le32 i_used;  /* Bits (ie, clusters) used  */
0711             __le32 i_total; /* Total bits (clusters)
0712                        available */
0713         } bitmap1;
0714         struct {        /* Info for journal system
0715                        inodes */
0716             __le32 ij_flags;    /* Mounted, version, etc. */
0717             __le32 ij_recovery_generation; /* Incremented when the
0718                               journal is recovered
0719                               after an unclean
0720                               shutdown */
0721         } journal1;
0722     } id1;              /* Inode type dependent 1 */
0723 /*C0*/  union {
0724         struct ocfs2_super_block    i_super;
0725         struct ocfs2_local_alloc    i_lab;
0726         struct ocfs2_chain_list     i_chain;
0727         struct ocfs2_extent_list    i_list;
0728         struct ocfs2_truncate_log   i_dealloc;
0729         struct ocfs2_inline_data    i_data;
0730         __u8                    i_symlink[0];
0731     } id2;
0732 /* Actual on-disk size is one block */
0733 };
0734 
0735 /*
0736  * On-disk directory entry structure for OCFS2
0737  *
0738  * Packed as this structure could be accessed unaligned on 64-bit platforms
0739  */
0740 struct ocfs2_dir_entry {
0741 /*00*/  __le64   inode;                  /* Inode number */
0742     __le16   rec_len;                /* Directory entry length */
0743     __u8    name_len;               /* Name length */
0744     __u8    file_type;
0745 /*0C*/  char    name[OCFS2_MAX_FILENAME_LEN];   /* File name */
0746 /* Actual on-disk length specified by rec_len */
0747 } __attribute__ ((packed));
0748 
0749 /*
0750  * Per-block record for the unindexed directory btree. This is carefully
0751  * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
0752  * mirrored. That way, the directory manipulation code needs a minimal amount
0753  * of update.
0754  *
0755  * NOTE: Keep this structure aligned to a multiple of 4 bytes.
0756  */
0757 struct ocfs2_dir_block_trailer {
0758 /*00*/  __le64      db_compat_inode;    /* Always zero. Was inode */
0759 
0760     __le16      db_compat_rec_len;  /* Backwards compatible with
0761                          * ocfs2_dir_entry. */
0762     __u8        db_compat_name_len; /* Always zero. Was name_len */
0763     __u8        db_reserved0;
0764     __le16      db_reserved1;
0765     __le16      db_free_rec_len;    /* Size of largest empty hole
0766                          * in this block. (unused) */
0767 /*10*/  __u8        db_signature[8];    /* Signature for verification */
0768     __le64      db_reserved2;
0769 /*20*/  __le64      db_free_next;       /* Next block in list (unused) */
0770     __le64      db_blkno;       /* Offset on disk, in blocks */
0771 /*30*/  __le64      db_parent_dinode;   /* dinode which owns me, in
0772                            blocks */
0773     struct ocfs2_block_check db_check;  /* Error checking */
0774 /*40*/
0775 };
0776 
0777  /*
0778  * A directory entry in the indexed tree. We don't store the full name here,
0779  * but instead provide a pointer to the full dirent in the unindexed tree.
0780  *
0781  * We also store name_len here so as to reduce the number of leaf blocks we
0782  * need to search in case of collisions.
0783  */
0784 struct ocfs2_dx_entry {
0785     __le32      dx_major_hash;  /* Used to find logical
0786                      * cluster in index */
0787     __le32      dx_minor_hash;  /* Lower bits used to find
0788                      * block in cluster */
0789     __le64      dx_dirent_blk;  /* Physical block in unindexed
0790                      * tree holding this dirent. */
0791 };
0792 
0793 struct ocfs2_dx_entry_list {
0794     __le32      de_reserved;
0795     __le16      de_count;   /* Maximum number of entries
0796                      * possible in de_entries */
0797     __le16      de_num_used;    /* Current number of
0798                      * de_entries entries */
0799     struct  ocfs2_dx_entry      de_entries[];   /* Indexed dir entries
0800                              * in a packed array of
0801                              * length de_num_used */
0802 };
0803 
0804 #define OCFS2_DX_FLAG_INLINE    0x01
0805 
0806 /*
0807  * A directory indexing block. Each indexed directory has one of these,
0808  * pointed to by ocfs2_dinode.
0809  *
0810  * This block stores an indexed btree root, and a set of free space
0811  * start-of-list pointers.
0812  */
0813 struct ocfs2_dx_root_block {
0814     __u8        dr_signature[8];    /* Signature for verification */
0815     struct ocfs2_block_check dr_check;  /* Error checking */
0816     __le16      dr_suballoc_slot;   /* Slot suballocator this
0817                          * block belongs to. */
0818     __le16      dr_suballoc_bit;    /* Bit offset in suballocator
0819                          * block group */
0820     __le32      dr_fs_generation;   /* Must match super block */
0821     __le64      dr_blkno;       /* Offset on disk, in blocks */
0822     __le64      dr_last_eb_blk;     /* Pointer to last
0823                          * extent block */
0824     __le32      dr_clusters;        /* Clusters allocated
0825                          * to the indexed tree. */
0826     __u8        dr_flags;       /* OCFS2_DX_FLAG_* flags */
0827     __u8        dr_reserved0;
0828     __le16      dr_reserved1;
0829     __le64      dr_dir_blkno;       /* Pointer to parent inode */
0830     __le32      dr_num_entries;     /* Total number of
0831                          * names stored in
0832                          * this directory.*/
0833     __le32      dr_reserved2;
0834     __le64      dr_free_blk;        /* Pointer to head of free
0835                          * unindexed block list. */
0836     __le64      dr_suballoc_loc;    /* Suballocator block group
0837                            this root belongs to.
0838                            Only valid if allocated
0839                            from a discontiguous
0840                            block group */
0841     __le64      dr_reserved3[14];
0842     union {
0843         struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
0844                            * bits for maximum space
0845                            * efficiency. */
0846         struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
0847                             * entries. We grow out
0848                             * to extents if this
0849                             * gets too big. */
0850     };
0851 };
0852 
0853 /*
0854  * The header of a leaf block in the indexed tree.
0855  */
0856 struct ocfs2_dx_leaf {
0857     __u8        dl_signature[8];/* Signature for verification */
0858     struct ocfs2_block_check dl_check;  /* Error checking */
0859     __le64      dl_blkno;   /* Offset on disk, in blocks */
0860     __le32      dl_fs_generation;/* Must match super block */
0861     __le32      dl_reserved0;
0862     __le64      dl_reserved1;
0863     struct ocfs2_dx_entry_list  dl_list;
0864 };
0865 
0866 /*
0867  * Largest bitmap for a block (suballocator) group in bytes.  This limit
0868  * does not affect cluster groups (global allocator).  Cluster group
0869  * bitmaps run to the end of the block.
0870  */
0871 #define OCFS2_MAX_BG_BITMAP_SIZE    256
0872 
0873 /*
0874  * On disk allocator group structure for OCFS2
0875  */
0876 struct ocfs2_group_desc
0877 {
0878 /*00*/  __u8    bg_signature[8];        /* Signature for validation */
0879     __le16   bg_size;                /* Size of included bitmap in
0880                        bytes. */
0881     __le16   bg_bits;                /* Bits represented by this
0882                        group. */
0883     __le16  bg_free_bits_count;     /* Free bits count */
0884     __le16   bg_chain;               /* What chain I am in. */
0885 /*10*/  __le32   bg_generation;
0886     __le32  bg_reserved1;
0887     __le64   bg_next_group;          /* Next group in my list, in
0888                        blocks */
0889 /*20*/  __le64   bg_parent_dinode;       /* dinode which owns me, in
0890                        blocks */
0891     __le64   bg_blkno;               /* Offset on disk, in blocks */
0892 /*30*/  struct ocfs2_block_check bg_check;  /* Error checking */
0893     __le64   bg_reserved2;
0894 /*40*/  union {
0895         __u8    bg_bitmap[0];
0896         struct {
0897             /*
0898              * Block groups may be discontiguous when
0899              * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
0900              * The extents of a discontiguous block group are
0901              * stored in bg_list.  It is a flat list.
0902              * l_tree_depth must always be zero.  A
0903              * discontiguous group is signified by a non-zero
0904              * bg_list->l_next_free_rec.  Only block groups
0905              * can be discontiguous; Cluster groups cannot.
0906              * We've never made a block group with more than
0907              * 2048 blocks (256 bytes of bg_bitmap).  This
0908              * codifies that limit so that we can fit bg_list.
0909              * bg_size of a discontiguous block group will
0910              * be 256 to match bg_bitmap_filler.
0911              */
0912             __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
0913 /*140*/         struct ocfs2_extent_list bg_list;
0914         };
0915     };
0916 /* Actual on-disk size is one block */
0917 };
0918 
0919 struct ocfs2_refcount_rec {
0920 /*00*/  __le64 r_cpos;      /* Physical offset, in clusters */
0921     __le32 r_clusters;  /* Clusters covered by this extent */
0922     __le32 r_refcount;  /* Reference count of this extent */
0923 /*10*/
0924 };
0925 #define OCFS2_32BIT_POS_MASK        (0xffffffffULL)
0926 
0927 #define OCFS2_REFCOUNT_LEAF_FL          (0x00000001)
0928 #define OCFS2_REFCOUNT_TREE_FL          (0x00000002)
0929 
0930 struct ocfs2_refcount_list {
0931 /*00*/  __le16 rl_count;    /* Maximum number of entries possible
0932                    in rl_records */
0933     __le16 rl_used;     /* Current number of used records */
0934     __le32 rl_reserved2;
0935     __le64 rl_reserved1;    /* Pad to sizeof(ocfs2_refcount_record) */
0936 /*10*/  struct ocfs2_refcount_rec rl_recs[];    /* Refcount records */
0937 };
0938 
0939 
0940 struct ocfs2_refcount_block {
0941 /*00*/  __u8 rf_signature[8];       /* Signature for verification */
0942     __le16 rf_suballoc_slot;    /* Slot suballocator this block
0943                        belongs to */
0944     __le16 rf_suballoc_bit;     /* Bit offset in suballocator
0945                        block group */
0946     __le32 rf_fs_generation;    /* Must match superblock */
0947 /*10*/  __le64 rf_blkno;        /* Offset on disk, in blocks */
0948     __le64 rf_parent;       /* Parent block, only valid if
0949                        OCFS2_REFCOUNT_LEAF_FL is set in
0950                        rf_flags */
0951 /*20*/  struct ocfs2_block_check rf_check;  /* Error checking */
0952     __le64 rf_last_eb_blk;      /* Pointer to last extent block */
0953 /*30*/  __le32 rf_count;        /* Number of inodes sharing this
0954                        refcount tree */
0955     __le32 rf_flags;        /* See the flags above */
0956     __le32 rf_clusters;     /* clusters covered by refcount tree. */
0957     __le32 rf_cpos;         /* cluster offset in refcount tree.*/
0958 /*40*/  __le32 rf_generation;       /* generation number. all be the same
0959                      * for the same refcount tree. */
0960     __le32 rf_reserved0;
0961     __le64 rf_suballoc_loc;     /* Suballocator block group this
0962                        refcount block belongs to. Only
0963                        valid if allocated from a
0964                        discontiguous block group */
0965 /*50*/  __le64 rf_reserved1[6];
0966 /*80*/  union {
0967         struct ocfs2_refcount_list rf_records;  /* List of refcount
0968                               records */
0969         struct ocfs2_extent_list rf_list;   /* Extent record list,
0970                             only valid if
0971                             OCFS2_REFCOUNT_TREE_FL
0972                             is set in rf_flags */
0973     };
0974 /* Actual on-disk size is one block */
0975 };
0976 
0977 /*
0978  * On disk extended attribute structure for OCFS2.
0979  */
0980 
0981 /*
0982  * ocfs2_xattr_entry indicates one extend attribute.
0983  *
0984  * Note that it can be stored in inode, one block or one xattr bucket.
0985  */
0986 struct ocfs2_xattr_entry {
0987     __le32  xe_name_hash;    /* hash value of xattr prefix+suffix. */
0988     __le16  xe_name_offset;  /* byte offset from the 1st entry in the
0989                     local xattr storage(inode, xattr block or
0990                     xattr bucket). */
0991     __u8    xe_name_len;     /* xattr name len, doesn't include prefix. */
0992     __u8    xe_type;         /* the low 7 bits indicate the name prefix
0993                   * type and the highest bit indicates whether
0994                   * the EA is stored in the local storage. */
0995     __le64  xe_value_size;   /* real xattr value length. */
0996 };
0997 
0998 /*
0999  * On disk structure for xattr header.
1000  *
1001  * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
1002  * the local xattr storage.
1003  */
1004 struct ocfs2_xattr_header {
1005     __le16  xh_count;                       /* contains the count of how
1006                            many records are in the
1007                            local xattr storage. */
1008     __le16  xh_free_start;                  /* current offset for storing
1009                            xattr. */
1010     __le16  xh_name_value_len;              /* total length of name/value
1011                            length in this bucket. */
1012     __le16  xh_num_buckets;                 /* Number of xattr buckets
1013                            in this extent record,
1014                            only valid in the first
1015                            bucket. */
1016     struct ocfs2_block_check xh_check;  /* Error checking
1017                            (Note, this is only
1018                             used for xattr
1019                             buckets.  A block uses
1020                             xb_check and sets
1021                             this field to zero.) */
1022     struct ocfs2_xattr_entry xh_entries[]; /* xattr entry list. */
1023 };
1024 
1025 /*
1026  * On disk structure for xattr value root.
1027  *
1028  * When an xattr's value is large enough, it is stored in an external
1029  * b-tree like file data.  The xattr value root points to this structure.
1030  */
1031 struct ocfs2_xattr_value_root {
1032 /*00*/  __le32  xr_clusters;              /* clusters covered by xattr value. */
1033     __le32  xr_reserved0;
1034     __le64  xr_last_eb_blk;           /* Pointer to last extent block */
1035 /*10*/  struct ocfs2_extent_list xr_list; /* Extent record list */
1036 };
1037 
1038 /*
1039  * On disk structure for xattr tree root.
1040  *
1041  * It is used when there are too many extended attributes for one file. These
1042  * attributes will be organized and stored in an indexed-btree.
1043  */
1044 struct ocfs2_xattr_tree_root {
1045 /*00*/  __le32  xt_clusters;              /* clusters covered by xattr. */
1046     __le32  xt_reserved0;
1047     __le64  xt_last_eb_blk;           /* Pointer to last extent block */
1048 /*10*/  struct ocfs2_extent_list xt_list; /* Extent record list */
1049 };
1050 
1051 #define OCFS2_XATTR_INDEXED 0x1
1052 #define OCFS2_HASH_SHIFT    5
1053 #define OCFS2_XATTR_ROUND   3
1054 #define OCFS2_XATTR_SIZE(size)  (((size) + OCFS2_XATTR_ROUND) & \
1055                 ~(OCFS2_XATTR_ROUND))
1056 
1057 #define OCFS2_XATTR_BUCKET_SIZE         4096
1058 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET   (OCFS2_XATTR_BUCKET_SIZE \
1059                          / OCFS2_MIN_BLOCKSIZE)
1060 
1061 /*
1062  * On disk structure for xattr block.
1063  */
1064 struct ocfs2_xattr_block {
1065 /*00*/  __u8    xb_signature[8];     /* Signature for verification */
1066     __le16  xb_suballoc_slot;    /* Slot suballocator this
1067                     block belongs to. */
1068     __le16  xb_suballoc_bit;     /* Bit offset in suballocator
1069                     block group */
1070     __le32  xb_fs_generation;    /* Must match super block */
1071 /*10*/  __le64  xb_blkno;            /* Offset on disk, in blocks */
1072     struct ocfs2_block_check xb_check;  /* Error checking */
1073 /*20*/  __le16  xb_flags;            /* Indicates whether this block contains
1074                     real xattr or a xattr tree. */
1075     __le16  xb_reserved0;
1076     __le32  xb_reserved1;
1077     __le64  xb_suballoc_loc;    /* Suballocator block group this
1078                        xattr block belongs to. Only
1079                        valid if allocated from a
1080                        discontiguous block group */
1081 /*30*/  union {
1082         struct ocfs2_xattr_header xb_header; /* xattr header if this
1083                             block contains xattr */
1084         struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1085                             block cotains xattr
1086                             tree. */
1087     } xb_attrs;
1088 };
1089 
1090 #define OCFS2_XATTR_ENTRY_LOCAL     0x80
1091 #define OCFS2_XATTR_TYPE_MASK       0x7F
1092 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1093                      int local)
1094 {
1095     if (local)
1096         xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1097     else
1098         xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1099 }
1100 
1101 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1102 {
1103     return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1104 }
1105 
1106 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1107 {
1108     xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1109 }
1110 
1111 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1112 {
1113     return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1114 }
1115 
1116 /*
1117  *  On disk structures for global quota file
1118  */
1119 
1120 /* Magic numbers and known versions for global quota files */
1121 #define OCFS2_GLOBAL_QMAGICS {\
1122     0x0cf52470, /* USRQUOTA */ \
1123     0x0cf52471  /* GRPQUOTA */ \
1124 }
1125 
1126 #define OCFS2_GLOBAL_QVERSIONS {\
1127     0, \
1128     0, \
1129 }
1130 
1131 
1132 /* Each block of each quota file has a certain fixed number of bytes reserved
1133  * for OCFS2 internal use at its end. OCFS2 can use it for things like
1134  * checksums, etc. */
1135 #define OCFS2_QBLK_RESERVED_SPACE 8
1136 
1137 /* Generic header of all quota files */
1138 struct ocfs2_disk_dqheader {
1139     __le32 dqh_magic;   /* Magic number identifying file */
1140     __le32 dqh_version; /* Quota format version */
1141 };
1142 
1143 #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1144 
1145 /* Information header of global quota file (immediately follows the generic
1146  * header) */
1147 struct ocfs2_global_disk_dqinfo {
1148 /*00*/  __le32 dqi_bgrace;  /* Grace time for space softlimit excess */
1149     __le32 dqi_igrace;  /* Grace time for inode softlimit excess */
1150     __le32 dqi_syncms;  /* Time after which we sync local changes to
1151                  * global quota file */
1152     __le32 dqi_blocks;  /* Number of blocks in quota file */
1153 /*10*/  __le32 dqi_free_blk;    /* First free block in quota file */
1154     __le32 dqi_free_entry;  /* First block with free dquot entry in quota
1155                  * file */
1156 };
1157 
1158 /* Structure with global user / group information. We reserve some space
1159  * for future use. */
1160 struct ocfs2_global_disk_dqblk {
1161 /*00*/  __le32 dqb_id;          /* ID the structure belongs to */
1162     __le32 dqb_use_count;   /* Number of nodes having reference to this structure */
1163     __le64 dqb_ihardlimit;  /* absolute limit on allocated inodes */
1164 /*10*/  __le64 dqb_isoftlimit;  /* preferred inode limit */
1165     __le64 dqb_curinodes;   /* current # allocated inodes */
1166 /*20*/  __le64 dqb_bhardlimit;  /* absolute limit on disk space */
1167     __le64 dqb_bsoftlimit;  /* preferred limit on disk space */
1168 /*30*/  __le64 dqb_curspace;    /* current space occupied */
1169     __le64 dqb_btime;       /* time limit for excessive disk use */
1170 /*40*/  __le64 dqb_itime;       /* time limit for excessive inode use */
1171     __le64 dqb_pad1;
1172 /*50*/  __le64 dqb_pad2;
1173 };
1174 
1175 /*
1176  *  On-disk structures for local quota file
1177  */
1178 
1179 /* Magic numbers and known versions for local quota files */
1180 #define OCFS2_LOCAL_QMAGICS {\
1181     0x0cf524c0, /* USRQUOTA */ \
1182     0x0cf524c1  /* GRPQUOTA */ \
1183 }
1184 
1185 #define OCFS2_LOCAL_QVERSIONS {\
1186     0, \
1187     0, \
1188 }
1189 
1190 /* Quota flags in dqinfo header */
1191 #define OLQF_CLEAN  0x0001  /* Quota file is empty (this should be after\
1192                  * quota has been cleanly turned off) */
1193 
1194 #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1195 
1196 /* Information header of local quota file (immediately follows the generic
1197  * header) */
1198 struct ocfs2_local_disk_dqinfo {
1199     __le32 dqi_flags;   /* Flags for quota file */
1200     __le32 dqi_chunks;  /* Number of chunks of quota structures
1201                  * with a bitmap */
1202     __le32 dqi_blocks;  /* Number of blocks allocated for quota file */
1203 };
1204 
1205 /* Header of one chunk of a quota file */
1206 struct ocfs2_local_disk_chunk {
1207     __le32 dqc_free;    /* Number of free entries in the bitmap */
1208     __u8 dqc_bitmap[];  /* Bitmap of entries in the corresponding
1209                  * chunk of quota file */
1210 };
1211 
1212 /* One entry in local quota file */
1213 struct ocfs2_local_disk_dqblk {
1214 /*00*/  __le64 dqb_id;      /* id this quota applies to */
1215     __le64 dqb_spacemod;    /* Change in the amount of used space */
1216 /*10*/  __le64 dqb_inodemod;    /* Change in the amount of used inodes */
1217 };
1218 
1219 
1220 /*
1221  * The quota trailer lives at the end of each quota block.
1222  */
1223 
1224 struct ocfs2_disk_dqtrailer {
1225 /*00*/  struct ocfs2_block_check dq_check;  /* Error checking */
1226 /*08*/  /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1227 };
1228 
1229 static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1230                                  void *buf)
1231 {
1232     char *ptr = buf;
1233     ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1234 
1235     return (struct ocfs2_disk_dqtrailer *)ptr;
1236 }
1237 
1238 #ifdef __KERNEL__
1239 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1240 {
1241     return  sb->s_blocksize -
1242          offsetof(struct ocfs2_dinode, id2.i_symlink);
1243 }
1244 
1245 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1246                            struct ocfs2_dinode *di)
1247 {
1248     unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1249 
1250     if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1251         return sb->s_blocksize -
1252             offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1253             xattrsize;
1254     else
1255         return sb->s_blocksize -
1256             offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1257 }
1258 
1259 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1260 {
1261     int size;
1262 
1263     size = sb->s_blocksize -
1264         offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1265 
1266     return size / sizeof(struct ocfs2_extent_rec);
1267 }
1268 
1269 static inline int ocfs2_extent_recs_per_inode_with_xattr(
1270                         struct super_block *sb,
1271                         struct ocfs2_dinode *di)
1272 {
1273     int size;
1274     unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1275 
1276     if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1277         size = sb->s_blocksize -
1278             offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1279             xattrsize;
1280     else
1281         size = sb->s_blocksize -
1282             offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1283 
1284     return size / sizeof(struct ocfs2_extent_rec);
1285 }
1286 
1287 static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1288 {
1289     int size;
1290 
1291     size = sb->s_blocksize -
1292         offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1293 
1294     return size / sizeof(struct ocfs2_extent_rec);
1295 }
1296 
1297 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1298 {
1299     int size;
1300 
1301     size = sb->s_blocksize -
1302         offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1303 
1304     return size / sizeof(struct ocfs2_chain_rec);
1305 }
1306 
1307 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1308 {
1309     int size;
1310 
1311     size = sb->s_blocksize -
1312         offsetof(struct ocfs2_extent_block, h_list.l_recs);
1313 
1314     return size / sizeof(struct ocfs2_extent_rec);
1315 }
1316 
1317 static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1318 {
1319     int size;
1320 
1321     size = sb->s_blocksize -
1322         offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1323 
1324     return size / sizeof(struct ocfs2_extent_rec);
1325 }
1326 
1327 static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1328 {
1329     int size;
1330 
1331     size = sb->s_blocksize -
1332         offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1333 
1334     return size / sizeof(struct ocfs2_dx_entry);
1335 }
1336 
1337 static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1338 {
1339     int size;
1340 
1341     size = sb->s_blocksize -
1342         offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1343 
1344     return size / sizeof(struct ocfs2_dx_entry);
1345 }
1346 
1347 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1348 {
1349     u16 size;
1350 
1351     size = sb->s_blocksize -
1352         offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1353 
1354     return size;
1355 }
1356 
1357 static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1358                       int suballocator,
1359                       u32 feature_incompat)
1360 {
1361     int size = sb->s_blocksize -
1362         offsetof(struct ocfs2_group_desc, bg_bitmap);
1363 
1364     /*
1365      * The cluster allocator uses the entire block.  Suballocators have
1366      * never used more than OCFS2_MAX_BG_BITMAP_SIZE.  Unfortunately, older
1367      * code expects bg_size set to the maximum.  Thus we must keep
1368      * bg_size as-is unless discontig_bg is enabled.
1369      */
1370     if (suballocator &&
1371         (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1372         size = OCFS2_MAX_BG_BITMAP_SIZE;
1373 
1374     return size;
1375 }
1376 
1377 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1378 {
1379     int size;
1380 
1381     size = sb->s_blocksize -
1382         offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1383 
1384     return size / sizeof(struct ocfs2_truncate_rec);
1385 }
1386 
1387 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1388 {
1389     u64 offset = OCFS2_BACKUP_SB_START;
1390 
1391     if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1392         offset <<= (2 * index);
1393         offset >>= sb->s_blocksize_bits;
1394         return offset;
1395     }
1396 
1397     return 0;
1398 
1399 }
1400 
1401 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1402 {
1403     int size;
1404 
1405     size = sb->s_blocksize -
1406         offsetof(struct ocfs2_xattr_block,
1407              xb_attrs.xb_root.xt_list.l_recs);
1408 
1409     return size / sizeof(struct ocfs2_extent_rec);
1410 }
1411 
1412 static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1413 {
1414     int size;
1415 
1416     size = sb->s_blocksize -
1417         offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1418 
1419     return size / sizeof(struct ocfs2_extent_rec);
1420 }
1421 
1422 static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1423 {
1424     int size;
1425 
1426     size = sb->s_blocksize -
1427         offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1428 
1429     return size / sizeof(struct ocfs2_refcount_rec);
1430 }
1431 
1432 static inline u32
1433 ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1434 {
1435     return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1436 }
1437 #else
1438 static inline int ocfs2_fast_symlink_chars(int blocksize)
1439 {
1440     return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1441 }
1442 
1443 static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1444                            struct ocfs2_dinode *di)
1445 {
1446     if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1447         return blocksize -
1448             offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1449             di->i_xattr_inline_size;
1450     else
1451         return blocksize -
1452             offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1453 }
1454 
1455 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1456 {
1457     int size;
1458 
1459     size = blocksize -
1460         offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1461 
1462     return size / sizeof(struct ocfs2_extent_rec);
1463 }
1464 
1465 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1466 {
1467     int size;
1468 
1469     size = blocksize -
1470         offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1471 
1472     return size / sizeof(struct ocfs2_chain_rec);
1473 }
1474 
1475 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1476 {
1477     int size;
1478 
1479     size = blocksize -
1480         offsetof(struct ocfs2_extent_block, h_list.l_recs);
1481 
1482     return size / sizeof(struct ocfs2_extent_rec);
1483 }
1484 
1485 static inline int ocfs2_extent_recs_per_gd(int blocksize)
1486 {
1487     int size;
1488 
1489     size = blocksize -
1490         offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1491 
1492     return size / sizeof(struct ocfs2_extent_rec);
1493 }
1494 
1495 static inline int ocfs2_local_alloc_size(int blocksize)
1496 {
1497     int size;
1498 
1499     size = blocksize -
1500         offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1501 
1502     return size;
1503 }
1504 
1505 static inline int ocfs2_group_bitmap_size(int blocksize,
1506                       int suballocator,
1507                       uint32_t feature_incompat)
1508 {
1509     int size = sb->s_blocksize -
1510         offsetof(struct ocfs2_group_desc, bg_bitmap);
1511 
1512     /*
1513      * The cluster allocator uses the entire block.  Suballocators have
1514      * never used more than OCFS2_MAX_BG_BITMAP_SIZE.  Unfortunately, older
1515      * code expects bg_size set to the maximum.  Thus we must keep
1516      * bg_size as-is unless discontig_bg is enabled.
1517      */
1518     if (suballocator &&
1519         (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1520         size = OCFS2_MAX_BG_BITMAP_SIZE;
1521 
1522     return size;
1523 }
1524 
1525 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1526 {
1527     int size;
1528 
1529     size = blocksize -
1530         offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1531 
1532     return size / sizeof(struct ocfs2_truncate_rec);
1533 }
1534 
1535 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1536 {
1537     uint64_t offset = OCFS2_BACKUP_SB_START;
1538 
1539     if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1540         offset <<= (2 * index);
1541         offset /= blocksize;
1542         return offset;
1543     }
1544 
1545     return 0;
1546 }
1547 
1548 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1549 {
1550     int size;
1551 
1552     size = blocksize -
1553         offsetof(struct ocfs2_xattr_block,
1554              xb_attrs.xb_root.xt_list.l_recs);
1555 
1556     return size / sizeof(struct ocfs2_extent_rec);
1557 }
1558 #endif  /* __KERNEL__ */
1559 
1560 
1561 static inline int ocfs2_system_inode_is_global(int type)
1562 {
1563     return ((type >= 0) &&
1564         (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1565 }
1566 
1567 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1568                           int type, int slot)
1569 {
1570     int chars;
1571 
1572         /*
1573          * Global system inodes can only have one copy.  Everything
1574          * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1575          * list has a copy per slot.
1576          */
1577     if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1578         chars = snprintf(buf, len, "%s",
1579                  ocfs2_system_inodes[type].si_name);
1580     else
1581         chars = snprintf(buf, len,
1582                  ocfs2_system_inodes[type].si_name,
1583                  slot);
1584 
1585     return chars;
1586 }
1587 
1588 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1589                     umode_t mode)
1590 {
1591     de->file_type = fs_umode_to_ftype(mode);
1592 }
1593 
1594 static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1595 {
1596     if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1597          le16_to_cpu(gd->bg_size)) !=
1598         offsetof(struct ocfs2_group_desc, bg_list))
1599         return 0;
1600     /*
1601      * Only valid to check l_next_free_rec if
1602      * bg_bitmap + bg_size == bg_list.
1603      */
1604     if (!gd->bg_list.l_next_free_rec)
1605         return 0;
1606     return 1;
1607 }
1608 #endif  /* _OCFS2_FS_H */
1609