ocfs2_fs.h 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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_reserved1;
  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. /*
  712. * On disk structure for xattr block.
  713. */
  714. struct ocfs2_xattr_block {
  715. /*00*/ __u8 xb_signature[8]; /* Signature for verification */
  716. __le16 xb_suballoc_slot; /* Slot suballocator this
  717. block belongs to. */
  718. __le16 xb_suballoc_bit; /* Bit offset in suballocator
  719. block group */
  720. __le32 xb_fs_generation; /* Must match super block */
  721. /*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
  722. __le64 xb_csum;
  723. /*20*/ __le16 xb_flags; /* Indicates whether this block contains
  724. real xattr or a xattr tree. */
  725. __le16 xb_reserved0;
  726. __le32 xb_reserved1;
  727. __le64 xb_reserved2;
  728. /*30*/ union {
  729. struct ocfs2_xattr_header xb_header; /* xattr header if this
  730. block contains xattr */
  731. struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
  732. block cotains xattr
  733. tree. */
  734. } xb_attrs;
  735. };
  736. #define OCFS2_XATTR_ENTRY_LOCAL 0x80
  737. #define OCFS2_XATTR_TYPE_MASK 0x7F
  738. static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
  739. int local)
  740. {
  741. if (local)
  742. xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
  743. else
  744. xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
  745. }
  746. static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
  747. {
  748. return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
  749. }
  750. static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
  751. {
  752. xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
  753. }
  754. static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
  755. {
  756. return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
  757. }
  758. #ifdef __KERNEL__
  759. static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
  760. {
  761. return sb->s_blocksize -
  762. offsetof(struct ocfs2_dinode, id2.i_symlink);
  763. }
  764. static inline int ocfs2_max_inline_data(struct super_block *sb)
  765. {
  766. return sb->s_blocksize -
  767. offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  768. }
  769. static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
  770. struct ocfs2_dinode *di)
  771. {
  772. unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
  773. if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
  774. return sb->s_blocksize -
  775. offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
  776. xattrsize;
  777. else
  778. return sb->s_blocksize -
  779. offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  780. }
  781. static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
  782. {
  783. int size;
  784. size = sb->s_blocksize -
  785. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  786. return size / sizeof(struct ocfs2_extent_rec);
  787. }
  788. static inline int ocfs2_extent_recs_per_inode_with_xattr(
  789. struct super_block *sb,
  790. struct ocfs2_dinode *di)
  791. {
  792. int size;
  793. unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
  794. if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
  795. size = sb->s_blocksize -
  796. offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
  797. xattrsize;
  798. else
  799. size = sb->s_blocksize -
  800. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  801. return size / sizeof(struct ocfs2_extent_rec);
  802. }
  803. static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
  804. {
  805. int size;
  806. size = sb->s_blocksize -
  807. offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
  808. return size / sizeof(struct ocfs2_chain_rec);
  809. }
  810. static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
  811. {
  812. int size;
  813. size = sb->s_blocksize -
  814. offsetof(struct ocfs2_extent_block, h_list.l_recs);
  815. return size / sizeof(struct ocfs2_extent_rec);
  816. }
  817. static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
  818. {
  819. u16 size;
  820. size = sb->s_blocksize -
  821. offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
  822. return size;
  823. }
  824. static inline int ocfs2_group_bitmap_size(struct super_block *sb)
  825. {
  826. int size;
  827. size = sb->s_blocksize -
  828. offsetof(struct ocfs2_group_desc, bg_bitmap);
  829. return size;
  830. }
  831. static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
  832. {
  833. int size;
  834. size = sb->s_blocksize -
  835. offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
  836. return size / sizeof(struct ocfs2_truncate_rec);
  837. }
  838. static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
  839. {
  840. u64 offset = OCFS2_BACKUP_SB_START;
  841. if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
  842. offset <<= (2 * index);
  843. offset >>= sb->s_blocksize_bits;
  844. return offset;
  845. }
  846. return 0;
  847. }
  848. #else
  849. static inline int ocfs2_fast_symlink_chars(int blocksize)
  850. {
  851. return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
  852. }
  853. static inline int ocfs2_max_inline_data(int blocksize)
  854. {
  855. return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
  856. }
  857. static inline int ocfs2_extent_recs_per_inode(int blocksize)
  858. {
  859. int size;
  860. size = blocksize -
  861. offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
  862. return size / sizeof(struct ocfs2_extent_rec);
  863. }
  864. static inline int ocfs2_chain_recs_per_inode(int blocksize)
  865. {
  866. int size;
  867. size = blocksize -
  868. offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
  869. return size / sizeof(struct ocfs2_chain_rec);
  870. }
  871. static inline int ocfs2_extent_recs_per_eb(int blocksize)
  872. {
  873. int size;
  874. size = blocksize -
  875. offsetof(struct ocfs2_extent_block, h_list.l_recs);
  876. return size / sizeof(struct ocfs2_extent_rec);
  877. }
  878. static inline int ocfs2_local_alloc_size(int blocksize)
  879. {
  880. int size;
  881. size = blocksize -
  882. offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
  883. return size;
  884. }
  885. static inline int ocfs2_group_bitmap_size(int blocksize)
  886. {
  887. int size;
  888. size = blocksize -
  889. offsetof(struct ocfs2_group_desc, bg_bitmap);
  890. return size;
  891. }
  892. static inline int ocfs2_truncate_recs_per_inode(int blocksize)
  893. {
  894. int size;
  895. size = blocksize -
  896. offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
  897. return size / sizeof(struct ocfs2_truncate_rec);
  898. }
  899. static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
  900. {
  901. uint64_t offset = OCFS2_BACKUP_SB_START;
  902. if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
  903. offset <<= (2 * index);
  904. offset /= blocksize;
  905. return offset;
  906. }
  907. return 0;
  908. }
  909. #endif /* __KERNEL__ */
  910. static inline int ocfs2_system_inode_is_global(int type)
  911. {
  912. return ((type >= 0) &&
  913. (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
  914. }
  915. static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
  916. int type, int slot)
  917. {
  918. int chars;
  919. /*
  920. * Global system inodes can only have one copy. Everything
  921. * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
  922. * list has a copy per slot.
  923. */
  924. if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
  925. chars = snprintf(buf, len, "%s",
  926. ocfs2_system_inodes[type].si_name);
  927. else
  928. chars = snprintf(buf, len,
  929. ocfs2_system_inodes[type].si_name,
  930. slot);
  931. return chars;
  932. }
  933. static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
  934. umode_t mode)
  935. {
  936. de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
  937. }
  938. #endif /* _OCFS2_FS_H */