ocfs2_fs.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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. /* Compatibility flags */
  62. #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
  63. ( OCFS2_SB(sb)->s_feature_compat & (mask) )
  64. #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
  65. ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
  66. #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
  67. ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
  68. #define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
  69. OCFS2_SB(sb)->s_feature_compat |= (mask)
  70. #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
  71. OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
  72. #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
  73. OCFS2_SB(sb)->s_feature_incompat |= (mask)
  74. #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
  75. OCFS2_SB(sb)->s_feature_compat &= ~(mask)
  76. #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
  77. OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
  78. #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
  79. OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
  80. #define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB
  81. #define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
  82. | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
  83. | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
  84. | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
  85. | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
  86. #define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
  87. /*
  88. * Heartbeat-only devices are missing journals and other files. The
  89. * filesystem driver can't load them, but the library can. Never put
  90. * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
  91. */
  92. #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
  93. /*
  94. * tunefs sets this incompat flag before starting the resize and clears it
  95. * at the end. This flag protects users from inadvertently mounting the fs
  96. * after an aborted run without fsck-ing.
  97. */
  98. #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
  99. /* Used to denote a non-clustered volume */
  100. #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
  101. /* Support for sparse allocation in b-trees */
  102. #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
  103. /*
  104. * Tunefs sets this incompat flag before starting an operation which
  105. * would require cleanup on abort. This is done to protect users from
  106. * inadvertently mounting the fs after an aborted run without
  107. * fsck-ing.
  108. *
  109. * s_tunefs_flags on the super block describes precisely which
  110. * operations were in progress.
  111. */
  112. #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
  113. /* Support for data packed into inode blocks */
  114. #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
  115. /* Support for the extended slot map */
  116. #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
  117. /*
  118. * Support for alternate, userspace cluster stacks. If set, the superblock
  119. * field s_cluster_info contains a tag for the alternate stack in use as
  120. * well as the name of the cluster being joined.
  121. * mount.ocfs2 must pass in a matching stack name.
  122. *
  123. * If not set, the classic stack will be used. This is compatbile with
  124. * all older versions.
  125. */
  126. #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
  127. /*
  128. * backup superblock flag is used to indicate that this volume
  129. * has backup superblocks.
  130. */
  131. #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
  132. /*
  133. * Unwritten extents support.
  134. */
  135. #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
  136. /* The byte offset of the first backup block will be 1G.
  137. * The following will be 4G, 16G, 64G, 256G and 1T.
  138. */
  139. #define OCFS2_BACKUP_SB_START 1 << 30
  140. /* the max backup superblock nums */
  141. #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
  142. /*
  143. * Flags on ocfs2_super_block.s_tunefs_flags
  144. */
  145. #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
  146. /*
  147. * Flags on ocfs2_dinode.i_flags
  148. */
  149. #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
  150. #define OCFS2_UNUSED2_FL (0x00000002)
  151. #define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
  152. #define OCFS2_UNUSED3_FL (0x00000008)
  153. /* System inode flags */
  154. #define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
  155. #define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
  156. #define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
  157. #define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
  158. #define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
  159. #define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
  160. #define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
  161. #define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
  162. /*
  163. * Flags on ocfs2_dinode.i_dyn_features
  164. *
  165. * These can change much more often than i_flags. When adding flags,
  166. * keep in mind that i_dyn_features is only 16 bits wide.
  167. */
  168. #define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
  169. #define OCFS2_HAS_XATTR_FL (0x0002)
  170. #define OCFS2_INLINE_XATTR_FL (0x0004)
  171. #define OCFS2_INDEXED_DIR_FL (0x0008)
  172. /* Inode attributes, keep in sync with EXT2 */
  173. #define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
  174. #define OCFS2_UNRM_FL (0x00000002) /* Undelete */
  175. #define OCFS2_COMPR_FL (0x00000004) /* Compress file */
  176. #define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
  177. #define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
  178. #define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
  179. #define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
  180. #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
  181. #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
  182. #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
  183. #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
  184. /*
  185. * Extent record flags (e_node.leaf.flags)
  186. */
  187. #define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
  188. * unwritten */
  189. /*
  190. * ioctl commands
  191. */
  192. #define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
  193. #define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
  194. #define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
  195. #define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
  196. /*
  197. * Space reservation / allocation / free ioctls and argument structure
  198. * are designed to be compatible with XFS.
  199. *
  200. * ALLOCSP* and FREESP* are not and will never be supported, but are
  201. * included here for completeness.
  202. */
  203. struct ocfs2_space_resv {
  204. __s16 l_type;
  205. __s16 l_whence;
  206. __s64 l_start;
  207. __s64 l_len; /* len == 0 means until end of file */
  208. __s32 l_sysid;
  209. __u32 l_pid;
  210. __s32 l_pad[4]; /* reserve area */
  211. };
  212. #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
  213. #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
  214. #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
  215. #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
  216. #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
  217. #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
  218. #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
  219. #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
  220. /* Used to pass group descriptor data when online resize is done */
  221. struct ocfs2_new_group_input {
  222. __u64 group; /* Group descriptor's blkno. */
  223. __u32 clusters; /* Total number of clusters in this group */
  224. __u32 frees; /* Total free clusters in this group */
  225. __u16 chain; /* Chain for this group */
  226. __u16 reserved1;
  227. __u32 reserved2;
  228. };
  229. #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
  230. #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
  231. #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
  232. /*
  233. * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
  234. */
  235. #define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
  236. /*
  237. * superblock s_state flags
  238. */
  239. #define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
  240. /* Limit of space in ocfs2_dir_entry */
  241. #define OCFS2_MAX_FILENAME_LEN 255
  242. /* Maximum slots on an ocfs2 file system */
  243. #define OCFS2_MAX_SLOTS 255
  244. /* Slot map indicator for an empty slot */
  245. #define OCFS2_INVALID_SLOT -1
  246. #define OCFS2_VOL_UUID_LEN 16
  247. #define OCFS2_MAX_VOL_LABEL_LEN 64
  248. /* The alternate, userspace stack fields */
  249. #define OCFS2_STACK_LABEL_LEN 4
  250. #define OCFS2_CLUSTER_NAME_LEN 16
  251. /* Journal limits (in bytes) */
  252. #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
  253. /*
  254. * Default local alloc size (in megabytes)
  255. *
  256. * The value chosen should be such that most allocations, including new
  257. * block groups, use local alloc.
  258. */
  259. #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
  260. /*
  261. * Inline extended attribute size (in bytes)
  262. * The value chosen should be aligned to 16 byte boundaries.
  263. */
  264. #define OCFS2_MIN_XATTR_INLINE_SIZE 256
  265. struct ocfs2_system_inode_info {
  266. char *si_name;
  267. int si_iflags;
  268. int si_mode;
  269. };
  270. /* System file index */
  271. enum {
  272. BAD_BLOCK_SYSTEM_INODE = 0,
  273. GLOBAL_INODE_ALLOC_SYSTEM_INODE,
  274. SLOT_MAP_SYSTEM_INODE,
  275. #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
  276. HEARTBEAT_SYSTEM_INODE,
  277. GLOBAL_BITMAP_SYSTEM_INODE,
  278. #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
  279. ORPHAN_DIR_SYSTEM_INODE,
  280. EXTENT_ALLOC_SYSTEM_INODE,
  281. INODE_ALLOC_SYSTEM_INODE,
  282. JOURNAL_SYSTEM_INODE,
  283. LOCAL_ALLOC_SYSTEM_INODE,
  284. TRUNCATE_LOG_SYSTEM_INODE,
  285. NUM_SYSTEM_INODES
  286. };
  287. static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
  288. /* Global system inodes (single copy) */
  289. /* The first two are only used from userspace mfks/tunefs */
  290. [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
  291. [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
  292. /* These are used by the running filesystem */
  293. [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
  294. [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
  295. [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
  296. /* Slot-specific system inodes (one copy per slot) */
  297. [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
  298. [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
  299. [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
  300. [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
  301. [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
  302. [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
  303. };
  304. /* Parameter passed from mount.ocfs2 to module */
  305. #define OCFS2_HB_NONE "heartbeat=none"
  306. #define OCFS2_HB_LOCAL "heartbeat=local"
  307. /*
  308. * OCFS2 directory file types. Only the low 3 bits are used. The
  309. * other bits are reserved for now.
  310. */
  311. #define OCFS2_FT_UNKNOWN 0
  312. #define OCFS2_FT_REG_FILE 1
  313. #define OCFS2_FT_DIR 2
  314. #define OCFS2_FT_CHRDEV 3
  315. #define OCFS2_FT_BLKDEV 4
  316. #define OCFS2_FT_FIFO 5
  317. #define OCFS2_FT_SOCK 6
  318. #define OCFS2_FT_SYMLINK 7
  319. #define OCFS2_FT_MAX 8
  320. /*
  321. * OCFS2_DIR_PAD defines the directory entries boundaries
  322. *
  323. * NOTE: It must be a multiple of 4
  324. */
  325. #define OCFS2_DIR_PAD 4
  326. #define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
  327. #define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
  328. #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
  329. OCFS2_DIR_ROUND) & \
  330. ~OCFS2_DIR_ROUND)
  331. #define OCFS2_LINK_MAX 32000
  332. #define S_SHIFT 12
  333. static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
  334. [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
  335. [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
  336. [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
  337. [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
  338. [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
  339. [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
  340. [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
  341. };
  342. /*
  343. * Convenience casts
  344. */
  345. #define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
  346. /*
  347. * On disk extent record for OCFS2
  348. * It describes a range of clusters on disk.
  349. *
  350. * Length fields are divided into interior and leaf node versions.
  351. * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
  352. */
  353. struct ocfs2_extent_rec {
  354. /*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
  355. union {
  356. __le32 e_int_clusters; /* Clusters covered by all children */
  357. struct {
  358. __le16 e_leaf_clusters; /* Clusters covered by this
  359. extent */
  360. __u8 e_reserved1;
  361. __u8 e_flags; /* Extent flags */
  362. };
  363. };
  364. __le64 e_blkno; /* Physical disk offset, in blocks */
  365. /*10*/
  366. };
  367. struct ocfs2_chain_rec {
  368. __le32 c_free; /* Number of free bits in this chain. */
  369. __le32 c_total; /* Number of total bits in this chain */
  370. __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
  371. };
  372. struct ocfs2_truncate_rec {
  373. __le32 t_start; /* 1st cluster in this log */
  374. __le32 t_clusters; /* Number of total clusters covered */
  375. };
  376. /*
  377. * On disk extent list for OCFS2 (node in the tree). Note that this
  378. * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
  379. * offsets are relative to ocfs2_dinode.id2.i_list or
  380. * ocfs2_extent_block.h_list, respectively.
  381. */
  382. struct ocfs2_extent_list {
  383. /*00*/ __le16 l_tree_depth; /* Extent tree depth from this
  384. point. 0 means data extents
  385. hang directly off this
  386. header (a leaf)
  387. NOTE: The high 8 bits cannot be
  388. used - tree_depth is never that big.
  389. */
  390. __le16 l_count; /* Number of extent records */
  391. __le16 l_next_free_rec; /* Next unused extent slot */
  392. __le16 l_reserved1;
  393. __le64 l_reserved2; /* Pad to
  394. sizeof(ocfs2_extent_rec) */
  395. /*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
  396. };
  397. /*
  398. * On disk allocation chain list for OCFS2. Note that this is
  399. * contained inside ocfs2_dinode, so the offsets are relative to
  400. * ocfs2_dinode.id2.i_chain.
  401. */
  402. struct ocfs2_chain_list {
  403. /*00*/ __le16 cl_cpg; /* Clusters per Block Group */
  404. __le16 cl_bpc; /* Bits per cluster */
  405. __le16 cl_count; /* Total chains in this list */
  406. __le16 cl_next_free_rec; /* Next unused chain slot */
  407. __le64 cl_reserved1;
  408. /*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
  409. };
  410. /*
  411. * On disk deallocation log for OCFS2. Note that this is
  412. * contained inside ocfs2_dinode, so the offsets are relative to
  413. * ocfs2_dinode.id2.i_dealloc.
  414. */
  415. struct ocfs2_truncate_log {
  416. /*00*/ __le16 tl_count; /* Total records in this log */
  417. __le16 tl_used; /* Number of records in use */
  418. __le32 tl_reserved1;
  419. /*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
  420. };
  421. /*
  422. * On disk extent block (indirect block) for OCFS2
  423. */
  424. struct ocfs2_extent_block
  425. {
  426. /*00*/ __u8 h_signature[8]; /* Signature for verification */
  427. __le64 h_reserved1;
  428. /*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
  429. extent_header belongs to */
  430. __le16 h_suballoc_bit; /* Bit offset in suballocator
  431. block group */
  432. __le32 h_fs_generation; /* Must match super block */
  433. __le64 h_blkno; /* Offset on disk, in blocks */
  434. /*20*/ __le64 h_reserved3;
  435. __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
  436. of next leaf header pointing
  437. to data */
  438. /*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
  439. /* Actual on-disk size is one block */
  440. };
  441. /*
  442. * On disk slot map for OCFS2. This defines the contents of the "slot_map"
  443. * system file. A slot is valid if it contains a node number >= 0. The
  444. * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
  445. */
  446. struct ocfs2_slot_map {
  447. /*00*/ __le16 sm_slots[0];
  448. /*
  449. * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
  450. * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
  451. */
  452. };
  453. struct ocfs2_extended_slot {
  454. /*00*/ __u8 es_valid;
  455. __u8 es_reserved1[3];
  456. __le32 es_node_num;
  457. /*10*/
  458. };
  459. /*
  460. * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
  461. * is set. It separates out the valid marker from the node number, and
  462. * has room to grow. Unlike the old slot map, this format is defined by
  463. * i_size.
  464. */
  465. struct ocfs2_slot_map_extended {
  466. /*00*/ struct ocfs2_extended_slot se_slots[0];
  467. /*
  468. * Actual size is i_size of the slot_map system file. It should
  469. * match s_max_slots * sizeof(struct ocfs2_extended_slot)
  470. */
  471. };
  472. struct ocfs2_cluster_info {
  473. /*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
  474. __le32 ci_reserved;
  475. /*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
  476. /*18*/
  477. };
  478. /*
  479. * On disk superblock for OCFS2
  480. * Note that it is contained inside an ocfs2_dinode, so all offsets
  481. * are relative to the start of ocfs2_dinode.id2.
  482. */
  483. struct ocfs2_super_block {
  484. /*00*/ __le16 s_major_rev_level;
  485. __le16 s_minor_rev_level;
  486. __le16 s_mnt_count;
  487. __le16 s_max_mnt_count;
  488. __le16 s_state; /* File system state */
  489. __le16 s_errors; /* Behaviour when detecting errors */
  490. __le32 s_checkinterval; /* Max time between checks */
  491. /*10*/ __le64 s_lastcheck; /* Time of last check */
  492. __le32 s_creator_os; /* OS */
  493. __le32 s_feature_compat; /* Compatible feature set */
  494. /*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
  495. __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
  496. __le64 s_root_blkno; /* Offset, in blocks, of root directory
  497. dinode */
  498. /*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
  499. directory dinode */
  500. __le32 s_blocksize_bits; /* Blocksize for this fs */
  501. __le32 s_clustersize_bits; /* Clustersize for this fs */
  502. /*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
  503. before tunefs required */
  504. __le16 s_tunefs_flag;
  505. __le32 s_uuid_hash; /* hash value of uuid */
  506. __le64 s_first_cluster_group; /* Block offset of 1st cluster
  507. * group header */
  508. /*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
  509. /*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
  510. /*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
  511. stack. Only valid
  512. with INCOMPAT flag. */
  513. /*B8*/ __le64 s_reserved2[17]; /* Fill out superblock */
  514. /*140*/
  515. /*
  516. * NOTE: As stated above, all offsets are relative to
  517. * ocfs2_dinode.id2, which is at 0xC0 in the inode.
  518. * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
  519. * our smallest blocksize, which is 512 bytes. To ensure this,
  520. * we reserve the space in s_reserved2. Anything past s_reserved2
  521. * will not be available on the smallest blocksize.
  522. */
  523. };
  524. /*
  525. * Local allocation bitmap for OCFS2 slots
  526. * Note that it exists inside an ocfs2_dinode, so all offsets are
  527. * relative to the start of ocfs2_dinode.id2.
  528. */
  529. struct ocfs2_local_alloc
  530. {
  531. /*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
  532. __le16 la_size; /* Size of included bitmap, in bytes */
  533. __le16 la_reserved1;
  534. __le64 la_reserved2;
  535. /*10*/ __u8 la_bitmap[0];
  536. };
  537. /*
  538. * Data-in-inode header. This is only used if i_dyn_features has
  539. * OCFS2_INLINE_DATA_FL set.
  540. */
  541. struct ocfs2_inline_data
  542. {
  543. /*00*/ __le16 id_count; /* Number of bytes that can be used
  544. * for data, starting at id_data */
  545. __le16 id_reserved0;
  546. __le32 id_reserved1;
  547. __u8 id_data[0]; /* Start of user data */
  548. };
  549. /*
  550. * On disk inode for OCFS2
  551. */
  552. struct ocfs2_dinode {
  553. /*00*/ __u8 i_signature[8]; /* Signature for validation */
  554. __le32 i_generation; /* Generation number */
  555. __le16 i_suballoc_slot; /* Slot suballocator this inode
  556. belongs to */
  557. __le16 i_suballoc_bit; /* Bit offset in suballocator
  558. block group */
  559. /*10*/ __le16 i_reserved0;
  560. __le16 i_xattr_inline_size;
  561. __le32 i_clusters; /* Cluster count */
  562. __le32 i_uid; /* Owner UID */
  563. __le32 i_gid; /* Owning GID */
  564. /*20*/ __le64 i_size; /* Size in bytes */
  565. __le16 i_mode; /* File mode */
  566. __le16 i_links_count; /* Links count */
  567. __le32 i_flags; /* File flags */
  568. /*30*/ __le64 i_atime; /* Access time */
  569. __le64 i_ctime; /* Creation time */
  570. /*40*/ __le64 i_mtime; /* Modification time */
  571. __le64 i_dtime; /* Deletion time */
  572. /*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
  573. __le64 i_last_eb_blk; /* Pointer to last extent
  574. block */
  575. /*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
  576. __le32 i_atime_nsec;
  577. __le32 i_ctime_nsec;
  578. __le32 i_mtime_nsec;
  579. /*70*/ __le32 i_attr;
  580. __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
  581. was set in i_flags */
  582. __le16 i_dyn_features;
  583. __le64 i_xattr_loc;
  584. /*80*/ __le64 i_reserved2[7];
  585. /*B8*/ union {
  586. __le64 i_pad1; /* Generic way to refer to this
  587. 64bit union */
  588. struct {
  589. __le64 i_rdev; /* Device number */
  590. } dev1;
  591. struct { /* Info for bitmap system
  592. inodes */
  593. __le32 i_used; /* Bits (ie, clusters) used */
  594. __le32 i_total; /* Total bits (clusters)
  595. available */
  596. } bitmap1;
  597. struct { /* Info for journal system
  598. inodes */
  599. __le32 ij_flags; /* Mounted, version, etc. */
  600. __le32 ij_recovery_generation; /* Incremented when the
  601. journal is recovered
  602. after an unclean
  603. shutdown */
  604. } journal1;
  605. } id1; /* Inode type dependant 1 */
  606. /*C0*/ union {
  607. struct ocfs2_super_block i_super;
  608. struct ocfs2_local_alloc i_lab;
  609. struct ocfs2_chain_list i_chain;
  610. struct ocfs2_extent_list i_list;
  611. struct ocfs2_truncate_log i_dealloc;
  612. struct ocfs2_inline_data i_data;
  613. __u8 i_symlink[0];
  614. } id2;
  615. /* Actual on-disk size is one block */
  616. };
  617. /*
  618. * On-disk directory entry structure for OCFS2
  619. *
  620. * Packed as this structure could be accessed unaligned on 64-bit platforms
  621. */
  622. struct ocfs2_dir_entry {
  623. /*00*/ __le64 inode; /* Inode number */
  624. __le16 rec_len; /* Directory entry length */
  625. __u8 name_len; /* Name length */
  626. __u8 file_type;
  627. /*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
  628. /* Actual on-disk length specified by rec_len */
  629. } __attribute__ ((packed));
  630. /*
  631. * On disk allocator group structure for OCFS2
  632. */
  633. struct ocfs2_group_desc
  634. {
  635. /*00*/ __u8 bg_signature[8]; /* Signature for validation */
  636. __le16 bg_size; /* Size of included bitmap in
  637. bytes. */
  638. __le16 bg_bits; /* Bits represented by this
  639. group. */
  640. __le16 bg_free_bits_count; /* Free bits count */
  641. __le16 bg_chain; /* What chain I am in. */
  642. /*10*/ __le32 bg_generation;
  643. __le32 bg_reserved1;
  644. __le64 bg_next_group; /* Next group in my list, in
  645. blocks */
  646. /*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
  647. blocks */
  648. __le64 bg_blkno; /* Offset on disk, in blocks */
  649. /*30*/ __le64 bg_reserved2[2];
  650. /*40*/ __u8 bg_bitmap[0];
  651. };
  652. /*
  653. * On disk extended attribute structure for OCFS2.
  654. */
  655. /*
  656. * ocfs2_xattr_entry indicates one extend attribute.
  657. *
  658. * Note that it can be stored in inode, one block or one xattr bucket.
  659. */
  660. struct ocfs2_xattr_entry {
  661. __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
  662. __le16 xe_name_offset; /* byte offset from the 1st etnry in the local
  663. local xattr storage(inode, xattr block or
  664. xattr bucket). */
  665. __u8 xe_name_len; /* xattr name len, does't include prefix. */
  666. __u8 xe_type; /* the low 7 bits indicates the name prefix's
  667. * type and the highest 1 bits indicate whether
  668. * the EA is stored in the local storage. */
  669. __le64 xe_value_size; /* real xattr value length. */
  670. };
  671. /*
  672. * On disk structure for xattr header.
  673. *
  674. * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
  675. * the local xattr storage.
  676. */
  677. struct ocfs2_xattr_header {
  678. __le16 xh_count; /* contains the count of how
  679. many records are in the
  680. local xattr storage. */
  681. __le16 xh_reserved1;
  682. __le32 xh_reserved2;
  683. __le64 xh_csum;
  684. struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
  685. };
  686. /*
  687. * On disk structure for xattr value root.
  688. *
  689. * It is used when one extended attribute's size is larger, and we will save it
  690. * in an outside cluster. It will stored in a b-tree like file content.
  691. */
  692. struct ocfs2_xattr_value_root {
  693. /*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
  694. __le32 xr_reserved0;
  695. __le64 xr_last_eb_blk; /* Pointer to last extent block */
  696. /*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
  697. };
  698. /*
  699. * On disk structure for xattr tree root.
  700. *
  701. * It is used when there are too many extended attributes for one file. These
  702. * attributes will be organized and stored in an indexed-btree.
  703. */
  704. struct ocfs2_xattr_tree_root {
  705. /*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
  706. __le32 xt_reserved0;
  707. __le64 xt_last_eb_blk; /* Pointer to last extent block */
  708. /*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
  709. };
  710. #define OCFS2_XATTR_INDEXED 0x1
  711. #define OCFS2_HASH_SHIFT 5
  712. #define OCFS2_XATTR_ROUND 3
  713. #define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
  714. ~(OCFS2_XATTR_ROUND))
  715. /*
  716. * On disk structure for xattr block.
  717. */
  718. struct ocfs2_xattr_block {
  719. /*00*/ __u8 xb_signature[8]; /* Signature for verification */
  720. __le16 xb_suballoc_slot; /* Slot suballocator this
  721. block belongs to. */
  722. __le16 xb_suballoc_bit; /* Bit offset in suballocator
  723. block group */
  724. __le32 xb_fs_generation; /* Must match super block */
  725. /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
  726. __le64 xb_csum;
  727. /*20*/ __le16 xb_flags; /* Indicates whether this block contains
  728. real xattr or a xattr tree. */
  729. __le16 xb_reserved0;
  730. __le32 xb_reserved1;
  731. __le64 xb_reserved2;
  732. /*30*/ union {
  733. struct ocfs2_xattr_header xb_header; /* xattr header if this
  734. block contains xattr */
  735. struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
  736. block cotains xattr
  737. tree. */
  738. } xb_attrs;
  739. };
  740. #define OCFS2_XATTR_ENTRY_LOCAL 0x80
  741. #define OCFS2_XATTR_TYPE_MASK 0x7F
  742. static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
  743. int local)
  744. {
  745. if (local)
  746. xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
  747. else
  748. xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
  749. }
  750. static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
  751. {
  752. return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
  753. }
  754. static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
  755. {
  756. xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
  757. }
  758. static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
  759. {
  760. return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
  761. }
  762. #ifdef __KERNEL__
  763. static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
  764. {
  765. return sb->s_blocksize -
  766. offsetof(struct ocfs2_dinode, id2.i_symlink);
  767. }
  768. static inline int ocfs2_max_inline_data(struct super_block *sb)
  769. {
  770. return sb->s_blocksize -
  771. offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  772. }
  773. static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
  774. struct ocfs2_dinode *di)
  775. {
  776. unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
  777. if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
  778. return sb->s_blocksize -
  779. offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
  780. xattrsize;
  781. else
  782. return sb->s_blocksize -
  783. offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  784. }
  785. static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
  786. {
  787. int size;
  788. size = sb->s_blocksize -
  789. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  790. return size / sizeof(struct ocfs2_extent_rec);
  791. }
  792. static inline int ocfs2_extent_recs_per_inode_with_xattr(
  793. struct super_block *sb,
  794. struct ocfs2_dinode *di)
  795. {
  796. int size;
  797. unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
  798. if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
  799. size = sb->s_blocksize -
  800. offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
  801. xattrsize;
  802. else
  803. size = sb->s_blocksize -
  804. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  805. return size / sizeof(struct ocfs2_extent_rec);
  806. }
  807. static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
  808. {
  809. int size;
  810. size = sb->s_blocksize -
  811. offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
  812. return size / sizeof(struct ocfs2_chain_rec);
  813. }
  814. static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
  815. {
  816. int size;
  817. size = sb->s_blocksize -
  818. offsetof(struct ocfs2_extent_block, h_list.l_recs);
  819. return size / sizeof(struct ocfs2_extent_rec);
  820. }
  821. static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
  822. {
  823. u16 size;
  824. size = sb->s_blocksize -
  825. offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
  826. return size;
  827. }
  828. static inline int ocfs2_group_bitmap_size(struct super_block *sb)
  829. {
  830. int size;
  831. size = sb->s_blocksize -
  832. offsetof(struct ocfs2_group_desc, bg_bitmap);
  833. return size;
  834. }
  835. static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
  836. {
  837. int size;
  838. size = sb->s_blocksize -
  839. offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
  840. return size / sizeof(struct ocfs2_truncate_rec);
  841. }
  842. static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
  843. {
  844. u64 offset = OCFS2_BACKUP_SB_START;
  845. if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
  846. offset <<= (2 * index);
  847. offset >>= sb->s_blocksize_bits;
  848. return offset;
  849. }
  850. return 0;
  851. }
  852. #else
  853. static inline int ocfs2_fast_symlink_chars(int blocksize)
  854. {
  855. return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
  856. }
  857. static inline int ocfs2_max_inline_data(int blocksize)
  858. {
  859. return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  860. }
  861. static inline int ocfs2_extent_recs_per_inode(int blocksize)
  862. {
  863. int size;
  864. size = blocksize -
  865. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  866. return size / sizeof(struct ocfs2_extent_rec);
  867. }
  868. static inline int ocfs2_chain_recs_per_inode(int blocksize)
  869. {
  870. int size;
  871. size = blocksize -
  872. offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
  873. return size / sizeof(struct ocfs2_chain_rec);
  874. }
  875. static inline int ocfs2_extent_recs_per_eb(int blocksize)
  876. {
  877. int size;
  878. size = blocksize -
  879. offsetof(struct ocfs2_extent_block, h_list.l_recs);
  880. return size / sizeof(struct ocfs2_extent_rec);
  881. }
  882. static inline int ocfs2_local_alloc_size(int blocksize)
  883. {
  884. int size;
  885. size = blocksize -
  886. offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
  887. return size;
  888. }
  889. static inline int ocfs2_group_bitmap_size(int blocksize)
  890. {
  891. int size;
  892. size = blocksize -
  893. offsetof(struct ocfs2_group_desc, bg_bitmap);
  894. return size;
  895. }
  896. static inline int ocfs2_truncate_recs_per_inode(int blocksize)
  897. {
  898. int size;
  899. size = blocksize -
  900. offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
  901. return size / sizeof(struct ocfs2_truncate_rec);
  902. }
  903. static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
  904. {
  905. uint64_t offset = OCFS2_BACKUP_SB_START;
  906. if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
  907. offset <<= (2 * index);
  908. offset /= blocksize;
  909. return offset;
  910. }
  911. return 0;
  912. }
  913. #endif /* __KERNEL__ */
  914. static inline int ocfs2_system_inode_is_global(int type)
  915. {
  916. return ((type >= 0) &&
  917. (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
  918. }
  919. static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
  920. int type, int slot)
  921. {
  922. int chars;
  923. /*
  924. * Global system inodes can only have one copy. Everything
  925. * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
  926. * list has a copy per slot.
  927. */
  928. if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
  929. chars = snprintf(buf, len, "%s",
  930. ocfs2_system_inodes[type].si_name);
  931. else
  932. chars = snprintf(buf, len,
  933. ocfs2_system_inodes[type].si_name,
  934. slot);
  935. return chars;
  936. }
  937. static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
  938. umode_t mode)
  939. {
  940. de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
  941. }
  942. #endif /* _OCFS2_FS_H */