| 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" | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 67 | #define OCFS2_XATTR_BLOCK_SIGNATURE	"XATTR01" | 
| Mark Fasheh | 87d35a7 | 2008-12-10 17:36:25 -0800 | [diff] [blame] | 68 | #define OCFS2_DIR_TRAILER_SIGNATURE	"DIRTRL1" | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 69 | #define OCFS2_DX_ROOT_SIGNATURE		"DXDIR01" | 
|  | 70 | #define OCFS2_DX_LEAF_SIGNATURE		"DXLEAF1" | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 71 | #define OCFS2_REFCOUNT_BLOCK_SIGNATURE	"REFCNT1" | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 72 |  | 
|  | 73 | /* Compatibility flags */ | 
|  | 74 | #define OCFS2_HAS_COMPAT_FEATURE(sb,mask)			\ | 
|  | 75 | ( OCFS2_SB(sb)->s_feature_compat & (mask) ) | 
|  | 76 | #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask)			\ | 
|  | 77 | ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) ) | 
|  | 78 | #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask)			\ | 
|  | 79 | ( OCFS2_SB(sb)->s_feature_incompat & (mask) ) | 
|  | 80 | #define OCFS2_SET_COMPAT_FEATURE(sb,mask)			\ | 
|  | 81 | OCFS2_SB(sb)->s_feature_compat |= (mask) | 
|  | 82 | #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask)			\ | 
|  | 83 | OCFS2_SB(sb)->s_feature_ro_compat |= (mask) | 
|  | 84 | #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask)			\ | 
|  | 85 | OCFS2_SB(sb)->s_feature_incompat |= (mask) | 
|  | 86 | #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask)			\ | 
|  | 87 | OCFS2_SB(sb)->s_feature_compat &= ~(mask) | 
|  | 88 | #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask)			\ | 
|  | 89 | OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask) | 
|  | 90 | #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask)			\ | 
|  | 91 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) | 
|  | 92 |  | 
| Joel Becker | a977218 | 2008-12-16 18:10:18 -0800 | [diff] [blame] | 93 | #define OCFS2_FEATURE_COMPAT_SUPP	(OCFS2_FEATURE_COMPAT_BACKUP_SB	\ | 
|  | 94 | | OCFS2_FEATURE_COMPAT_JBD2_SB) | 
| Mark Fasheh | dcd0538 | 2007-01-16 11:32:23 -0800 | [diff] [blame] | 95 | #define OCFS2_FEATURE_INCOMPAT_SUPP	(OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \ | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 96 | | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \ | 
| Joel Becker | 386a2ef | 2008-02-01 12:06:54 -0800 | [diff] [blame] | 97 | | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \ | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 98 | | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ | 
| Tiger Yang | 8154da3 | 2008-08-18 17:11:46 +0800 | [diff] [blame] | 99 | | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \ | 
| Joel Becker | 9d28cfb | 2008-10-16 17:53:29 -0700 | [diff] [blame] | 100 | | OCFS2_FEATURE_INCOMPAT_XATTR \ | 
| Mark Fasheh | 3a8df2b | 2008-11-24 17:14:09 -0800 | [diff] [blame] | 101 | | OCFS2_FEATURE_INCOMPAT_META_ECC \ | 
| Tao Ma | 64871b8 | 2009-08-18 11:48:02 +0800 | [diff] [blame] | 102 | | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \ | 
|  | 103 | | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE) | 
| Jan Kara | 19ece54 | 2008-08-21 20:13:17 +0200 | [diff] [blame] | 104 | #define OCFS2_FEATURE_RO_COMPAT_SUPP	(OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ | 
|  | 105 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | 
|  | 106 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 107 |  | 
|  | 108 | /* | 
|  | 109 | * Heartbeat-only devices are missing journals and other files.  The | 
|  | 110 | * filesystem driver can't load them, but the library can.  Never put | 
|  | 111 | * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*. | 
|  | 112 | */ | 
|  | 113 | #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV	0x0002 | 
|  | 114 |  | 
| Mark Fasheh | 8903901 | 2006-12-07 18:05:37 -0800 | [diff] [blame] | 115 | /* | 
|  | 116 | * tunefs sets this incompat flag before starting the resize and clears it | 
|  | 117 | * at the end. This flag protects users from inadvertently mounting the fs | 
|  | 118 | * after an aborted run without fsck-ing. | 
|  | 119 | */ | 
|  | 120 | #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG    0x0004 | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 121 |  | 
| Sunil Mushran | c271c5c | 2006-12-05 17:56:35 -0800 | [diff] [blame] | 122 | /* Used to denote a non-clustered volume */ | 
|  | 123 | #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT	0x0008 | 
|  | 124 |  | 
| Mark Fasheh | 8903901 | 2006-12-07 18:05:37 -0800 | [diff] [blame] | 125 | /* Support for sparse allocation in b-trees */ | 
|  | 126 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC	0x0010 | 
|  | 127 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 128 | /* | 
| Mark Fasheh | 92e91ce | 2007-09-20 11:19:20 -0700 | [diff] [blame] | 129 | * Tunefs sets this incompat flag before starting an operation which | 
|  | 130 | * would require cleanup on abort. This is done to protect users from | 
|  | 131 | * inadvertently mounting the fs after an aborted run without | 
|  | 132 | * fsck-ing. | 
|  | 133 | * | 
|  | 134 | * s_tunefs_flags on the super block describes precisely which | 
|  | 135 | * operations were in progress. | 
|  | 136 | */ | 
|  | 137 | #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG	0x0020 | 
|  | 138 |  | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 139 | /* Support for data packed into inode blocks */ | 
|  | 140 | #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA	0x0040 | 
|  | 141 |  | 
| Mark Fasheh | 92e91ce | 2007-09-20 11:19:20 -0700 | [diff] [blame] | 142 | /* | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 143 | * Support for alternate, userspace cluster stacks.  If set, the superblock | 
|  | 144 | * field s_cluster_info contains a tag for the alternate stack in use as | 
|  | 145 | * well as the name of the cluster being joined. | 
|  | 146 | * mount.ocfs2 must pass in a matching stack name. | 
|  | 147 | * | 
|  | 148 | * If not set, the classic stack will be used.  This is compatbile with | 
|  | 149 | * all older versions. | 
|  | 150 | */ | 
|  | 151 | #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK	0x0080 | 
|  | 152 |  | 
| Tiger Yang | 8154da3 | 2008-08-18 17:11:46 +0800 | [diff] [blame] | 153 | /* Support for the extended slot map */ | 
|  | 154 | #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100 | 
|  | 155 |  | 
|  | 156 | /* Support for extended attributes */ | 
|  | 157 | #define OCFS2_FEATURE_INCOMPAT_XATTR		0x0200 | 
|  | 158 |  | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 159 | /* Support for indexed directores */ | 
|  | 160 | #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS	0x0400 | 
|  | 161 |  | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 162 | /* Metadata checksum and error correction */ | 
|  | 163 | #define OCFS2_FEATURE_INCOMPAT_META_ECC		0x0800 | 
|  | 164 |  | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 165 | /* Refcount tree support */ | 
|  | 166 | #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE	0x1000 | 
|  | 167 |  | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 168 | /* | 
| Mark Fasheh | 50af94b | 2007-01-21 14:44:59 -0800 | [diff] [blame] | 169 | * backup superblock flag is used to indicate that this volume | 
|  | 170 | * has backup superblocks. | 
|  | 171 | */ | 
|  | 172 | #define OCFS2_FEATURE_COMPAT_BACKUP_SB		0x0001 | 
|  | 173 |  | 
| Mark Fasheh | 328d575 | 2007-06-18 10:48:04 -0700 | [diff] [blame] | 174 | /* | 
| Joel Becker | a977218 | 2008-12-16 18:10:18 -0800 | [diff] [blame] | 175 | * The filesystem will correctly handle journal feature bits. | 
|  | 176 | */ | 
|  | 177 | #define OCFS2_FEATURE_COMPAT_JBD2_SB		0x0002 | 
|  | 178 |  | 
|  | 179 | /* | 
| Mark Fasheh | 328d575 | 2007-06-18 10:48:04 -0700 | [diff] [blame] | 180 | * Unwritten extents support. | 
|  | 181 | */ | 
|  | 182 | #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN	0x0001 | 
|  | 183 |  | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 184 | /* | 
|  | 185 | * Maintain quota information for this filesystem | 
|  | 186 | */ | 
|  | 187 | #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA	0x0002 | 
|  | 188 | #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA	0x0004 | 
|  | 189 |  | 
| Mark Fasheh | 50af94b | 2007-01-21 14:44:59 -0800 | [diff] [blame] | 190 | /* The byte offset of the first backup block will be 1G. | 
|  | 191 | * The following will be 4G, 16G, 64G, 256G and 1T. | 
|  | 192 | */ | 
|  | 193 | #define OCFS2_BACKUP_SB_START			1 << 30 | 
|  | 194 |  | 
|  | 195 | /* the max backup superblock nums */ | 
|  | 196 | #define OCFS2_MAX_BACKUP_SUPERBLOCKS	6 | 
|  | 197 |  | 
|  | 198 | /* | 
| Mark Fasheh | 92e91ce | 2007-09-20 11:19:20 -0700 | [diff] [blame] | 199 | * Flags on ocfs2_super_block.s_tunefs_flags | 
|  | 200 | */ | 
|  | 201 | #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT		0x0001	/* Removing slots */ | 
|  | 202 |  | 
|  | 203 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 204 | * Flags on ocfs2_dinode.i_flags | 
|  | 205 | */ | 
|  | 206 | #define OCFS2_VALID_FL		(0x00000001)	/* Inode is valid */ | 
|  | 207 | #define OCFS2_UNUSED2_FL	(0x00000002) | 
|  | 208 | #define OCFS2_ORPHANED_FL	(0x00000004)	/* On the orphan list */ | 
|  | 209 | #define OCFS2_UNUSED3_FL	(0x00000008) | 
|  | 210 | /* System inode flags */ | 
|  | 211 | #define OCFS2_SYSTEM_FL		(0x00000010)	/* System inode */ | 
|  | 212 | #define OCFS2_SUPER_BLOCK_FL	(0x00000020)	/* Super block */ | 
|  | 213 | #define OCFS2_LOCAL_ALLOC_FL	(0x00000040)	/* Slot local alloc bitmap */ | 
|  | 214 | #define OCFS2_BITMAP_FL		(0x00000080)	/* Allocation bitmap */ | 
|  | 215 | #define OCFS2_JOURNAL_FL	(0x00000100)	/* Slot local journal */ | 
|  | 216 | #define OCFS2_HEARTBEAT_FL	(0x00000200)	/* Heartbeat area */ | 
|  | 217 | #define OCFS2_CHAIN_FL		(0x00000400)	/* Chain allocator */ | 
|  | 218 | #define OCFS2_DEALLOC_FL	(0x00000800)	/* Truncate log */ | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 219 | #define OCFS2_QUOTA_FL		(0x00001000)	/* Quota file */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 220 |  | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 221 | /* | 
|  | 222 | * Flags on ocfs2_dinode.i_dyn_features | 
|  | 223 | * | 
|  | 224 | * These can change much more often than i_flags. When adding flags, | 
|  | 225 | * keep in mind that i_dyn_features is only 16 bits wide. | 
|  | 226 | */ | 
|  | 227 | #define OCFS2_INLINE_DATA_FL	(0x0001)	/* Data stored in inode block */ | 
|  | 228 | #define OCFS2_HAS_XATTR_FL	(0x0002) | 
|  | 229 | #define OCFS2_INLINE_XATTR_FL	(0x0004) | 
|  | 230 | #define OCFS2_INDEXED_DIR_FL	(0x0008) | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 231 | #define OCFS2_HAS_REFCOUNT_FL   (0x0010) | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 232 |  | 
| Herbert Poetzl | ca4d147 | 2006-07-03 17:27:12 -0700 | [diff] [blame] | 233 | /* Inode attributes, keep in sync with EXT2 */ | 
|  | 234 | #define OCFS2_SECRM_FL		(0x00000001)	/* Secure deletion */ | 
|  | 235 | #define OCFS2_UNRM_FL		(0x00000002)	/* Undelete */ | 
|  | 236 | #define OCFS2_COMPR_FL		(0x00000004)	/* Compress file */ | 
|  | 237 | #define OCFS2_SYNC_FL		(0x00000008)	/* Synchronous updates */ | 
|  | 238 | #define OCFS2_IMMUTABLE_FL	(0x00000010)	/* Immutable file */ | 
|  | 239 | #define OCFS2_APPEND_FL		(0x00000020)	/* writes to file may only append */ | 
|  | 240 | #define OCFS2_NODUMP_FL		(0x00000040)	/* do not dump file */ | 
|  | 241 | #define OCFS2_NOATIME_FL	(0x00000080)	/* do not update atime */ | 
|  | 242 | #define OCFS2_DIRSYNC_FL	(0x00010000)	/* dirsync behaviour (directories only) */ | 
|  | 243 |  | 
|  | 244 | #define OCFS2_FL_VISIBLE	(0x000100FF)	/* User visible flags */ | 
|  | 245 | #define OCFS2_FL_MODIFIABLE	(0x000100FF)	/* User modifiable flags */ | 
|  | 246 |  | 
|  | 247 | /* | 
| Mark Fasheh | e48edee | 2007-03-07 16:46:57 -0800 | [diff] [blame] | 248 | * Extent record flags (e_node.leaf.flags) | 
|  | 249 | */ | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 250 | #define OCFS2_EXT_UNWRITTEN		(0x01)	/* Extent is allocated but | 
|  | 251 | * unwritten */ | 
|  | 252 | #define OCFS2_EXT_REFCOUNTED		(0x02)  /* Extent is reference | 
|  | 253 | * counted in an associated | 
|  | 254 | * refcount tree */ | 
| Mark Fasheh | e48edee | 2007-03-07 16:46:57 -0800 | [diff] [blame] | 255 |  | 
|  | 256 | /* | 
| Herbert Poetzl | ca4d147 | 2006-07-03 17:27:12 -0700 | [diff] [blame] | 257 | * ioctl commands | 
|  | 258 | */ | 
|  | 259 | #define OCFS2_IOC_GETFLAGS	_IOR('f', 1, long) | 
|  | 260 | #define OCFS2_IOC_SETFLAGS	_IOW('f', 2, long) | 
| Mark Fasheh | 586d232 | 2007-03-09 15:56:28 -0800 | [diff] [blame] | 261 | #define OCFS2_IOC32_GETFLAGS	_IOR('f', 1, int) | 
|  | 262 | #define OCFS2_IOC32_SETFLAGS	_IOW('f', 2, int) | 
| Herbert Poetzl | ca4d147 | 2006-07-03 17:27:12 -0700 | [diff] [blame] | 263 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 264 | /* | 
| Mark Fasheh | b258010 | 2007-03-09 16:53:21 -0800 | [diff] [blame] | 265 | * Space reservation / allocation / free ioctls and argument structure | 
|  | 266 | * are designed to be compatible with XFS. | 
|  | 267 | * | 
|  | 268 | * ALLOCSP* and FREESP* are not and will never be supported, but are | 
|  | 269 | * included here for completeness. | 
|  | 270 | */ | 
|  | 271 | struct ocfs2_space_resv { | 
|  | 272 | __s16		l_type; | 
|  | 273 | __s16		l_whence; | 
|  | 274 | __s64		l_start; | 
|  | 275 | __s64		l_len;		/* len == 0 means until end of file */ | 
|  | 276 | __s32		l_sysid; | 
|  | 277 | __u32		l_pid; | 
|  | 278 | __s32		l_pad[4];	/* reserve area			    */ | 
|  | 279 | }; | 
|  | 280 |  | 
|  | 281 | #define OCFS2_IOC_ALLOCSP		_IOW ('X', 10, struct ocfs2_space_resv) | 
|  | 282 | #define OCFS2_IOC_FREESP		_IOW ('X', 11, struct ocfs2_space_resv) | 
|  | 283 | #define OCFS2_IOC_RESVSP		_IOW ('X', 40, struct ocfs2_space_resv) | 
|  | 284 | #define OCFS2_IOC_UNRESVSP	_IOW ('X', 41, struct ocfs2_space_resv) | 
|  | 285 | #define OCFS2_IOC_ALLOCSP64	_IOW ('X', 36, struct ocfs2_space_resv) | 
|  | 286 | #define OCFS2_IOC_FREESP64	_IOW ('X', 37, struct ocfs2_space_resv) | 
|  | 287 | #define OCFS2_IOC_RESVSP64	_IOW ('X', 42, struct ocfs2_space_resv) | 
|  | 288 | #define OCFS2_IOC_UNRESVSP64	_IOW ('X', 43, struct ocfs2_space_resv) | 
|  | 289 |  | 
| Tao Ma | 7909f2b | 2007-12-18 15:47:25 +0800 | [diff] [blame] | 290 | /* Used to pass group descriptor data when online resize is done */ | 
|  | 291 | struct ocfs2_new_group_input { | 
|  | 292 | __u64 group;		/* Group descriptor's blkno. */ | 
|  | 293 | __u32 clusters;		/* Total number of clusters in this group */ | 
|  | 294 | __u32 frees;		/* Total free clusters in this group */ | 
|  | 295 | __u16 chain;		/* Chain for this group */ | 
|  | 296 | __u16 reserved1; | 
|  | 297 | __u32 reserved2; | 
|  | 298 | }; | 
|  | 299 |  | 
| Tao Ma | d659072 | 2007-12-18 15:47:03 +0800 | [diff] [blame] | 300 | #define OCFS2_IOC_GROUP_EXTEND	_IOW('o', 1, int) | 
| Tao Ma | 7909f2b | 2007-12-18 15:47:25 +0800 | [diff] [blame] | 301 | #define OCFS2_IOC_GROUP_ADD	_IOW('o', 2,struct ocfs2_new_group_input) | 
|  | 302 | #define OCFS2_IOC_GROUP_ADD64	_IOW('o', 3,struct ocfs2_new_group_input) | 
| Tao Ma | d659072 | 2007-12-18 15:47:03 +0800 | [diff] [blame] | 303 |  | 
| Tao Ma | bd50873 | 2009-09-21 11:25:14 +0800 | [diff] [blame] | 304 | /* Used to pass 2 file names to reflink. */ | 
|  | 305 | struct reflink_arguments { | 
|  | 306 | __u64 old_path; | 
|  | 307 | __u64 new_path; | 
|  | 308 | __u64 preserve; | 
|  | 309 | }; | 
|  | 310 | #define OCFS2_IOC_REFLINK	_IOW('o', 4, struct reflink_arguments) | 
|  | 311 |  | 
|  | 312 |  | 
| Mark Fasheh | b258010 | 2007-03-09 16:53:21 -0800 | [diff] [blame] | 313 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 314 | * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) | 
|  | 315 | */ | 
|  | 316 | #define OCFS2_JOURNAL_DIRTY_FL	(0x00000001)	/* Journal needs recovery */ | 
|  | 317 |  | 
|  | 318 | /* | 
|  | 319 | * superblock s_state flags | 
|  | 320 | */ | 
|  | 321 | #define OCFS2_ERROR_FS		(0x00000001)	/* FS saw errors */ | 
|  | 322 |  | 
|  | 323 | /* Limit of space in ocfs2_dir_entry */ | 
|  | 324 | #define OCFS2_MAX_FILENAME_LEN		255 | 
|  | 325 |  | 
|  | 326 | /* Maximum slots on an ocfs2 file system */ | 
|  | 327 | #define OCFS2_MAX_SLOTS			255 | 
|  | 328 |  | 
|  | 329 | /* Slot map indicator for an empty slot */ | 
|  | 330 | #define OCFS2_INVALID_SLOT		-1 | 
|  | 331 |  | 
|  | 332 | #define OCFS2_VOL_UUID_LEN		16 | 
|  | 333 | #define OCFS2_MAX_VOL_LABEL_LEN		64 | 
|  | 334 |  | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 335 | /* The alternate, userspace stack fields */ | 
|  | 336 | #define OCFS2_STACK_LABEL_LEN		4 | 
|  | 337 | #define OCFS2_CLUSTER_NAME_LEN		16 | 
|  | 338 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 339 | /* Journal limits (in bytes) */ | 
|  | 340 | #define OCFS2_MIN_JOURNAL_SIZE		(4 * 1024 * 1024) | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 341 |  | 
| Sunil Mushran | 2fbe8d1 | 2007-12-20 14:58:11 -0800 | [diff] [blame] | 342 | /* | 
|  | 343 | * Default local alloc size (in megabytes) | 
|  | 344 | * | 
|  | 345 | * The value chosen should be such that most allocations, including new | 
|  | 346 | * block groups, use local alloc. | 
|  | 347 | */ | 
|  | 348 | #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE	8 | 
|  | 349 |  | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 350 | /* | 
|  | 351 | * Inline extended attribute size (in bytes) | 
|  | 352 | * The value chosen should be aligned to 16 byte boundaries. | 
|  | 353 | */ | 
|  | 354 | #define OCFS2_MIN_XATTR_INLINE_SIZE     256 | 
|  | 355 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 356 | struct ocfs2_system_inode_info { | 
|  | 357 | char	*si_name; | 
|  | 358 | int	si_iflags; | 
|  | 359 | int	si_mode; | 
|  | 360 | }; | 
|  | 361 |  | 
|  | 362 | /* System file index */ | 
|  | 363 | enum { | 
|  | 364 | BAD_BLOCK_SYSTEM_INODE = 0, | 
|  | 365 | GLOBAL_INODE_ALLOC_SYSTEM_INODE, | 
|  | 366 | SLOT_MAP_SYSTEM_INODE, | 
|  | 367 | #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE | 
|  | 368 | HEARTBEAT_SYSTEM_INODE, | 
|  | 369 | GLOBAL_BITMAP_SYSTEM_INODE, | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 370 | USER_QUOTA_SYSTEM_INODE, | 
|  | 371 | GROUP_QUOTA_SYSTEM_INODE, | 
|  | 372 | #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 373 | ORPHAN_DIR_SYSTEM_INODE, | 
|  | 374 | EXTENT_ALLOC_SYSTEM_INODE, | 
|  | 375 | INODE_ALLOC_SYSTEM_INODE, | 
|  | 376 | JOURNAL_SYSTEM_INODE, | 
|  | 377 | LOCAL_ALLOC_SYSTEM_INODE, | 
|  | 378 | TRUNCATE_LOG_SYSTEM_INODE, | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 379 | LOCAL_USER_QUOTA_SYSTEM_INODE, | 
|  | 380 | LOCAL_GROUP_QUOTA_SYSTEM_INODE, | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 381 | NUM_SYSTEM_INODES | 
|  | 382 | }; | 
|  | 383 |  | 
|  | 384 | static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { | 
|  | 385 | /* Global system inodes (single copy) */ | 
|  | 386 | /* The first two are only used from userspace mfks/tunefs */ | 
|  | 387 | [BAD_BLOCK_SYSTEM_INODE]		= { "bad_blocks", 0, S_IFREG | 0644 }, | 
|  | 388 | [GLOBAL_INODE_ALLOC_SYSTEM_INODE] 	= { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | 
|  | 389 |  | 
|  | 390 | /* These are used by the running filesystem */ | 
|  | 391 | [SLOT_MAP_SYSTEM_INODE]			= { "slot_map", 0, S_IFREG | 0644 }, | 
|  | 392 | [HEARTBEAT_SYSTEM_INODE]		= { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 }, | 
|  | 393 | [GLOBAL_BITMAP_SYSTEM_INODE]		= { "global_bitmap", 0, S_IFREG | 0644 }, | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 394 | [USER_QUOTA_SYSTEM_INODE]		= { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | 
|  | 395 | [GROUP_QUOTA_SYSTEM_INODE]		= { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 396 |  | 
|  | 397 | /* Slot-specific system inodes (one copy per slot) */ | 
|  | 398 | [ORPHAN_DIR_SYSTEM_INODE]		= { "orphan_dir:%04d", 0, S_IFDIR | 0755 }, | 
|  | 399 | [EXTENT_ALLOC_SYSTEM_INODE]		= { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | 
|  | 400 | [INODE_ALLOC_SYSTEM_INODE]		= { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, | 
|  | 401 | [JOURNAL_SYSTEM_INODE]			= { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 }, | 
|  | 402 | [LOCAL_ALLOC_SYSTEM_INODE]		= { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }, | 
| Jan Kara | 1a224ad | 2008-08-20 15:43:36 +0200 | [diff] [blame] | 403 | [TRUNCATE_LOG_SYSTEM_INODE]		= { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }, | 
|  | 404 | [LOCAL_USER_QUOTA_SYSTEM_INODE]		= { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | 
|  | 405 | [LOCAL_GROUP_QUOTA_SYSTEM_INODE]	= { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 }, | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 406 | }; | 
|  | 407 |  | 
|  | 408 | /* Parameter passed from mount.ocfs2 to module */ | 
|  | 409 | #define OCFS2_HB_NONE			"heartbeat=none" | 
|  | 410 | #define OCFS2_HB_LOCAL			"heartbeat=local" | 
|  | 411 |  | 
|  | 412 | /* | 
|  | 413 | * OCFS2 directory file types.  Only the low 3 bits are used.  The | 
|  | 414 | * other bits are reserved for now. | 
|  | 415 | */ | 
|  | 416 | #define OCFS2_FT_UNKNOWN	0 | 
|  | 417 | #define OCFS2_FT_REG_FILE	1 | 
|  | 418 | #define OCFS2_FT_DIR		2 | 
|  | 419 | #define OCFS2_FT_CHRDEV		3 | 
|  | 420 | #define OCFS2_FT_BLKDEV		4 | 
|  | 421 | #define OCFS2_FT_FIFO		5 | 
|  | 422 | #define OCFS2_FT_SOCK		6 | 
|  | 423 | #define OCFS2_FT_SYMLINK	7 | 
|  | 424 |  | 
|  | 425 | #define OCFS2_FT_MAX		8 | 
|  | 426 |  | 
|  | 427 | /* | 
|  | 428 | * OCFS2_DIR_PAD defines the directory entries boundaries | 
|  | 429 | * | 
|  | 430 | * NOTE: It must be a multiple of 4 | 
|  | 431 | */ | 
|  | 432 | #define OCFS2_DIR_PAD			4 | 
|  | 433 | #define OCFS2_DIR_ROUND			(OCFS2_DIR_PAD - 1) | 
|  | 434 | #define OCFS2_DIR_MEMBER_LEN 		offsetof(struct ocfs2_dir_entry, name) | 
|  | 435 | #define OCFS2_DIR_REC_LEN(name_len)	(((name_len) + OCFS2_DIR_MEMBER_LEN + \ | 
|  | 436 | OCFS2_DIR_ROUND) & \ | 
|  | 437 | ~OCFS2_DIR_ROUND) | 
| Mark Fasheh | e7c17e4 | 2009-01-29 18:17:46 -0800 | [diff] [blame] | 438 | #define OCFS2_DIR_MIN_REC_LEN	OCFS2_DIR_REC_LEN(1) | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 439 |  | 
|  | 440 | #define OCFS2_LINK_MAX		32000 | 
| Mark Fasheh | 198a1ca | 2008-11-20 17:54:57 -0800 | [diff] [blame] | 441 | #define	OCFS2_DX_LINK_MAX	((1U << 31) - 1U) | 
|  | 442 | #define	OCFS2_LINKS_HI_SHIFT	16 | 
| Mark Fasheh | e3a93c2 | 2009-02-17 15:29:35 -0800 | [diff] [blame] | 443 | #define	OCFS2_DX_ENTRIES_MAX	(0xffffffffU) | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 444 |  | 
|  | 445 | #define S_SHIFT			12 | 
|  | 446 | static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { | 
|  | 447 | [S_IFREG >> S_SHIFT]  = OCFS2_FT_REG_FILE, | 
|  | 448 | [S_IFDIR >> S_SHIFT]  = OCFS2_FT_DIR, | 
|  | 449 | [S_IFCHR >> S_SHIFT]  = OCFS2_FT_CHRDEV, | 
|  | 450 | [S_IFBLK >> S_SHIFT]  = OCFS2_FT_BLKDEV, | 
|  | 451 | [S_IFIFO >> S_SHIFT]  = OCFS2_FT_FIFO, | 
|  | 452 | [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK, | 
|  | 453 | [S_IFLNK >> S_SHIFT]  = OCFS2_FT_SYMLINK, | 
|  | 454 | }; | 
|  | 455 |  | 
|  | 456 |  | 
|  | 457 | /* | 
|  | 458 | * Convenience casts | 
|  | 459 | */ | 
|  | 460 | #define OCFS2_RAW_SB(dinode)		(&((dinode)->id2.i_super)) | 
|  | 461 |  | 
|  | 462 | /* | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 463 | * Block checking structure.  This is used in metadata to validate the | 
|  | 464 | * contents.  If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all | 
|  | 465 | * zeros. | 
|  | 466 | */ | 
|  | 467 | struct ocfs2_block_check { | 
|  | 468 | /*00*/	__le32 bc_crc32e;	/* 802.3 Ethernet II CRC32 */ | 
|  | 469 | __le16 bc_ecc;		/* Single-error-correction parity vector. | 
|  | 470 | This is a simple Hamming code dependant | 
|  | 471 | on the blocksize.  OCFS2's maximum | 
|  | 472 | blocksize, 4K, requires 16 parity bits, | 
|  | 473 | so we fit in __le16. */ | 
|  | 474 | __le16 bc_reserved1; | 
|  | 475 | /*08*/ | 
|  | 476 | }; | 
|  | 477 |  | 
|  | 478 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 479 | * On disk extent record for OCFS2 | 
|  | 480 | * It describes a range of clusters on disk. | 
| Mark Fasheh | e48edee | 2007-03-07 16:46:57 -0800 | [diff] [blame] | 481 | * | 
|  | 482 | * Length fields are divided into interior and leaf node versions. | 
|  | 483 | * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes. | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 484 | */ | 
|  | 485 | struct ocfs2_extent_rec { | 
|  | 486 | /*00*/	__le32 e_cpos;		/* Offset into the file, in clusters */ | 
| Mark Fasheh | e48edee | 2007-03-07 16:46:57 -0800 | [diff] [blame] | 487 | union { | 
|  | 488 | __le32 e_int_clusters; /* Clusters covered by all children */ | 
|  | 489 | struct { | 
|  | 490 | __le16 e_leaf_clusters; /* Clusters covered by this | 
|  | 491 | extent */ | 
|  | 492 | __u8 e_reserved1; | 
|  | 493 | __u8 e_flags; /* Extent flags */ | 
|  | 494 | }; | 
|  | 495 | }; | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 496 | __le64 e_blkno;		/* Physical disk offset, in blocks */ | 
|  | 497 | /*10*/ | 
|  | 498 | }; | 
|  | 499 |  | 
|  | 500 | struct ocfs2_chain_rec { | 
|  | 501 | __le32 c_free;	/* Number of free bits in this chain. */ | 
|  | 502 | __le32 c_total;	/* Number of total bits in this chain */ | 
|  | 503 | __le64 c_blkno;	/* Physical disk offset (blocks) of 1st group */ | 
|  | 504 | }; | 
|  | 505 |  | 
|  | 506 | struct ocfs2_truncate_rec { | 
|  | 507 | __le32 t_start;		/* 1st cluster in this log */ | 
|  | 508 | __le32 t_clusters;	/* Number of total clusters covered */ | 
|  | 509 | }; | 
|  | 510 |  | 
|  | 511 | /* | 
|  | 512 | * On disk extent list for OCFS2 (node in the tree).  Note that this | 
|  | 513 | * is contained inside ocfs2_dinode or ocfs2_extent_block, so the | 
|  | 514 | * offsets are relative to ocfs2_dinode.id2.i_list or | 
|  | 515 | * ocfs2_extent_block.h_list, respectively. | 
|  | 516 | */ | 
|  | 517 | struct ocfs2_extent_list { | 
|  | 518 | /*00*/	__le16 l_tree_depth;		/* Extent tree depth from this | 
|  | 519 | point.  0 means data extents | 
|  | 520 | hang directly off this | 
| Mark Fasheh | dcd0538 | 2007-01-16 11:32:23 -0800 | [diff] [blame] | 521 | header (a leaf) | 
|  | 522 | NOTE: The high 8 bits cannot be | 
|  | 523 | used - tree_depth is never that big. | 
|  | 524 | */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 525 | __le16 l_count;			/* Number of extent records */ | 
|  | 526 | __le16 l_next_free_rec;		/* Next unused extent slot */ | 
|  | 527 | __le16 l_reserved1; | 
|  | 528 | __le64 l_reserved2;		/* Pad to | 
|  | 529 | sizeof(ocfs2_extent_rec) */ | 
|  | 530 | /*10*/	struct ocfs2_extent_rec l_recs[0];	/* Extent records */ | 
|  | 531 | }; | 
|  | 532 |  | 
|  | 533 | /* | 
|  | 534 | * On disk allocation chain list for OCFS2.  Note that this is | 
|  | 535 | * contained inside ocfs2_dinode, so the offsets are relative to | 
|  | 536 | * ocfs2_dinode.id2.i_chain. | 
|  | 537 | */ | 
|  | 538 | struct ocfs2_chain_list { | 
|  | 539 | /*00*/	__le16 cl_cpg;			/* Clusters per Block Group */ | 
|  | 540 | __le16 cl_bpc;			/* Bits per cluster */ | 
|  | 541 | __le16 cl_count;		/* Total chains in this list */ | 
|  | 542 | __le16 cl_next_free_rec;	/* Next unused chain slot */ | 
|  | 543 | __le64 cl_reserved1; | 
|  | 544 | /*10*/	struct ocfs2_chain_rec cl_recs[0];	/* Chain records */ | 
|  | 545 | }; | 
|  | 546 |  | 
|  | 547 | /* | 
|  | 548 | * On disk deallocation log for OCFS2.  Note that this is | 
|  | 549 | * contained inside ocfs2_dinode, so the offsets are relative to | 
|  | 550 | * ocfs2_dinode.id2.i_dealloc. | 
|  | 551 | */ | 
|  | 552 | struct ocfs2_truncate_log { | 
|  | 553 | /*00*/	__le16 tl_count;		/* Total records in this log */ | 
|  | 554 | __le16 tl_used;			/* Number of records in use */ | 
|  | 555 | __le32 tl_reserved1; | 
|  | 556 | /*08*/	struct ocfs2_truncate_rec tl_recs[0];	/* Truncate records */ | 
|  | 557 | }; | 
|  | 558 |  | 
|  | 559 | /* | 
|  | 560 | * On disk extent block (indirect block) for OCFS2 | 
|  | 561 | */ | 
|  | 562 | struct ocfs2_extent_block | 
|  | 563 | { | 
|  | 564 | /*00*/	__u8 h_signature[8];		/* Signature for verification */ | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 565 | struct ocfs2_block_check h_check;	/* Error checking */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 566 | /*10*/	__le16 h_suballoc_slot;		/* Slot suballocator this | 
|  | 567 | extent_header belongs to */ | 
|  | 568 | __le16 h_suballoc_bit;		/* Bit offset in suballocator | 
|  | 569 | block group */ | 
|  | 570 | __le32 h_fs_generation;		/* Must match super block */ | 
|  | 571 | __le64 h_blkno;			/* Offset on disk, in blocks */ | 
|  | 572 | /*20*/	__le64 h_reserved3; | 
|  | 573 | __le64 h_next_leaf_blk;		/* Offset on disk, in blocks, | 
|  | 574 | of next leaf header pointing | 
|  | 575 | to data */ | 
|  | 576 | /*30*/	struct ocfs2_extent_list h_list;	/* Extent record list */ | 
|  | 577 | /* Actual on-disk size is one block */ | 
|  | 578 | }; | 
|  | 579 |  | 
|  | 580 | /* | 
| Joel Becker | fb86b1f | 2008-02-01 11:59:05 -0800 | [diff] [blame] | 581 | * On disk slot map for OCFS2.  This defines the contents of the "slot_map" | 
| Joel Becker | 386a2ef | 2008-02-01 12:06:54 -0800 | [diff] [blame] | 582 | * system file.  A slot is valid if it contains a node number >= 0.  The | 
|  | 583 | * value -1 (0xFFFF) is OCFS2_INVALID_SLOT.  This marks a slot empty. | 
| Joel Becker | fb86b1f | 2008-02-01 11:59:05 -0800 | [diff] [blame] | 584 | */ | 
|  | 585 | struct ocfs2_slot_map { | 
|  | 586 | /*00*/	__le16 sm_slots[0]; | 
|  | 587 | /* | 
|  | 588 | * Actual on-disk size is one block.  OCFS2_MAX_SLOTS is 255, | 
|  | 589 | * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize. | 
|  | 590 | */ | 
|  | 591 | }; | 
|  | 592 |  | 
| Joel Becker | 386a2ef | 2008-02-01 12:06:54 -0800 | [diff] [blame] | 593 | struct ocfs2_extended_slot { | 
|  | 594 | /*00*/	__u8	es_valid; | 
|  | 595 | __u8	es_reserved1[3]; | 
|  | 596 | __le32	es_node_num; | 
|  | 597 | /*10*/ | 
|  | 598 | }; | 
|  | 599 |  | 
|  | 600 | /* | 
|  | 601 | * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP | 
|  | 602 | * is set.  It separates out the valid marker from the node number, and | 
|  | 603 | * has room to grow.  Unlike the old slot map, this format is defined by | 
|  | 604 | * i_size. | 
|  | 605 | */ | 
|  | 606 | struct ocfs2_slot_map_extended { | 
|  | 607 | /*00*/	struct ocfs2_extended_slot se_slots[0]; | 
|  | 608 | /* | 
|  | 609 | * Actual size is i_size of the slot_map system file.  It should | 
|  | 610 | * match s_max_slots * sizeof(struct ocfs2_extended_slot) | 
|  | 611 | */ | 
|  | 612 | }; | 
|  | 613 |  | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 614 | struct ocfs2_cluster_info { | 
|  | 615 | /*00*/	__u8   ci_stack[OCFS2_STACK_LABEL_LEN]; | 
|  | 616 | __le32 ci_reserved; | 
|  | 617 | /*08*/	__u8   ci_cluster[OCFS2_CLUSTER_NAME_LEN]; | 
|  | 618 | /*18*/ | 
|  | 619 | }; | 
|  | 620 |  | 
| Joel Becker | fb86b1f | 2008-02-01 11:59:05 -0800 | [diff] [blame] | 621 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 622 | * On disk superblock for OCFS2 | 
|  | 623 | * Note that it is contained inside an ocfs2_dinode, so all offsets | 
|  | 624 | * are relative to the start of ocfs2_dinode.id2. | 
|  | 625 | */ | 
|  | 626 | struct ocfs2_super_block { | 
|  | 627 | /*00*/	__le16 s_major_rev_level; | 
|  | 628 | __le16 s_minor_rev_level; | 
|  | 629 | __le16 s_mnt_count; | 
|  | 630 | __le16 s_max_mnt_count; | 
|  | 631 | __le16 s_state;			/* File system state */ | 
|  | 632 | __le16 s_errors;			/* Behaviour when detecting errors */ | 
|  | 633 | __le32 s_checkinterval;		/* Max time between checks */ | 
|  | 634 | /*10*/	__le64 s_lastcheck;		/* Time of last check */ | 
|  | 635 | __le32 s_creator_os;		/* OS */ | 
|  | 636 | __le32 s_feature_compat;		/* Compatible feature set */ | 
|  | 637 | /*20*/	__le32 s_feature_incompat;	/* Incompatible feature set */ | 
|  | 638 | __le32 s_feature_ro_compat;	/* Readonly-compatible feature set */ | 
|  | 639 | __le64 s_root_blkno;		/* Offset, in blocks, of root directory | 
|  | 640 | dinode */ | 
|  | 641 | /*30*/	__le64 s_system_dir_blkno;	/* Offset, in blocks, of system | 
|  | 642 | directory dinode */ | 
|  | 643 | __le32 s_blocksize_bits;		/* Blocksize for this fs */ | 
|  | 644 | __le32 s_clustersize_bits;	/* Clustersize for this fs */ | 
|  | 645 | /*40*/	__le16 s_max_slots;		/* Max number of simultaneous mounts | 
|  | 646 | before tunefs required */ | 
| Mark Fasheh | 92e91ce | 2007-09-20 11:19:20 -0700 | [diff] [blame] | 647 | __le16 s_tunefs_flag; | 
| Tiger Yang | cf1d6c7 | 2008-08-18 17:11:00 +0800 | [diff] [blame] | 648 | __le32 s_uuid_hash;		/* hash value of uuid */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 649 | __le64 s_first_cluster_group;	/* Block offset of 1st cluster | 
|  | 650 | * group header */ | 
|  | 651 | /*50*/	__u8  s_label[OCFS2_MAX_VOL_LABEL_LEN];	/* Label for mounting, etc. */ | 
|  | 652 | /*90*/	__u8  s_uuid[OCFS2_VOL_UUID_LEN];	/* 128-bit uuid */ | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 653 | /*A0*/  struct ocfs2_cluster_info s_cluster_info; /* Selected userspace | 
|  | 654 | stack.  Only valid | 
|  | 655 | with INCOMPAT flag. */ | 
| Tiger Yang | 8154da3 | 2008-08-18 17:11:46 +0800 | [diff] [blame] | 656 | /*B8*/	__le16 s_xattr_inline_size;	/* extended attribute inline size | 
|  | 657 | for this fs*/ | 
|  | 658 | __le16 s_reserved0; | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 659 | __le32 s_dx_seed[3];		/* seed[0-2] for dx dir hash. | 
|  | 660 | * s_uuid_hash serves as seed[3]. */ | 
|  | 661 | /*C0*/  __le64 s_reserved2[15];		/* Fill out superblock */ | 
| Joel Becker | b61817e | 2008-02-01 15:08:23 -0800 | [diff] [blame] | 662 | /*140*/ | 
|  | 663 |  | 
|  | 664 | /* | 
|  | 665 | * NOTE: As stated above, all offsets are relative to | 
|  | 666 | * ocfs2_dinode.id2, which is at 0xC0 in the inode. | 
|  | 667 | * 0xC0 + 0x140 = 0x200 or 512 bytes.  A superblock must fit within | 
|  | 668 | * our smallest blocksize, which is 512 bytes.  To ensure this, | 
|  | 669 | * we reserve the space in s_reserved2.  Anything past s_reserved2 | 
|  | 670 | * will not be available on the smallest blocksize. | 
|  | 671 | */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 672 | }; | 
|  | 673 |  | 
|  | 674 | /* | 
|  | 675 | * Local allocation bitmap for OCFS2 slots | 
|  | 676 | * Note that it exists inside an ocfs2_dinode, so all offsets are | 
|  | 677 | * relative to the start of ocfs2_dinode.id2. | 
|  | 678 | */ | 
|  | 679 | struct ocfs2_local_alloc | 
|  | 680 | { | 
|  | 681 | /*00*/	__le32 la_bm_off;	/* Starting bit offset in main bitmap */ | 
|  | 682 | __le16 la_size;		/* Size of included bitmap, in bytes */ | 
|  | 683 | __le16 la_reserved1; | 
|  | 684 | __le64 la_reserved2; | 
|  | 685 | /*10*/	__u8   la_bitmap[0]; | 
|  | 686 | }; | 
|  | 687 |  | 
|  | 688 | /* | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 689 | * Data-in-inode header. This is only used if i_dyn_features has | 
|  | 690 | * OCFS2_INLINE_DATA_FL set. | 
|  | 691 | */ | 
|  | 692 | struct ocfs2_inline_data | 
|  | 693 | { | 
|  | 694 | /*00*/	__le16	id_count;	/* Number of bytes that can be used | 
|  | 695 | * for data, starting at id_data */ | 
|  | 696 | __le16	id_reserved0; | 
|  | 697 | __le32	id_reserved1; | 
|  | 698 | __u8	id_data[0];	/* Start of user data */ | 
|  | 699 | }; | 
|  | 700 |  | 
|  | 701 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 702 | * On disk inode for OCFS2 | 
|  | 703 | */ | 
|  | 704 | struct ocfs2_dinode { | 
|  | 705 | /*00*/	__u8 i_signature[8];		/* Signature for validation */ | 
|  | 706 | __le32 i_generation;		/* Generation number */ | 
|  | 707 | __le16 i_suballoc_slot;		/* Slot suballocator this inode | 
|  | 708 | belongs to */ | 
|  | 709 | __le16 i_suballoc_bit;		/* Bit offset in suballocator | 
|  | 710 | block group */ | 
| Mark Fasheh | 198a1ca | 2008-11-20 17:54:57 -0800 | [diff] [blame] | 711 | /*10*/	__le16 i_links_count_hi;	/* High 16 bits of links count */ | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 712 | __le16 i_xattr_inline_size; | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 713 | __le32 i_clusters;		/* Cluster count */ | 
|  | 714 | __le32 i_uid;			/* Owner UID */ | 
|  | 715 | __le32 i_gid;			/* Owning GID */ | 
|  | 716 | /*20*/	__le64 i_size;			/* Size in bytes */ | 
|  | 717 | __le16 i_mode;			/* File mode */ | 
|  | 718 | __le16 i_links_count;		/* Links count */ | 
|  | 719 | __le32 i_flags;			/* File flags */ | 
|  | 720 | /*30*/	__le64 i_atime;			/* Access time */ | 
|  | 721 | __le64 i_ctime;			/* Creation time */ | 
|  | 722 | /*40*/	__le64 i_mtime;			/* Modification time */ | 
|  | 723 | __le64 i_dtime;			/* Deletion time */ | 
|  | 724 | /*50*/	__le64 i_blkno;			/* Offset on disk, in blocks */ | 
|  | 725 | __le64 i_last_eb_blk;		/* Pointer to last extent | 
|  | 726 | block */ | 
|  | 727 | /*60*/	__le32 i_fs_generation;		/* Generation per fs-instance */ | 
|  | 728 | __le32 i_atime_nsec; | 
|  | 729 | __le32 i_ctime_nsec; | 
|  | 730 | __le32 i_mtime_nsec; | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 731 | /*70*/	__le32 i_attr; | 
| Tiger Yang | 5000863 | 2007-03-20 16:01:38 -0700 | [diff] [blame] | 732 | __le16 i_orphaned_slot;		/* Only valid when OCFS2_ORPHANED_FL | 
|  | 733 | was set in i_flags */ | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 734 | __le16 i_dyn_features; | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 735 | __le64 i_xattr_loc; | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 736 | /*80*/	struct ocfs2_block_check i_check;	/* Error checking */ | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 737 | /*88*/	__le64 i_dx_root;		/* Pointer to dir index root block */ | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 738 | /*90*/	__le64 i_refcount_loc; | 
|  | 739 | __le64 i_reserved2[4]; | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 740 | /*B8*/	union { | 
|  | 741 | __le64 i_pad1;		/* Generic way to refer to this | 
|  | 742 | 64bit union */ | 
|  | 743 | struct { | 
|  | 744 | __le64 i_rdev;	/* Device number */ | 
|  | 745 | } dev1; | 
|  | 746 | struct {		/* Info for bitmap system | 
|  | 747 | inodes */ | 
|  | 748 | __le32 i_used;	/* Bits (ie, clusters) used  */ | 
|  | 749 | __le32 i_total;	/* Total bits (clusters) | 
|  | 750 | available */ | 
|  | 751 | } bitmap1; | 
|  | 752 | struct {		/* Info for journal system | 
|  | 753 | inodes */ | 
|  | 754 | __le32 ij_flags;	/* Mounted, version, etc. */ | 
| Sunil Mushran | c69991a | 2008-07-14 17:31:09 -0700 | [diff] [blame] | 755 | __le32 ij_recovery_generation; /* Incremented when the | 
|  | 756 | journal is recovered | 
|  | 757 | after an unclean | 
|  | 758 | shutdown */ | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 759 | } journal1; | 
|  | 760 | } id1;				/* Inode type dependant 1 */ | 
|  | 761 | /*C0*/	union { | 
|  | 762 | struct ocfs2_super_block	i_super; | 
|  | 763 | struct ocfs2_local_alloc	i_lab; | 
|  | 764 | struct ocfs2_chain_list		i_chain; | 
|  | 765 | struct ocfs2_extent_list	i_list; | 
|  | 766 | struct ocfs2_truncate_log	i_dealloc; | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 767 | struct ocfs2_inline_data	i_data; | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 768 | __u8               		i_symlink[0]; | 
|  | 769 | } id2; | 
|  | 770 | /* Actual on-disk size is one block */ | 
|  | 771 | }; | 
|  | 772 |  | 
|  | 773 | /* | 
|  | 774 | * On-disk directory entry structure for OCFS2 | 
|  | 775 | * | 
|  | 776 | * Packed as this structure could be accessed unaligned on 64-bit platforms | 
|  | 777 | */ | 
|  | 778 | struct ocfs2_dir_entry { | 
|  | 779 | /*00*/	__le64   inode;                  /* Inode number */ | 
|  | 780 | __le16   rec_len;                /* Directory entry length */ | 
|  | 781 | __u8    name_len;               /* Name length */ | 
|  | 782 | __u8    file_type; | 
|  | 783 | /*0C*/	char    name[OCFS2_MAX_FILENAME_LEN];   /* File name */ | 
|  | 784 | /* Actual on-disk length specified by rec_len */ | 
|  | 785 | } __attribute__ ((packed)); | 
|  | 786 |  | 
|  | 787 | /* | 
| Mark Fasheh | 87d35a7 | 2008-12-10 17:36:25 -0800 | [diff] [blame] | 788 | * Per-block record for the unindexed directory btree. This is carefully | 
|  | 789 | * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are | 
|  | 790 | * mirrored. That way, the directory manipulation code needs a minimal amount | 
|  | 791 | * of update. | 
|  | 792 | * | 
|  | 793 | * NOTE: Keep this structure aligned to a multiple of 4 bytes. | 
|  | 794 | */ | 
|  | 795 | struct ocfs2_dir_block_trailer { | 
|  | 796 | /*00*/	__le64		db_compat_inode;	/* Always zero. Was inode */ | 
|  | 797 |  | 
|  | 798 | __le16		db_compat_rec_len;	/* Backwards compatible with | 
|  | 799 | * ocfs2_dir_entry. */ | 
|  | 800 | __u8		db_compat_name_len;	/* Always zero. Was name_len */ | 
|  | 801 | __u8		db_reserved0; | 
|  | 802 | __le16		db_reserved1; | 
|  | 803 | __le16		db_free_rec_len;	/* Size of largest empty hole | 
|  | 804 | * in this block. (unused) */ | 
|  | 805 | /*10*/	__u8		db_signature[8];	/* Signature for verification */ | 
|  | 806 | __le64		db_reserved2; | 
|  | 807 | __le64		db_free_next;		/* Next block in list (unused) */ | 
|  | 808 | /*20*/	__le64		db_blkno;		/* Offset on disk, in blocks */ | 
|  | 809 | __le64		db_parent_dinode;	/* dinode which owns me, in | 
|  | 810 | blocks */ | 
| Joel Becker | c175a51 | 2008-12-10 17:58:22 -0800 | [diff] [blame] | 811 | /*30*/	struct ocfs2_block_check db_check;	/* Error checking */ | 
| Mark Fasheh | 87d35a7 | 2008-12-10 17:36:25 -0800 | [diff] [blame] | 812 | /*40*/ | 
|  | 813 | }; | 
|  | 814 |  | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 815 | /* | 
|  | 816 | * A directory entry in the indexed tree. We don't store the full name here, | 
|  | 817 | * but instead provide a pointer to the full dirent in the unindexed tree. | 
|  | 818 | * | 
|  | 819 | * We also store name_len here so as to reduce the number of leaf blocks we | 
|  | 820 | * need to search in case of collisions. | 
|  | 821 | */ | 
|  | 822 | struct ocfs2_dx_entry { | 
|  | 823 | __le32		dx_major_hash;	/* Used to find logical | 
|  | 824 | * cluster in index */ | 
|  | 825 | __le32		dx_minor_hash;	/* Lower bits used to find | 
|  | 826 | * block in cluster */ | 
|  | 827 | __le64		dx_dirent_blk;	/* Physical block in unindexed | 
|  | 828 | * tree holding this dirent. */ | 
|  | 829 | }; | 
|  | 830 |  | 
|  | 831 | struct ocfs2_dx_entry_list { | 
|  | 832 | __le32		de_reserved; | 
|  | 833 | __le16		de_count;	/* Maximum number of entries | 
|  | 834 | * possible in de_entries */ | 
|  | 835 | __le16		de_num_used;	/* Current number of | 
|  | 836 | * de_entries entries */ | 
|  | 837 | struct	ocfs2_dx_entry		de_entries[0];	/* Indexed dir entries | 
|  | 838 | * in a packed array of | 
|  | 839 | * length de_num_used */ | 
|  | 840 | }; | 
|  | 841 |  | 
| Mark Fasheh | 4ed8a6b | 2008-11-24 17:02:08 -0800 | [diff] [blame] | 842 | #define OCFS2_DX_FLAG_INLINE	0x01 | 
|  | 843 |  | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 844 | /* | 
|  | 845 | * A directory indexing block. Each indexed directory has one of these, | 
|  | 846 | * pointed to by ocfs2_dinode. | 
|  | 847 | * | 
|  | 848 | * This block stores an indexed btree root, and a set of free space | 
|  | 849 | * start-of-list pointers. | 
|  | 850 | */ | 
|  | 851 | struct ocfs2_dx_root_block { | 
|  | 852 | __u8		dr_signature[8];	/* Signature for verification */ | 
|  | 853 | struct ocfs2_block_check dr_check;	/* Error checking */ | 
|  | 854 | __le16		dr_suballoc_slot;	/* Slot suballocator this | 
|  | 855 | * block belongs to. */ | 
|  | 856 | __le16		dr_suballoc_bit;	/* Bit offset in suballocator | 
|  | 857 | * block group */ | 
|  | 858 | __le32		dr_fs_generation;	/* Must match super block */ | 
|  | 859 | __le64		dr_blkno;		/* Offset on disk, in blocks */ | 
|  | 860 | __le64		dr_last_eb_blk;		/* Pointer to last | 
|  | 861 | * extent block */ | 
|  | 862 | __le32		dr_clusters;		/* Clusters allocated | 
|  | 863 | * to the indexed tree. */ | 
| Mark Fasheh | 4ed8a6b | 2008-11-24 17:02:08 -0800 | [diff] [blame] | 864 | __u8		dr_flags;		/* OCFS2_DX_FLAG_* flags */ | 
|  | 865 | __u8		dr_reserved0; | 
|  | 866 | __le16		dr_reserved1; | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 867 | __le64		dr_dir_blkno;		/* Pointer to parent inode */ | 
| Mark Fasheh | e3a93c2 | 2009-02-17 15:29:35 -0800 | [diff] [blame] | 868 | __le32		dr_num_entries;		/* Total number of | 
|  | 869 | * names stored in | 
|  | 870 | * this directory.*/ | 
|  | 871 | __le32		dr_reserved2; | 
| Mark Fasheh | e7c17e4 | 2009-01-29 18:17:46 -0800 | [diff] [blame] | 872 | __le64		dr_free_blk;		/* Pointer to head of free | 
|  | 873 | * unindexed block list. */ | 
|  | 874 | __le64		dr_reserved3[15]; | 
| Mark Fasheh | 4ed8a6b | 2008-11-24 17:02:08 -0800 | [diff] [blame] | 875 | union { | 
|  | 876 | struct ocfs2_extent_list dr_list; /* Keep this aligned to 128 | 
|  | 877 | * bits for maximum space | 
|  | 878 | * efficiency. */ | 
|  | 879 | struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of | 
|  | 880 | * entries. We grow out | 
|  | 881 | * to extents if this | 
|  | 882 | * gets too big. */ | 
|  | 883 | }; | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 884 | }; | 
|  | 885 |  | 
|  | 886 | /* | 
|  | 887 | * The header of a leaf block in the indexed tree. | 
|  | 888 | */ | 
|  | 889 | struct ocfs2_dx_leaf { | 
|  | 890 | __u8		dl_signature[8];/* Signature for verification */ | 
|  | 891 | struct ocfs2_block_check dl_check;	/* Error checking */ | 
|  | 892 | __le64		dl_blkno;	/* Offset on disk, in blocks */ | 
|  | 893 | __le32		dl_fs_generation;/* Must match super block */ | 
|  | 894 | __le32		dl_reserved0; | 
|  | 895 | __le64		dl_reserved1; | 
|  | 896 | struct ocfs2_dx_entry_list	dl_list; | 
|  | 897 | }; | 
|  | 898 |  | 
| Mark Fasheh | 87d35a7 | 2008-12-10 17:36:25 -0800 | [diff] [blame] | 899 | /* | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 900 | * On disk allocator group structure for OCFS2 | 
|  | 901 | */ | 
|  | 902 | struct ocfs2_group_desc | 
|  | 903 | { | 
|  | 904 | /*00*/	__u8    bg_signature[8];        /* Signature for validation */ | 
|  | 905 | __le16   bg_size;                /* Size of included bitmap in | 
|  | 906 | bytes. */ | 
|  | 907 | __le16   bg_bits;                /* Bits represented by this | 
|  | 908 | group. */ | 
|  | 909 | __le16	bg_free_bits_count;     /* Free bits count */ | 
|  | 910 | __le16   bg_chain;               /* What chain I am in. */ | 
|  | 911 | /*10*/	__le32   bg_generation; | 
|  | 912 | __le32	bg_reserved1; | 
|  | 913 | __le64   bg_next_group;          /* Next group in my list, in | 
|  | 914 | blocks */ | 
|  | 915 | /*20*/	__le64   bg_parent_dinode;       /* dinode which owns me, in | 
|  | 916 | blocks */ | 
|  | 917 | __le64   bg_blkno;               /* Offset on disk, in blocks */ | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 918 | /*30*/	struct ocfs2_block_check bg_check;	/* Error checking */ | 
|  | 919 | __le64   bg_reserved2; | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 920 | /*40*/	__u8    bg_bitmap[0]; | 
|  | 921 | }; | 
|  | 922 |  | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 923 | struct ocfs2_refcount_rec { | 
|  | 924 | /*00*/	__le64 r_cpos;		/* Physical offset, in clusters */ | 
|  | 925 | __le32 r_clusters;	/* Clusters covered by this extent */ | 
|  | 926 | __le32 r_refcount;	/* Reference count of this extent */ | 
|  | 927 | /*10*/ | 
|  | 928 | }; | 
| Tao Ma | e73a819 | 2009-08-11 14:33:14 +0800 | [diff] [blame] | 929 | #define OCFS2_32BIT_POS_MASK		(0xffffffffULL) | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 930 |  | 
|  | 931 | #define OCFS2_REFCOUNT_LEAF_FL          (0x00000001) | 
|  | 932 | #define OCFS2_REFCOUNT_TREE_FL          (0x00000002) | 
|  | 933 |  | 
|  | 934 | struct ocfs2_refcount_list { | 
|  | 935 | /*00*/	__le16 rl_count;	/* Maximum number of entries possible | 
|  | 936 | in rl_records */ | 
|  | 937 | __le16 rl_used;		/* Current number of used records */ | 
|  | 938 | __le32 rl_reserved2; | 
|  | 939 | __le64 rl_reserved1;	/* Pad to sizeof(ocfs2_refcount_record) */ | 
|  | 940 | /*10*/	struct ocfs2_refcount_rec rl_recs[0];	/* Refcount records */ | 
|  | 941 | }; | 
|  | 942 |  | 
|  | 943 |  | 
|  | 944 | struct ocfs2_refcount_block { | 
|  | 945 | /*00*/	__u8 rf_signature[8];		/* Signature for verification */ | 
|  | 946 | __le16 rf_suballoc_slot;	/* Slot suballocator this block | 
|  | 947 | belongs to */ | 
|  | 948 | __le16 rf_suballoc_bit;		/* Bit offset in suballocator | 
|  | 949 | block group */ | 
|  | 950 | __le32 rf_fs_generation;	/* Must match superblock */ | 
|  | 951 | /*10*/	__le64 rf_blkno;		/* Offset on disk, in blocks */ | 
|  | 952 | __le64 rf_parent;		/* Parent block, only valid if | 
|  | 953 | OCFS2_REFCOUNT_LEAF_FL is set in | 
|  | 954 | rf_flags */ | 
|  | 955 | /*20*/	struct ocfs2_block_check rf_check;	/* Error checking */ | 
|  | 956 | __le64 rf_last_eb_blk;		/* Pointer to last extent block */ | 
|  | 957 | /*30*/	__le32 rf_count;		/* Number of inodes sharing this | 
|  | 958 | refcount tree */ | 
|  | 959 | __le32 rf_flags;		/* See the flags above */ | 
|  | 960 | __le32 rf_clusters;		/* clusters covered by refcount tree. */ | 
|  | 961 | __le32 rf_cpos;			/* cluster offset in refcount tree.*/ | 
|  | 962 | /*40*/	__le32 rf_generation;		/* generation number. all be the same | 
|  | 963 | * for the same refcount tree. */ | 
|  | 964 | __le32 rf_reserved0; | 
|  | 965 | __le64 rf_reserved1[7]; | 
|  | 966 | /*80*/	union { | 
|  | 967 | struct ocfs2_refcount_list rf_records;  /* List of refcount | 
|  | 968 | records */ | 
|  | 969 | struct ocfs2_extent_list rf_list;	/* Extent record list, | 
|  | 970 | only valid if | 
|  | 971 | OCFS2_REFCOUNT_TREE_FL | 
|  | 972 | is set in rf_flags */ | 
|  | 973 | }; | 
|  | 974 | /* Actual on-disk size is one block */ | 
|  | 975 | }; | 
|  | 976 |  | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 977 | /* | 
|  | 978 | * On disk extended attribute structure for OCFS2. | 
|  | 979 | */ | 
|  | 980 |  | 
|  | 981 | /* | 
|  | 982 | * ocfs2_xattr_entry indicates one extend attribute. | 
|  | 983 | * | 
|  | 984 | * Note that it can be stored in inode, one block or one xattr bucket. | 
|  | 985 | */ | 
|  | 986 | struct ocfs2_xattr_entry { | 
|  | 987 | __le32	xe_name_hash;    /* hash value of xattr prefix+suffix. */ | 
| Tao Ma | 8573f79 | 2008-10-24 22:24:17 +0800 | [diff] [blame] | 988 | __le16	xe_name_offset;  /* byte offset from the 1st entry in the | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 989 | local xattr storage(inode, xattr block or | 
|  | 990 | xattr bucket). */ | 
|  | 991 | __u8	xe_name_len;	 /* xattr name len, does't include prefix. */ | 
| Tao Ma | 8573f79 | 2008-10-24 22:24:17 +0800 | [diff] [blame] | 992 | __u8	xe_type;         /* the low 7 bits indicate the name prefix | 
|  | 993 | * type and the highest bit indicates whether | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 994 | * the EA is stored in the local storage. */ | 
|  | 995 | __le64	xe_value_size;	 /* real xattr value length. */ | 
|  | 996 | }; | 
|  | 997 |  | 
|  | 998 | /* | 
|  | 999 | * 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. */ | 
| Tao Ma | 0c044f0 | 2008-08-18 17:38:50 +0800 | [diff] [blame] | 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. */ | 
| Tao Ma | 8573f79 | 2008-10-24 22:24:17 +0800 | [diff] [blame] | 1012 | __le16	xh_num_buckets;                 /* Number of xattr buckets | 
|  | 1013 | in this extent record, | 
|  | 1014 | only valid in the first | 
|  | 1015 | bucket. */ | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 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.) */ | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 1022 | struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */ | 
|  | 1023 | }; | 
|  | 1024 |  | 
|  | 1025 | /* | 
|  | 1026 | * On disk structure for xattr value root. | 
|  | 1027 | * | 
| Tao Ma | 8573f79 | 2008-10-24 22:24:17 +0800 | [diff] [blame] | 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. | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 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 |  | 
| Tiger Yang | cf1d6c7 | 2008-08-18 17:11:00 +0800 | [diff] [blame] | 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)) | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 1056 |  | 
| Tao Ma | 0c044f0 | 2008-08-18 17:38:50 +0800 | [diff] [blame] | 1057 | #define OCFS2_XATTR_BUCKET_SIZE			4096 | 
|  | 1058 | #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET 	(OCFS2_XATTR_BUCKET_SIZE \ | 
|  | 1059 | / OCFS2_MIN_BLOCKSIZE) | 
|  | 1060 |  | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 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 */ | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 1072 | struct ocfs2_block_check xb_check;	/* Error checking */ | 
| Tao Ma | 5a7bc8e | 2008-08-18 17:38:46 +0800 | [diff] [blame] | 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_reserved2; | 
|  | 1078 | /*30*/	union { | 
|  | 1079 | struct ocfs2_xattr_header xb_header; /* xattr header if this | 
|  | 1080 | block contains xattr */ | 
|  | 1081 | struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this | 
|  | 1082 | block cotains xattr | 
|  | 1083 | tree. */ | 
|  | 1084 | } xb_attrs; | 
|  | 1085 | }; | 
|  | 1086 |  | 
|  | 1087 | #define OCFS2_XATTR_ENTRY_LOCAL		0x80 | 
|  | 1088 | #define OCFS2_XATTR_TYPE_MASK		0x7F | 
|  | 1089 | static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe, | 
|  | 1090 | int local) | 
|  | 1091 | { | 
|  | 1092 | if (local) | 
|  | 1093 | xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL; | 
|  | 1094 | else | 
|  | 1095 | xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL; | 
|  | 1096 | } | 
|  | 1097 |  | 
|  | 1098 | static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe) | 
|  | 1099 | { | 
|  | 1100 | return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL; | 
|  | 1101 | } | 
|  | 1102 |  | 
|  | 1103 | static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type) | 
|  | 1104 | { | 
|  | 1105 | xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK; | 
|  | 1106 | } | 
|  | 1107 |  | 
|  | 1108 | static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe) | 
|  | 1109 | { | 
|  | 1110 | return xe->xe_type & OCFS2_XATTR_TYPE_MASK; | 
|  | 1111 | } | 
|  | 1112 |  | 
| Jan Kara | 9e33d69 | 2008-08-25 19:56:50 +0200 | [diff] [blame] | 1113 | /* | 
|  | 1114 | *  On disk structures for global quota file | 
|  | 1115 | */ | 
|  | 1116 |  | 
|  | 1117 | /* Magic numbers and known versions for global quota files */ | 
|  | 1118 | #define OCFS2_GLOBAL_QMAGICS {\ | 
|  | 1119 | 0x0cf52470, /* USRQUOTA */ \ | 
|  | 1120 | 0x0cf52471  /* GRPQUOTA */ \ | 
|  | 1121 | } | 
|  | 1122 |  | 
|  | 1123 | #define OCFS2_GLOBAL_QVERSIONS {\ | 
|  | 1124 | 0, \ | 
|  | 1125 | 0, \ | 
|  | 1126 | } | 
|  | 1127 |  | 
|  | 1128 |  | 
|  | 1129 | /* Each block of each quota file has a certain fixed number of bytes reserved | 
|  | 1130 | * for OCFS2 internal use at its end. OCFS2 can use it for things like | 
|  | 1131 | * checksums, etc. */ | 
|  | 1132 | #define OCFS2_QBLK_RESERVED_SPACE 8 | 
|  | 1133 |  | 
|  | 1134 | /* Generic header of all quota files */ | 
|  | 1135 | struct ocfs2_disk_dqheader { | 
|  | 1136 | __le32 dqh_magic;	/* Magic number identifying file */ | 
|  | 1137 | __le32 dqh_version;	/* Quota format version */ | 
|  | 1138 | }; | 
|  | 1139 |  | 
|  | 1140 | #define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader)) | 
|  | 1141 |  | 
|  | 1142 | /* Information header of global quota file (immediately follows the generic | 
|  | 1143 | * header) */ | 
|  | 1144 | struct ocfs2_global_disk_dqinfo { | 
|  | 1145 | /*00*/	__le32 dqi_bgrace;	/* Grace time for space softlimit excess */ | 
|  | 1146 | __le32 dqi_igrace;	/* Grace time for inode softlimit excess */ | 
|  | 1147 | __le32 dqi_syncms;	/* Time after which we sync local changes to | 
|  | 1148 | * global quota file */ | 
|  | 1149 | __le32 dqi_blocks;	/* Number of blocks in quota file */ | 
|  | 1150 | /*10*/	__le32 dqi_free_blk;	/* First free block in quota file */ | 
|  | 1151 | __le32 dqi_free_entry;	/* First block with free dquot entry in quota | 
|  | 1152 | * file */ | 
|  | 1153 | }; | 
|  | 1154 |  | 
|  | 1155 | /* Structure with global user / group information. We reserve some space | 
|  | 1156 | * for future use. */ | 
|  | 1157 | struct ocfs2_global_disk_dqblk { | 
|  | 1158 | /*00*/	__le32 dqb_id;          /* ID the structure belongs to */ | 
|  | 1159 | __le32 dqb_use_count;   /* Number of nodes having reference to this structure */ | 
|  | 1160 | __le64 dqb_ihardlimit;  /* absolute limit on allocated inodes */ | 
|  | 1161 | /*10*/	__le64 dqb_isoftlimit;  /* preferred inode limit */ | 
|  | 1162 | __le64 dqb_curinodes;   /* current # allocated inodes */ | 
|  | 1163 | /*20*/	__le64 dqb_bhardlimit;  /* absolute limit on disk space */ | 
|  | 1164 | __le64 dqb_bsoftlimit;  /* preferred limit on disk space */ | 
|  | 1165 | /*30*/	__le64 dqb_curspace;    /* current space occupied */ | 
|  | 1166 | __le64 dqb_btime;       /* time limit for excessive disk use */ | 
|  | 1167 | /*40*/	__le64 dqb_itime;       /* time limit for excessive inode use */ | 
|  | 1168 | __le64 dqb_pad1; | 
|  | 1169 | /*50*/	__le64 dqb_pad2; | 
|  | 1170 | }; | 
|  | 1171 |  | 
|  | 1172 | /* | 
|  | 1173 | *  On-disk structures for local quota file | 
|  | 1174 | */ | 
|  | 1175 |  | 
|  | 1176 | /* Magic numbers and known versions for local quota files */ | 
|  | 1177 | #define OCFS2_LOCAL_QMAGICS {\ | 
|  | 1178 | 0x0cf524c0, /* USRQUOTA */ \ | 
|  | 1179 | 0x0cf524c1  /* GRPQUOTA */ \ | 
|  | 1180 | } | 
|  | 1181 |  | 
|  | 1182 | #define OCFS2_LOCAL_QVERSIONS {\ | 
|  | 1183 | 0, \ | 
|  | 1184 | 0, \ | 
|  | 1185 | } | 
|  | 1186 |  | 
|  | 1187 | /* Quota flags in dqinfo header */ | 
|  | 1188 | #define OLQF_CLEAN	0x0001	/* Quota file is empty (this should be after\ | 
|  | 1189 | * quota has been cleanly turned off) */ | 
|  | 1190 |  | 
|  | 1191 | #define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader)) | 
|  | 1192 |  | 
|  | 1193 | /* Information header of local quota file (immediately follows the generic | 
|  | 1194 | * header) */ | 
|  | 1195 | struct ocfs2_local_disk_dqinfo { | 
|  | 1196 | __le32 dqi_flags;	/* Flags for quota file */ | 
|  | 1197 | __le32 dqi_chunks;	/* Number of chunks of quota structures | 
|  | 1198 | * with a bitmap */ | 
|  | 1199 | __le32 dqi_blocks;	/* Number of blocks allocated for quota file */ | 
|  | 1200 | }; | 
|  | 1201 |  | 
|  | 1202 | /* Header of one chunk of a quota file */ | 
|  | 1203 | struct ocfs2_local_disk_chunk { | 
|  | 1204 | __le32 dqc_free;	/* Number of free entries in the bitmap */ | 
|  | 1205 | u8 dqc_bitmap[0];	/* Bitmap of entries in the corresponding | 
|  | 1206 | * chunk of quota file */ | 
|  | 1207 | }; | 
|  | 1208 |  | 
|  | 1209 | /* One entry in local quota file */ | 
|  | 1210 | struct ocfs2_local_disk_dqblk { | 
|  | 1211 | /*00*/	__le64 dqb_id;		/* id this quota applies to */ | 
|  | 1212 | __le64 dqb_spacemod;	/* Change in the amount of used space */ | 
|  | 1213 | /*10*/	__le64 dqb_inodemod;	/* Change in the amount of used inodes */ | 
|  | 1214 | }; | 
|  | 1215 |  | 
| Joel Becker | ab552d5 | 2008-10-16 17:50:30 -0700 | [diff] [blame] | 1216 |  | 
|  | 1217 | /* | 
|  | 1218 | * The quota trailer lives at the end of each quota block. | 
|  | 1219 | */ | 
|  | 1220 |  | 
|  | 1221 | struct ocfs2_disk_dqtrailer { | 
|  | 1222 | /*00*/	struct ocfs2_block_check dq_check;	/* Error checking */ | 
|  | 1223 | /*08*/	/* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */ | 
|  | 1224 | }; | 
|  | 1225 |  | 
|  | 1226 | static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize, | 
|  | 1227 | void *buf) | 
|  | 1228 | { | 
|  | 1229 | char *ptr = buf; | 
|  | 1230 | ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE; | 
|  | 1231 |  | 
|  | 1232 | return (struct ocfs2_disk_dqtrailer *)ptr; | 
|  | 1233 | } | 
|  | 1234 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1235 | #ifdef __KERNEL__ | 
|  | 1236 | static inline int ocfs2_fast_symlink_chars(struct super_block *sb) | 
|  | 1237 | { | 
|  | 1238 | return  sb->s_blocksize - | 
|  | 1239 | offsetof(struct ocfs2_dinode, id2.i_symlink); | 
|  | 1240 | } | 
|  | 1241 |  | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 1242 | static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb, | 
|  | 1243 | struct ocfs2_dinode *di) | 
|  | 1244 | { | 
|  | 1245 | unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size); | 
|  | 1246 |  | 
|  | 1247 | if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL) | 
|  | 1248 | return sb->s_blocksize - | 
|  | 1249 | offsetof(struct ocfs2_dinode, id2.i_data.id_data) - | 
|  | 1250 | xattrsize; | 
|  | 1251 | else | 
|  | 1252 | return sb->s_blocksize - | 
|  | 1253 | offsetof(struct ocfs2_dinode, id2.i_data.id_data); | 
|  | 1254 | } | 
|  | 1255 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1256 | static inline int ocfs2_extent_recs_per_inode(struct super_block *sb) | 
|  | 1257 | { | 
|  | 1258 | int size; | 
|  | 1259 |  | 
|  | 1260 | size = sb->s_blocksize - | 
|  | 1261 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | 
|  | 1262 |  | 
|  | 1263 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1264 | } | 
|  | 1265 |  | 
| Tiger Yang | fdd7770 | 2008-08-18 17:08:55 +0800 | [diff] [blame] | 1266 | static inline int ocfs2_extent_recs_per_inode_with_xattr( | 
|  | 1267 | struct super_block *sb, | 
|  | 1268 | struct ocfs2_dinode *di) | 
|  | 1269 | { | 
|  | 1270 | int size; | 
|  | 1271 | unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size); | 
|  | 1272 |  | 
|  | 1273 | if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL) | 
|  | 1274 | size = sb->s_blocksize - | 
|  | 1275 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs) - | 
|  | 1276 | xattrsize; | 
|  | 1277 | else | 
|  | 1278 | size = sb->s_blocksize - | 
|  | 1279 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | 
|  | 1280 |  | 
|  | 1281 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1282 | } | 
|  | 1283 |  | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 1284 | static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb) | 
|  | 1285 | { | 
|  | 1286 | int size; | 
|  | 1287 |  | 
|  | 1288 | size = sb->s_blocksize - | 
|  | 1289 | offsetof(struct ocfs2_dx_root_block, dr_list.l_recs); | 
|  | 1290 |  | 
|  | 1291 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1292 | } | 
|  | 1293 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1294 | static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) | 
|  | 1295 | { | 
|  | 1296 | int size; | 
|  | 1297 |  | 
|  | 1298 | size = sb->s_blocksize - | 
|  | 1299 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); | 
|  | 1300 |  | 
|  | 1301 | return size / sizeof(struct ocfs2_chain_rec); | 
|  | 1302 | } | 
|  | 1303 |  | 
|  | 1304 | static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) | 
|  | 1305 | { | 
|  | 1306 | int size; | 
|  | 1307 |  | 
|  | 1308 | size = sb->s_blocksize - | 
|  | 1309 | offsetof(struct ocfs2_extent_block, h_list.l_recs); | 
|  | 1310 |  | 
|  | 1311 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1312 | } | 
|  | 1313 |  | 
| Mark Fasheh | 9b7895e | 2008-11-12 16:27:44 -0800 | [diff] [blame] | 1314 | static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb) | 
|  | 1315 | { | 
|  | 1316 | int size; | 
|  | 1317 |  | 
|  | 1318 | size = sb->s_blocksize - | 
|  | 1319 | offsetof(struct ocfs2_dx_leaf, dl_list.de_entries); | 
|  | 1320 |  | 
|  | 1321 | return size / sizeof(struct ocfs2_dx_entry); | 
|  | 1322 | } | 
|  | 1323 |  | 
| Mark Fasheh | 4ed8a6b | 2008-11-24 17:02:08 -0800 | [diff] [blame] | 1324 | static inline int ocfs2_dx_entries_per_root(struct super_block *sb) | 
|  | 1325 | { | 
|  | 1326 | int size; | 
|  | 1327 |  | 
|  | 1328 | size = sb->s_blocksize - | 
|  | 1329 | offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries); | 
|  | 1330 |  | 
|  | 1331 | return size / sizeof(struct ocfs2_dx_entry); | 
|  | 1332 | } | 
|  | 1333 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1334 | static inline u16 ocfs2_local_alloc_size(struct super_block *sb) | 
|  | 1335 | { | 
|  | 1336 | u16 size; | 
|  | 1337 |  | 
|  | 1338 | size = sb->s_blocksize - | 
|  | 1339 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | 
|  | 1340 |  | 
|  | 1341 | return size; | 
|  | 1342 | } | 
|  | 1343 |  | 
|  | 1344 | static inline int ocfs2_group_bitmap_size(struct super_block *sb) | 
|  | 1345 | { | 
|  | 1346 | int size; | 
|  | 1347 |  | 
|  | 1348 | size = sb->s_blocksize - | 
|  | 1349 | offsetof(struct ocfs2_group_desc, bg_bitmap); | 
|  | 1350 |  | 
|  | 1351 | return size; | 
|  | 1352 | } | 
|  | 1353 |  | 
|  | 1354 | static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb) | 
|  | 1355 | { | 
|  | 1356 | int size; | 
|  | 1357 |  | 
|  | 1358 | size = sb->s_blocksize - | 
|  | 1359 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); | 
|  | 1360 |  | 
|  | 1361 | return size / sizeof(struct ocfs2_truncate_rec); | 
|  | 1362 | } | 
| Mark Fasheh | 50af94b | 2007-01-21 14:44:59 -0800 | [diff] [blame] | 1363 |  | 
|  | 1364 | static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index) | 
|  | 1365 | { | 
|  | 1366 | u64 offset = OCFS2_BACKUP_SB_START; | 
|  | 1367 |  | 
|  | 1368 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | 
|  | 1369 | offset <<= (2 * index); | 
| Mark Fasheh | a8a75a2 | 2007-01-26 10:46:59 -0800 | [diff] [blame] | 1370 | offset >>= sb->s_blocksize_bits; | 
| Mark Fasheh | 50af94b | 2007-01-21 14:44:59 -0800 | [diff] [blame] | 1371 | return offset; | 
|  | 1372 | } | 
|  | 1373 |  | 
|  | 1374 | return 0; | 
|  | 1375 |  | 
|  | 1376 | } | 
| Tao Ma | 0c044f0 | 2008-08-18 17:38:50 +0800 | [diff] [blame] | 1377 |  | 
|  | 1378 | static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb) | 
|  | 1379 | { | 
|  | 1380 | int size; | 
|  | 1381 |  | 
|  | 1382 | size = sb->s_blocksize - | 
|  | 1383 | offsetof(struct ocfs2_xattr_block, | 
|  | 1384 | xb_attrs.xb_root.xt_list.l_recs); | 
|  | 1385 |  | 
|  | 1386 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1387 | } | 
| Tao Ma | 721f69c | 2009-08-18 11:17:49 +0800 | [diff] [blame] | 1388 |  | 
|  | 1389 | static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb) | 
|  | 1390 | { | 
|  | 1391 | int size; | 
|  | 1392 |  | 
|  | 1393 | size = sb->s_blocksize - | 
|  | 1394 | offsetof(struct ocfs2_refcount_block, rf_list.l_recs); | 
|  | 1395 |  | 
|  | 1396 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1397 | } | 
|  | 1398 |  | 
|  | 1399 | static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb) | 
|  | 1400 | { | 
|  | 1401 | int size; | 
|  | 1402 |  | 
|  | 1403 | size = sb->s_blocksize - | 
|  | 1404 | offsetof(struct ocfs2_refcount_block, rf_records.rl_recs); | 
|  | 1405 |  | 
|  | 1406 | return size / sizeof(struct ocfs2_refcount_rec); | 
|  | 1407 | } | 
| Tao Ma | e73a819 | 2009-08-11 14:33:14 +0800 | [diff] [blame] | 1408 |  | 
|  | 1409 | static inline u32 | 
|  | 1410 | ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec) | 
|  | 1411 | { | 
|  | 1412 | return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK; | 
|  | 1413 | } | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1414 | #else | 
|  | 1415 | static inline int ocfs2_fast_symlink_chars(int blocksize) | 
|  | 1416 | { | 
|  | 1417 | return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink); | 
|  | 1418 | } | 
|  | 1419 |  | 
| Mark Fasheh | 15b1e36 | 2007-09-07 13:58:15 -0700 | [diff] [blame] | 1420 | static inline int ocfs2_max_inline_data(int blocksize) | 
|  | 1421 | { | 
|  | 1422 | return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data); | 
|  | 1423 | } | 
|  | 1424 |  | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1425 | static inline int ocfs2_extent_recs_per_inode(int blocksize) | 
|  | 1426 | { | 
|  | 1427 | int size; | 
|  | 1428 |  | 
|  | 1429 | size = blocksize - | 
|  | 1430 | offsetof(struct ocfs2_dinode, id2.i_list.l_recs); | 
|  | 1431 |  | 
|  | 1432 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1433 | } | 
|  | 1434 |  | 
|  | 1435 | static inline int ocfs2_chain_recs_per_inode(int blocksize) | 
|  | 1436 | { | 
|  | 1437 | int size; | 
|  | 1438 |  | 
|  | 1439 | size = blocksize - | 
|  | 1440 | offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); | 
|  | 1441 |  | 
|  | 1442 | return size / sizeof(struct ocfs2_chain_rec); | 
|  | 1443 | } | 
|  | 1444 |  | 
|  | 1445 | static inline int ocfs2_extent_recs_per_eb(int blocksize) | 
|  | 1446 | { | 
|  | 1447 | int size; | 
|  | 1448 |  | 
|  | 1449 | size = blocksize - | 
|  | 1450 | offsetof(struct ocfs2_extent_block, h_list.l_recs); | 
|  | 1451 |  | 
|  | 1452 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1453 | } | 
|  | 1454 |  | 
|  | 1455 | static inline int ocfs2_local_alloc_size(int blocksize) | 
|  | 1456 | { | 
|  | 1457 | int size; | 
|  | 1458 |  | 
|  | 1459 | size = blocksize - | 
|  | 1460 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | 
|  | 1461 |  | 
|  | 1462 | return size; | 
|  | 1463 | } | 
|  | 1464 |  | 
|  | 1465 | static inline int ocfs2_group_bitmap_size(int blocksize) | 
|  | 1466 | { | 
|  | 1467 | int size; | 
|  | 1468 |  | 
|  | 1469 | size = blocksize - | 
|  | 1470 | offsetof(struct ocfs2_group_desc, bg_bitmap); | 
|  | 1471 |  | 
|  | 1472 | return size; | 
|  | 1473 | } | 
|  | 1474 |  | 
|  | 1475 | static inline int ocfs2_truncate_recs_per_inode(int blocksize) | 
|  | 1476 | { | 
|  | 1477 | int size; | 
|  | 1478 |  | 
|  | 1479 | size = blocksize - | 
|  | 1480 | offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); | 
|  | 1481 |  | 
|  | 1482 | return size / sizeof(struct ocfs2_truncate_rec); | 
|  | 1483 | } | 
| Mark Fasheh | 50af94b | 2007-01-21 14:44:59 -0800 | [diff] [blame] | 1484 |  | 
|  | 1485 | static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index) | 
|  | 1486 | { | 
|  | 1487 | uint64_t offset = OCFS2_BACKUP_SB_START; | 
|  | 1488 |  | 
|  | 1489 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | 
|  | 1490 | offset <<= (2 * index); | 
|  | 1491 | offset /= blocksize; | 
|  | 1492 | return offset; | 
|  | 1493 | } | 
|  | 1494 |  | 
|  | 1495 | return 0; | 
|  | 1496 | } | 
| Tao Ma | 0c044f0 | 2008-08-18 17:38:50 +0800 | [diff] [blame] | 1497 |  | 
|  | 1498 | static inline int ocfs2_xattr_recs_per_xb(int blocksize) | 
|  | 1499 | { | 
|  | 1500 | int size; | 
|  | 1501 |  | 
|  | 1502 | size = blocksize - | 
|  | 1503 | offsetof(struct ocfs2_xattr_block, | 
|  | 1504 | xb_attrs.xb_root.xt_list.l_recs); | 
|  | 1505 |  | 
|  | 1506 | return size / sizeof(struct ocfs2_extent_rec); | 
|  | 1507 | } | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1508 | #endif  /* __KERNEL__ */ | 
|  | 1509 |  | 
|  | 1510 |  | 
|  | 1511 | static inline int ocfs2_system_inode_is_global(int type) | 
|  | 1512 | { | 
|  | 1513 | return ((type >= 0) && | 
|  | 1514 | (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)); | 
|  | 1515 | } | 
|  | 1516 |  | 
|  | 1517 | static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, | 
|  | 1518 | int type, int slot) | 
|  | 1519 | { | 
|  | 1520 | int chars; | 
|  | 1521 |  | 
|  | 1522 | /* | 
|  | 1523 | * Global system inodes can only have one copy.  Everything | 
|  | 1524 | * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode | 
|  | 1525 | * list has a copy per slot. | 
|  | 1526 | */ | 
|  | 1527 | if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) | 
| Joel Becker | fe9f387 | 2008-06-12 22:39:18 -0700 | [diff] [blame] | 1528 | chars = snprintf(buf, len, "%s", | 
| Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame] | 1529 | ocfs2_system_inodes[type].si_name); | 
|  | 1530 | else | 
|  | 1531 | chars = snprintf(buf, len, | 
|  | 1532 | ocfs2_system_inodes[type].si_name, | 
|  | 1533 | slot); | 
|  | 1534 |  | 
|  | 1535 | return chars; | 
|  | 1536 | } | 
|  | 1537 |  | 
|  | 1538 | static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, | 
|  | 1539 | umode_t mode) | 
|  | 1540 | { | 
|  | 1541 | de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; | 
|  | 1542 | } | 
|  | 1543 |  | 
|  | 1544 | #endif  /* _OCFS2_FS_H */ | 
|  | 1545 |  |