ocfs2_fs.h 48 KB

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