ocfs2_fs.h 49 KB

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