Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1 | /* -*- mode: c; c-basic-offset: 8; -*- |
| 2 | * vim: noexpandtab sw=8 ts=8 sts=0: |
| 3 | * |
| 4 | * ocfs2_fs.h |
| 5 | * |
| 6 | * On-disk structures for OCFS2. |
| 7 | * |
| 8 | * Copyright (C) 2002, 2004 Oracle. All rights reserved. |
| 9 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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. |
| 23 | */ |
| 24 | |
| 25 | #ifndef _OCFS2_FS_H |
| 26 | #define _OCFS2_FS_H |
| 27 | |
| 28 | /* Version */ |
| 29 | #define OCFS2_MAJOR_REV_LEVEL 0 |
| 30 | #define OCFS2_MINOR_REV_LEVEL 90 |
| 31 | |
| 32 | /* |
| 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. |
| 37 | * |
| 38 | * All other structures are found from the superblock information. |
| 39 | * |
| 40 | * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a |
| 41 | * blocksize of 2K, it is 4096 bytes into disk. |
| 42 | */ |
| 43 | #define OCFS2_SUPER_BLOCK_BLKNO 2 |
| 44 | |
| 45 | /* |
| 46 | * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could |
| 47 | * grow if needed. |
| 48 | */ |
| 49 | #define OCFS2_MIN_CLUSTERSIZE 4096 |
| 50 | #define OCFS2_MAX_CLUSTERSIZE 1048576 |
| 51 | |
| 52 | /* |
| 53 | * Blocks cannot be bigger than clusters, so the maximum blocksize is the |
| 54 | * minimum cluster size. |
| 55 | */ |
| 56 | #define OCFS2_MIN_BLOCKSIZE 512 |
| 57 | #define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE |
| 58 | |
| 59 | /* Filesystem magic number */ |
| 60 | #define OCFS2_SUPER_MAGIC 0x7461636f |
| 61 | |
| 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 | |
| 68 | /* Compatibility flags */ |
| 69 | #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ |
| 70 | ( OCFS2_SB(sb)->s_feature_compat & (mask) ) |
| 71 | #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \ |
| 72 | ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) ) |
| 73 | #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \ |
| 74 | ( OCFS2_SB(sb)->s_feature_incompat & (mask) ) |
| 75 | #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \ |
| 76 | OCFS2_SB(sb)->s_feature_compat |= (mask) |
| 77 | #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \ |
| 78 | OCFS2_SB(sb)->s_feature_ro_compat |= (mask) |
| 79 | #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \ |
| 80 | OCFS2_SB(sb)->s_feature_incompat |= (mask) |
| 81 | #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \ |
| 82 | OCFS2_SB(sb)->s_feature_compat &= ~(mask) |
| 83 | #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ |
| 84 | OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask) |
| 85 | #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ |
| 86 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) |
| 87 | |
| 88 | #define OCFS2_FEATURE_COMPAT_SUPP 0 |
Sunil Mushran | c271c5c | 2006-12-05 17:56:35 -0800 | [diff] [blame] | 89 | #define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 90 | #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 |
| 91 | |
| 92 | /* |
| 93 | * Heartbeat-only devices are missing journals and other files. The |
| 94 | * filesystem driver can't load them, but the library can. Never put |
| 95 | * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*. |
| 96 | */ |
| 97 | #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 |
| 98 | |
Mark Fasheh | 8903901 | 2006-12-07 18:05:37 -0800 | [diff] [blame^] | 99 | /* |
| 100 | * tunefs sets this incompat flag before starting the resize and clears it |
| 101 | * at the end. This flag protects users from inadvertently mounting the fs |
| 102 | * after an aborted run without fsck-ing. |
| 103 | */ |
| 104 | #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004 |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 105 | |
Sunil Mushran | c271c5c | 2006-12-05 17:56:35 -0800 | [diff] [blame] | 106 | /* Used to denote a non-clustered volume */ |
| 107 | #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008 |
| 108 | |
Mark Fasheh | 8903901 | 2006-12-07 18:05:37 -0800 | [diff] [blame^] | 109 | /* Support for sparse allocation in b-trees */ |
| 110 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 |
| 111 | |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 112 | /* |
| 113 | * Flags on ocfs2_dinode.i_flags |
| 114 | */ |
| 115 | #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ |
| 116 | #define OCFS2_UNUSED2_FL (0x00000002) |
| 117 | #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */ |
| 118 | #define OCFS2_UNUSED3_FL (0x00000008) |
| 119 | /* System inode flags */ |
| 120 | #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */ |
| 121 | #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */ |
| 122 | #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */ |
| 123 | #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */ |
| 124 | #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */ |
| 125 | #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */ |
| 126 | #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */ |
| 127 | #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */ |
| 128 | |
Herbert Poetzl | ca4d147 | 2006-07-03 17:27:12 -0700 | [diff] [blame] | 129 | /* Inode attributes, keep in sync with EXT2 */ |
| 130 | #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */ |
| 131 | #define OCFS2_UNRM_FL (0x00000002) /* Undelete */ |
| 132 | #define OCFS2_COMPR_FL (0x00000004) /* Compress file */ |
| 133 | #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */ |
| 134 | #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */ |
| 135 | #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */ |
| 136 | #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */ |
| 137 | #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */ |
| 138 | #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */ |
| 139 | |
| 140 | #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */ |
| 141 | #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */ |
| 142 | |
| 143 | /* |
| 144 | * ioctl commands |
| 145 | */ |
| 146 | #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long) |
| 147 | #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long) |
| 148 | |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 149 | /* |
| 150 | * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) |
| 151 | */ |
| 152 | #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */ |
| 153 | |
| 154 | /* |
| 155 | * superblock s_state flags |
| 156 | */ |
| 157 | #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */ |
| 158 | |
| 159 | /* Limit of space in ocfs2_dir_entry */ |
| 160 | #define OCFS2_MAX_FILENAME_LEN 255 |
| 161 | |
| 162 | /* Maximum slots on an ocfs2 file system */ |
| 163 | #define OCFS2_MAX_SLOTS 255 |
| 164 | |
| 165 | /* Slot map indicator for an empty slot */ |
| 166 | #define OCFS2_INVALID_SLOT -1 |
| 167 | |
| 168 | #define OCFS2_VOL_UUID_LEN 16 |
| 169 | #define OCFS2_MAX_VOL_LABEL_LEN 64 |
| 170 | |
| 171 | /* Journal limits (in bytes) */ |
| 172 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 173 | |
| 174 | struct ocfs2_system_inode_info { |
| 175 | char *si_name; |
| 176 | int si_iflags; |
| 177 | int si_mode; |
| 178 | }; |
| 179 | |
| 180 | /* System file index */ |
| 181 | enum { |
| 182 | BAD_BLOCK_SYSTEM_INODE = 0, |
| 183 | GLOBAL_INODE_ALLOC_SYSTEM_INODE, |
| 184 | SLOT_MAP_SYSTEM_INODE, |
| 185 | #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE |
| 186 | HEARTBEAT_SYSTEM_INODE, |
| 187 | GLOBAL_BITMAP_SYSTEM_INODE, |
| 188 | #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE |
| 189 | ORPHAN_DIR_SYSTEM_INODE, |
| 190 | EXTENT_ALLOC_SYSTEM_INODE, |
| 191 | INODE_ALLOC_SYSTEM_INODE, |
| 192 | JOURNAL_SYSTEM_INODE, |
| 193 | LOCAL_ALLOC_SYSTEM_INODE, |
| 194 | TRUNCATE_LOG_SYSTEM_INODE, |
| 195 | NUM_SYSTEM_INODES |
| 196 | }; |
| 197 | |
| 198 | static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { |
| 199 | /* Global system inodes (single copy) */ |
| 200 | /* The first two are only used from userspace mfks/tunefs */ |
| 201 | [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 }, |
| 202 | [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, |
| 203 | |
| 204 | /* These are used by the running filesystem */ |
| 205 | [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 }, |
| 206 | [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 }, |
| 207 | [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 }, |
| 208 | |
| 209 | /* Slot-specific system inodes (one copy per slot) */ |
| 210 | [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 }, |
| 211 | [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, |
| 212 | [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, |
| 213 | [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 }, |
| 214 | [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }, |
| 215 | [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 } |
| 216 | }; |
| 217 | |
| 218 | /* Parameter passed from mount.ocfs2 to module */ |
| 219 | #define OCFS2_HB_NONE "heartbeat=none" |
| 220 | #define OCFS2_HB_LOCAL "heartbeat=local" |
| 221 | |
| 222 | /* |
| 223 | * OCFS2 directory file types. Only the low 3 bits are used. The |
| 224 | * other bits are reserved for now. |
| 225 | */ |
| 226 | #define OCFS2_FT_UNKNOWN 0 |
| 227 | #define OCFS2_FT_REG_FILE 1 |
| 228 | #define OCFS2_FT_DIR 2 |
| 229 | #define OCFS2_FT_CHRDEV 3 |
| 230 | #define OCFS2_FT_BLKDEV 4 |
| 231 | #define OCFS2_FT_FIFO 5 |
| 232 | #define OCFS2_FT_SOCK 6 |
| 233 | #define OCFS2_FT_SYMLINK 7 |
| 234 | |
| 235 | #define OCFS2_FT_MAX 8 |
| 236 | |
| 237 | /* |
| 238 | * OCFS2_DIR_PAD defines the directory entries boundaries |
| 239 | * |
| 240 | * NOTE: It must be a multiple of 4 |
| 241 | */ |
| 242 | #define OCFS2_DIR_PAD 4 |
| 243 | #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1) |
| 244 | #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name) |
| 245 | #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \ |
| 246 | OCFS2_DIR_ROUND) & \ |
| 247 | ~OCFS2_DIR_ROUND) |
| 248 | |
| 249 | #define OCFS2_LINK_MAX 32000 |
| 250 | |
| 251 | #define S_SHIFT 12 |
| 252 | static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { |
| 253 | [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE, |
| 254 | [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR, |
| 255 | [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV, |
| 256 | [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV, |
| 257 | [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO, |
| 258 | [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK, |
| 259 | [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK, |
| 260 | }; |
| 261 | |
| 262 | |
| 263 | /* |
| 264 | * Convenience casts |
| 265 | */ |
| 266 | #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super)) |
| 267 | |
| 268 | /* |
| 269 | * On disk extent record for OCFS2 |
| 270 | * It describes a range of clusters on disk. |
| 271 | */ |
| 272 | struct ocfs2_extent_rec { |
| 273 | /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */ |
| 274 | __le32 e_clusters; /* Clusters covered by this extent */ |
| 275 | __le64 e_blkno; /* Physical disk offset, in blocks */ |
| 276 | /*10*/ |
| 277 | }; |
| 278 | |
| 279 | struct ocfs2_chain_rec { |
| 280 | __le32 c_free; /* Number of free bits in this chain. */ |
| 281 | __le32 c_total; /* Number of total bits in this chain */ |
| 282 | __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */ |
| 283 | }; |
| 284 | |
| 285 | struct ocfs2_truncate_rec { |
| 286 | __le32 t_start; /* 1st cluster in this log */ |
| 287 | __le32 t_clusters; /* Number of total clusters covered */ |
| 288 | }; |
| 289 | |
| 290 | /* |
| 291 | * On disk extent list for OCFS2 (node in the tree). Note that this |
| 292 | * is contained inside ocfs2_dinode or ocfs2_extent_block, so the |
| 293 | * offsets are relative to ocfs2_dinode.id2.i_list or |
| 294 | * ocfs2_extent_block.h_list, respectively. |
| 295 | */ |
| 296 | struct ocfs2_extent_list { |
| 297 | /*00*/ __le16 l_tree_depth; /* Extent tree depth from this |
| 298 | point. 0 means data extents |
| 299 | hang directly off this |
| 300 | header (a leaf) */ |
| 301 | __le16 l_count; /* Number of extent records */ |
| 302 | __le16 l_next_free_rec; /* Next unused extent slot */ |
| 303 | __le16 l_reserved1; |
| 304 | __le64 l_reserved2; /* Pad to |
| 305 | sizeof(ocfs2_extent_rec) */ |
| 306 | /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */ |
| 307 | }; |
| 308 | |
| 309 | /* |
| 310 | * On disk allocation chain list for OCFS2. Note that this is |
| 311 | * contained inside ocfs2_dinode, so the offsets are relative to |
| 312 | * ocfs2_dinode.id2.i_chain. |
| 313 | */ |
| 314 | struct ocfs2_chain_list { |
| 315 | /*00*/ __le16 cl_cpg; /* Clusters per Block Group */ |
| 316 | __le16 cl_bpc; /* Bits per cluster */ |
| 317 | __le16 cl_count; /* Total chains in this list */ |
| 318 | __le16 cl_next_free_rec; /* Next unused chain slot */ |
| 319 | __le64 cl_reserved1; |
| 320 | /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */ |
| 321 | }; |
| 322 | |
| 323 | /* |
| 324 | * On disk deallocation log for OCFS2. Note that this is |
| 325 | * contained inside ocfs2_dinode, so the offsets are relative to |
| 326 | * ocfs2_dinode.id2.i_dealloc. |
| 327 | */ |
| 328 | struct ocfs2_truncate_log { |
| 329 | /*00*/ __le16 tl_count; /* Total records in this log */ |
| 330 | __le16 tl_used; /* Number of records in use */ |
| 331 | __le32 tl_reserved1; |
| 332 | /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */ |
| 333 | }; |
| 334 | |
| 335 | /* |
| 336 | * On disk extent block (indirect block) for OCFS2 |
| 337 | */ |
| 338 | struct ocfs2_extent_block |
| 339 | { |
| 340 | /*00*/ __u8 h_signature[8]; /* Signature for verification */ |
| 341 | __le64 h_reserved1; |
| 342 | /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this |
| 343 | extent_header belongs to */ |
| 344 | __le16 h_suballoc_bit; /* Bit offset in suballocator |
| 345 | block group */ |
| 346 | __le32 h_fs_generation; /* Must match super block */ |
| 347 | __le64 h_blkno; /* Offset on disk, in blocks */ |
| 348 | /*20*/ __le64 h_reserved3; |
| 349 | __le64 h_next_leaf_blk; /* Offset on disk, in blocks, |
| 350 | of next leaf header pointing |
| 351 | to data */ |
| 352 | /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */ |
| 353 | /* Actual on-disk size is one block */ |
| 354 | }; |
| 355 | |
| 356 | /* |
| 357 | * On disk superblock for OCFS2 |
| 358 | * Note that it is contained inside an ocfs2_dinode, so all offsets |
| 359 | * are relative to the start of ocfs2_dinode.id2. |
| 360 | */ |
| 361 | struct ocfs2_super_block { |
| 362 | /*00*/ __le16 s_major_rev_level; |
| 363 | __le16 s_minor_rev_level; |
| 364 | __le16 s_mnt_count; |
| 365 | __le16 s_max_mnt_count; |
| 366 | __le16 s_state; /* File system state */ |
| 367 | __le16 s_errors; /* Behaviour when detecting errors */ |
| 368 | __le32 s_checkinterval; /* Max time between checks */ |
| 369 | /*10*/ __le64 s_lastcheck; /* Time of last check */ |
| 370 | __le32 s_creator_os; /* OS */ |
| 371 | __le32 s_feature_compat; /* Compatible feature set */ |
| 372 | /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */ |
| 373 | __le32 s_feature_ro_compat; /* Readonly-compatible feature set */ |
| 374 | __le64 s_root_blkno; /* Offset, in blocks, of root directory |
| 375 | dinode */ |
| 376 | /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system |
| 377 | directory dinode */ |
| 378 | __le32 s_blocksize_bits; /* Blocksize for this fs */ |
| 379 | __le32 s_clustersize_bits; /* Clustersize for this fs */ |
| 380 | /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts |
| 381 | before tunefs required */ |
| 382 | __le16 s_reserved1; |
| 383 | __le32 s_reserved2; |
| 384 | __le64 s_first_cluster_group; /* Block offset of 1st cluster |
| 385 | * group header */ |
| 386 | /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */ |
| 387 | /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */ |
| 388 | /*A0*/ |
| 389 | }; |
| 390 | |
| 391 | /* |
| 392 | * Local allocation bitmap for OCFS2 slots |
| 393 | * Note that it exists inside an ocfs2_dinode, so all offsets are |
| 394 | * relative to the start of ocfs2_dinode.id2. |
| 395 | */ |
| 396 | struct ocfs2_local_alloc |
| 397 | { |
| 398 | /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */ |
| 399 | __le16 la_size; /* Size of included bitmap, in bytes */ |
| 400 | __le16 la_reserved1; |
| 401 | __le64 la_reserved2; |
| 402 | /*10*/ __u8 la_bitmap[0]; |
| 403 | }; |
| 404 | |
| 405 | /* |
| 406 | * On disk inode for OCFS2 |
| 407 | */ |
| 408 | struct ocfs2_dinode { |
| 409 | /*00*/ __u8 i_signature[8]; /* Signature for validation */ |
| 410 | __le32 i_generation; /* Generation number */ |
| 411 | __le16 i_suballoc_slot; /* Slot suballocator this inode |
| 412 | belongs to */ |
| 413 | __le16 i_suballoc_bit; /* Bit offset in suballocator |
| 414 | block group */ |
| 415 | /*10*/ __le32 i_reserved0; |
| 416 | __le32 i_clusters; /* Cluster count */ |
| 417 | __le32 i_uid; /* Owner UID */ |
| 418 | __le32 i_gid; /* Owning GID */ |
| 419 | /*20*/ __le64 i_size; /* Size in bytes */ |
| 420 | __le16 i_mode; /* File mode */ |
| 421 | __le16 i_links_count; /* Links count */ |
| 422 | __le32 i_flags; /* File flags */ |
| 423 | /*30*/ __le64 i_atime; /* Access time */ |
| 424 | __le64 i_ctime; /* Creation time */ |
| 425 | /*40*/ __le64 i_mtime; /* Modification time */ |
| 426 | __le64 i_dtime; /* Deletion time */ |
| 427 | /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */ |
| 428 | __le64 i_last_eb_blk; /* Pointer to last extent |
| 429 | block */ |
| 430 | /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */ |
| 431 | __le32 i_atime_nsec; |
| 432 | __le32 i_ctime_nsec; |
| 433 | __le32 i_mtime_nsec; |
Herbert Poetzl | ca4d147 | 2006-07-03 17:27:12 -0700 | [diff] [blame] | 434 | __le32 i_attr; |
| 435 | __le32 i_reserved1; |
| 436 | /*70*/ __le64 i_reserved2[8]; |
Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 437 | /*B8*/ union { |
| 438 | __le64 i_pad1; /* Generic way to refer to this |
| 439 | 64bit union */ |
| 440 | struct { |
| 441 | __le64 i_rdev; /* Device number */ |
| 442 | } dev1; |
| 443 | struct { /* Info for bitmap system |
| 444 | inodes */ |
| 445 | __le32 i_used; /* Bits (ie, clusters) used */ |
| 446 | __le32 i_total; /* Total bits (clusters) |
| 447 | available */ |
| 448 | } bitmap1; |
| 449 | struct { /* Info for journal system |
| 450 | inodes */ |
| 451 | __le32 ij_flags; /* Mounted, version, etc. */ |
| 452 | __le32 ij_pad; |
| 453 | } journal1; |
| 454 | } id1; /* Inode type dependant 1 */ |
| 455 | /*C0*/ union { |
| 456 | struct ocfs2_super_block i_super; |
| 457 | struct ocfs2_local_alloc i_lab; |
| 458 | struct ocfs2_chain_list i_chain; |
| 459 | struct ocfs2_extent_list i_list; |
| 460 | struct ocfs2_truncate_log i_dealloc; |
| 461 | __u8 i_symlink[0]; |
| 462 | } id2; |
| 463 | /* Actual on-disk size is one block */ |
| 464 | }; |
| 465 | |
| 466 | /* |
| 467 | * On-disk directory entry structure for OCFS2 |
| 468 | * |
| 469 | * Packed as this structure could be accessed unaligned on 64-bit platforms |
| 470 | */ |
| 471 | struct ocfs2_dir_entry { |
| 472 | /*00*/ __le64 inode; /* Inode number */ |
| 473 | __le16 rec_len; /* Directory entry length */ |
| 474 | __u8 name_len; /* Name length */ |
| 475 | __u8 file_type; |
| 476 | /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */ |
| 477 | /* Actual on-disk length specified by rec_len */ |
| 478 | } __attribute__ ((packed)); |
| 479 | |
| 480 | /* |
| 481 | * On disk allocator group structure for OCFS2 |
| 482 | */ |
| 483 | struct ocfs2_group_desc |
| 484 | { |
| 485 | /*00*/ __u8 bg_signature[8]; /* Signature for validation */ |
| 486 | __le16 bg_size; /* Size of included bitmap in |
| 487 | bytes. */ |
| 488 | __le16 bg_bits; /* Bits represented by this |
| 489 | group. */ |
| 490 | __le16 bg_free_bits_count; /* Free bits count */ |
| 491 | __le16 bg_chain; /* What chain I am in. */ |
| 492 | /*10*/ __le32 bg_generation; |
| 493 | __le32 bg_reserved1; |
| 494 | __le64 bg_next_group; /* Next group in my list, in |
| 495 | blocks */ |
| 496 | /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in |
| 497 | blocks */ |
| 498 | __le64 bg_blkno; /* Offset on disk, in blocks */ |
| 499 | /*30*/ __le64 bg_reserved2[2]; |
| 500 | /*40*/ __u8 bg_bitmap[0]; |
| 501 | }; |
| 502 | |
| 503 | #ifdef __KERNEL__ |
| 504 | static inline int ocfs2_fast_symlink_chars(struct super_block *sb) |
| 505 | { |
| 506 | return sb->s_blocksize - |
| 507 | offsetof(struct ocfs2_dinode, id2.i_symlink); |
| 508 | } |
| 509 | |
| 510 | static inline int ocfs2_extent_recs_per_inode(struct super_block *sb) |
| 511 | { |
| 512 | int size; |
| 513 | |
| 514 | size = sb->s_blocksize - |
| 515 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); |
| 516 | |
| 517 | return size / sizeof(struct ocfs2_extent_rec); |
| 518 | } |
| 519 | |
| 520 | static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) |
| 521 | { |
| 522 | int size; |
| 523 | |
| 524 | size = sb->s_blocksize - |
| 525 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); |
| 526 | |
| 527 | return size / sizeof(struct ocfs2_chain_rec); |
| 528 | } |
| 529 | |
| 530 | static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) |
| 531 | { |
| 532 | int size; |
| 533 | |
| 534 | size = sb->s_blocksize - |
| 535 | offsetof(struct ocfs2_extent_block, h_list.l_recs); |
| 536 | |
| 537 | return size / sizeof(struct ocfs2_extent_rec); |
| 538 | } |
| 539 | |
| 540 | static inline u16 ocfs2_local_alloc_size(struct super_block *sb) |
| 541 | { |
| 542 | u16 size; |
| 543 | |
| 544 | size = sb->s_blocksize - |
| 545 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); |
| 546 | |
| 547 | return size; |
| 548 | } |
| 549 | |
| 550 | static inline int ocfs2_group_bitmap_size(struct super_block *sb) |
| 551 | { |
| 552 | int size; |
| 553 | |
| 554 | size = sb->s_blocksize - |
| 555 | offsetof(struct ocfs2_group_desc, bg_bitmap); |
| 556 | |
| 557 | return size; |
| 558 | } |
| 559 | |
| 560 | static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb) |
| 561 | { |
| 562 | int size; |
| 563 | |
| 564 | size = sb->s_blocksize - |
| 565 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); |
| 566 | |
| 567 | return size / sizeof(struct ocfs2_truncate_rec); |
| 568 | } |
| 569 | #else |
| 570 | static inline int ocfs2_fast_symlink_chars(int blocksize) |
| 571 | { |
| 572 | return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink); |
| 573 | } |
| 574 | |
| 575 | static inline int ocfs2_extent_recs_per_inode(int blocksize) |
| 576 | { |
| 577 | int size; |
| 578 | |
| 579 | size = blocksize - |
| 580 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); |
| 581 | |
| 582 | return size / sizeof(struct ocfs2_extent_rec); |
| 583 | } |
| 584 | |
| 585 | static inline int ocfs2_chain_recs_per_inode(int blocksize) |
| 586 | { |
| 587 | int size; |
| 588 | |
| 589 | size = blocksize - |
| 590 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); |
| 591 | |
| 592 | return size / sizeof(struct ocfs2_chain_rec); |
| 593 | } |
| 594 | |
| 595 | static inline int ocfs2_extent_recs_per_eb(int blocksize) |
| 596 | { |
| 597 | int size; |
| 598 | |
| 599 | size = blocksize - |
| 600 | offsetof(struct ocfs2_extent_block, h_list.l_recs); |
| 601 | |
| 602 | return size / sizeof(struct ocfs2_extent_rec); |
| 603 | } |
| 604 | |
| 605 | static inline int ocfs2_local_alloc_size(int blocksize) |
| 606 | { |
| 607 | int size; |
| 608 | |
| 609 | size = blocksize - |
| 610 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); |
| 611 | |
| 612 | return size; |
| 613 | } |
| 614 | |
| 615 | static inline int ocfs2_group_bitmap_size(int blocksize) |
| 616 | { |
| 617 | int size; |
| 618 | |
| 619 | size = blocksize - |
| 620 | offsetof(struct ocfs2_group_desc, bg_bitmap); |
| 621 | |
| 622 | return size; |
| 623 | } |
| 624 | |
| 625 | static inline int ocfs2_truncate_recs_per_inode(int blocksize) |
| 626 | { |
| 627 | int size; |
| 628 | |
| 629 | size = blocksize - |
| 630 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); |
| 631 | |
| 632 | return size / sizeof(struct ocfs2_truncate_rec); |
| 633 | } |
| 634 | #endif /* __KERNEL__ */ |
| 635 | |
| 636 | |
| 637 | static inline int ocfs2_system_inode_is_global(int type) |
| 638 | { |
| 639 | return ((type >= 0) && |
| 640 | (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)); |
| 641 | } |
| 642 | |
| 643 | static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, |
| 644 | int type, int slot) |
| 645 | { |
| 646 | int chars; |
| 647 | |
| 648 | /* |
| 649 | * Global system inodes can only have one copy. Everything |
| 650 | * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode |
| 651 | * list has a copy per slot. |
| 652 | */ |
| 653 | if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) |
| 654 | chars = snprintf(buf, len, |
| 655 | ocfs2_system_inodes[type].si_name); |
| 656 | else |
| 657 | chars = snprintf(buf, len, |
| 658 | ocfs2_system_inodes[type].si_name, |
| 659 | slot); |
| 660 | |
| 661 | return chars; |
| 662 | } |
| 663 | |
| 664 | static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, |
| 665 | umode_t mode) |
| 666 | { |
| 667 | de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; |
| 668 | } |
| 669 | |
| 670 | #endif /* _OCFS2_FS_H */ |
| 671 | |