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