ext4_fs.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. /*
  2. * linux/include/linux/ext4_fs.h
  3. *
  4. * Copyright (C) 1992, 1993, 1994, 1995
  5. * Remy Card (card@masi.ibp.fr)
  6. * Laboratoire MASI - Institut Blaise Pascal
  7. * Universite Pierre et Marie Curie (Paris VI)
  8. *
  9. * from
  10. *
  11. * linux/include/linux/minix_fs.h
  12. *
  13. * Copyright (C) 1991, 1992 Linus Torvalds
  14. */
  15. #ifndef _LINUX_EXT4_FS_H
  16. #define _LINUX_EXT4_FS_H
  17. #include <linux/types.h>
  18. #include <linux/blkdev.h>
  19. #include <linux/magic.h>
  20. /*
  21. * The second extended filesystem constants/structures
  22. */
  23. /*
  24. * Define EXT4FS_DEBUG to produce debug messages
  25. */
  26. #undef EXT4FS_DEBUG
  27. /*
  28. * Define EXT4_RESERVATION to reserve data blocks for expanding files
  29. */
  30. #define EXT4_DEFAULT_RESERVE_BLOCKS 8
  31. /*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
  32. #define EXT4_MAX_RESERVE_BLOCKS 1027
  33. #define EXT4_RESERVE_WINDOW_NOT_ALLOCATED 0
  34. /*
  35. * Always enable hashed directories
  36. */
  37. #define CONFIG_EXT4_INDEX
  38. /*
  39. * Debug code
  40. */
  41. #ifdef EXT4FS_DEBUG
  42. #define ext4_debug(f, a...) \
  43. do { \
  44. printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
  45. __FILE__, __LINE__, __FUNCTION__); \
  46. printk (KERN_DEBUG f, ## a); \
  47. } while (0)
  48. #else
  49. #define ext4_debug(f, a...) do {} while (0)
  50. #endif
  51. /*
  52. * Special inodes numbers
  53. */
  54. #define EXT4_BAD_INO 1 /* Bad blocks inode */
  55. #define EXT4_ROOT_INO 2 /* Root inode */
  56. #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
  57. #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
  58. #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
  59. #define EXT4_JOURNAL_INO 8 /* Journal inode */
  60. /* First non-reserved inode for old ext4 filesystems */
  61. #define EXT4_GOOD_OLD_FIRST_INO 11
  62. /*
  63. * Maximal count of links to a file
  64. */
  65. #define EXT4_LINK_MAX 32000
  66. /*
  67. * Macro-instructions used to manage several block sizes
  68. */
  69. #define EXT4_MIN_BLOCK_SIZE 1024
  70. #define EXT4_MAX_BLOCK_SIZE 4096
  71. #define EXT4_MIN_BLOCK_LOG_SIZE 10
  72. #ifdef __KERNEL__
  73. # define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
  74. #else
  75. # define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  76. #endif
  77. #define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof (__u32))
  78. #ifdef __KERNEL__
  79. # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
  80. #else
  81. # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
  82. #endif
  83. #ifdef __KERNEL__
  84. #define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
  85. #define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
  86. #define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
  87. #else
  88. #define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
  89. EXT4_GOOD_OLD_INODE_SIZE : \
  90. (s)->s_inode_size)
  91. #define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
  92. EXT4_GOOD_OLD_FIRST_INO : \
  93. (s)->s_first_ino)
  94. #endif
  95. #define EXT4_BLOCK_ALIGN(size, blkbits) ALIGN((size), (1 << (blkbits)))
  96. /*
  97. * Macro-instructions used to manage fragments
  98. */
  99. #define EXT4_MIN_FRAG_SIZE 1024
  100. #define EXT4_MAX_FRAG_SIZE 4096
  101. #define EXT4_MIN_FRAG_LOG_SIZE 10
  102. #ifdef __KERNEL__
  103. # define EXT4_FRAG_SIZE(s) (EXT4_SB(s)->s_frag_size)
  104. # define EXT4_FRAGS_PER_BLOCK(s) (EXT4_SB(s)->s_frags_per_block)
  105. #else
  106. # define EXT4_FRAG_SIZE(s) (EXT4_MIN_FRAG_SIZE << (s)->s_log_frag_size)
  107. # define EXT4_FRAGS_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_FRAG_SIZE(s))
  108. #endif
  109. /*
  110. * Structure of a blocks group descriptor
  111. */
  112. struct ext4_group_desc
  113. {
  114. __le32 bg_block_bitmap; /* Blocks bitmap block */
  115. __le32 bg_inode_bitmap; /* Inodes bitmap block */
  116. __le32 bg_inode_table; /* Inodes table block */
  117. __le16 bg_free_blocks_count; /* Free blocks count */
  118. __le16 bg_free_inodes_count; /* Free inodes count */
  119. __le16 bg_used_dirs_count; /* Directories count */
  120. __u16 bg_flags;
  121. __u32 bg_reserved[3];
  122. __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
  123. __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
  124. __le32 bg_inode_table_hi; /* Inodes table block MSB */
  125. };
  126. #ifdef __KERNEL__
  127. #include <linux/ext4_fs_i.h>
  128. #include <linux/ext4_fs_sb.h>
  129. #endif
  130. /*
  131. * Macro-instructions used to manage group descriptors
  132. */
  133. #define EXT4_MIN_DESC_SIZE 32
  134. #define EXT4_MIN_DESC_SIZE_64BIT 64
  135. #define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
  136. #define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
  137. #ifdef __KERNEL__
  138. # define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
  139. # define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
  140. # define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
  141. # define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
  142. #else
  143. # define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
  144. # define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
  145. # define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
  146. #endif
  147. /*
  148. * Constants relative to the data blocks
  149. */
  150. #define EXT4_NDIR_BLOCKS 12
  151. #define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
  152. #define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
  153. #define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
  154. #define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
  155. /*
  156. * Inode flags
  157. */
  158. #define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
  159. #define EXT4_UNRM_FL 0x00000002 /* Undelete */
  160. #define EXT4_COMPR_FL 0x00000004 /* Compress file */
  161. #define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
  162. #define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
  163. #define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
  164. #define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
  165. #define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
  166. /* Reserved for compression usage... */
  167. #define EXT4_DIRTY_FL 0x00000100
  168. #define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
  169. #define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
  170. #define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
  171. /* End compression flags --- maybe not all used */
  172. #define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
  173. #define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
  174. #define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
  175. #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
  176. #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
  177. #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
  178. #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
  179. #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
  180. #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
  181. #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
  182. /*
  183. * Inode dynamic state flags
  184. */
  185. #define EXT4_STATE_JDATA 0x00000001 /* journaled data exists */
  186. #define EXT4_STATE_NEW 0x00000002 /* inode is newly created */
  187. #define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */
  188. /* Used to pass group descriptor data when online resize is done */
  189. struct ext4_new_group_input {
  190. __u32 group; /* Group number for this data */
  191. __u64 block_bitmap; /* Absolute block number of block bitmap */
  192. __u64 inode_bitmap; /* Absolute block number of inode bitmap */
  193. __u64 inode_table; /* Absolute block number of inode table start */
  194. __u32 blocks_count; /* Total number of blocks in this group */
  195. __u16 reserved_blocks; /* Number of reserved blocks in this group */
  196. __u16 unused;
  197. };
  198. /* The struct ext4_new_group_input in kernel space, with free_blocks_count */
  199. struct ext4_new_group_data {
  200. __u32 group;
  201. __u64 block_bitmap;
  202. __u64 inode_bitmap;
  203. __u64 inode_table;
  204. __u32 blocks_count;
  205. __u16 reserved_blocks;
  206. __u16 unused;
  207. __u32 free_blocks_count;
  208. };
  209. /*
  210. * Following is used by preallocation code to tell get_blocks() that we
  211. * want uninitialzed extents.
  212. */
  213. #define EXT4_CREATE_UNINITIALIZED_EXT 2
  214. /*
  215. * ioctl commands
  216. */
  217. #define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
  218. #define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
  219. #define EXT4_IOC_GETVERSION _IOR('f', 3, long)
  220. #define EXT4_IOC_SETVERSION _IOW('f', 4, long)
  221. #define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
  222. #define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
  223. #define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
  224. #define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
  225. #ifdef CONFIG_JBD2_DEBUG
  226. #define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
  227. #endif
  228. #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
  229. #define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
  230. /*
  231. * ioctl commands in 32 bit emulation
  232. */
  233. #define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
  234. #define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
  235. #define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
  236. #define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
  237. #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
  238. #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
  239. #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
  240. #ifdef CONFIG_JBD2_DEBUG
  241. #define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
  242. #endif
  243. #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
  244. #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
  245. /*
  246. * Mount options
  247. */
  248. struct ext4_mount_options {
  249. unsigned long s_mount_opt;
  250. uid_t s_resuid;
  251. gid_t s_resgid;
  252. unsigned long s_commit_interval;
  253. #ifdef CONFIG_QUOTA
  254. int s_jquota_fmt;
  255. char *s_qf_names[MAXQUOTAS];
  256. #endif
  257. };
  258. /*
  259. * Structure of an inode on the disk
  260. */
  261. struct ext4_inode {
  262. __le16 i_mode; /* File mode */
  263. __le16 i_uid; /* Low 16 bits of Owner Uid */
  264. __le32 i_size; /* Size in bytes */
  265. __le32 i_atime; /* Access time */
  266. __le32 i_ctime; /* Creation time */
  267. __le32 i_mtime; /* Modification time */
  268. __le32 i_dtime; /* Deletion Time */
  269. __le16 i_gid; /* Low 16 bits of Group Id */
  270. __le16 i_links_count; /* Links count */
  271. __le32 i_blocks; /* Blocks count */
  272. __le32 i_flags; /* File flags */
  273. union {
  274. struct {
  275. __u32 l_i_reserved1;
  276. } linux1;
  277. struct {
  278. __u32 h_i_translator;
  279. } hurd1;
  280. struct {
  281. __u32 m_i_reserved1;
  282. } masix1;
  283. } osd1; /* OS dependent 1 */
  284. __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
  285. __le32 i_generation; /* File version (for NFS) */
  286. __le32 i_file_acl; /* File ACL */
  287. __le32 i_dir_acl; /* Directory ACL */
  288. __le32 i_faddr; /* Fragment address */
  289. union {
  290. struct {
  291. __u8 l_i_frag; /* Fragment number */
  292. __u8 l_i_fsize; /* Fragment size */
  293. __le16 l_i_file_acl_high;
  294. __le16 l_i_uid_high; /* these 2 fields */
  295. __le16 l_i_gid_high; /* were reserved2[0] */
  296. __u32 l_i_reserved2;
  297. } linux2;
  298. struct {
  299. __u8 h_i_frag; /* Fragment number */
  300. __u8 h_i_fsize; /* Fragment size */
  301. __u16 h_i_mode_high;
  302. __u16 h_i_uid_high;
  303. __u16 h_i_gid_high;
  304. __u32 h_i_author;
  305. } hurd2;
  306. struct {
  307. __u8 m_i_frag; /* Fragment number */
  308. __u8 m_i_fsize; /* Fragment size */
  309. __le16 m_i_file_acl_high;
  310. __u32 m_i_reserved2[2];
  311. } masix2;
  312. } osd2; /* OS dependent 2 */
  313. __le16 i_extra_isize;
  314. __le16 i_pad1;
  315. };
  316. #define i_size_high i_dir_acl
  317. #if defined(__KERNEL__) || defined(__linux__)
  318. #define i_reserved1 osd1.linux1.l_i_reserved1
  319. #define i_frag osd2.linux2.l_i_frag
  320. #define i_fsize osd2.linux2.l_i_fsize
  321. #define i_file_acl_high osd2.linux2.l_i_file_acl_high
  322. #define i_uid_low i_uid
  323. #define i_gid_low i_gid
  324. #define i_uid_high osd2.linux2.l_i_uid_high
  325. #define i_gid_high osd2.linux2.l_i_gid_high
  326. #define i_reserved2 osd2.linux2.l_i_reserved2
  327. #elif defined(__GNU__)
  328. #define i_translator osd1.hurd1.h_i_translator
  329. #define i_frag osd2.hurd2.h_i_frag;
  330. #define i_fsize osd2.hurd2.h_i_fsize;
  331. #define i_uid_high osd2.hurd2.h_i_uid_high
  332. #define i_gid_high osd2.hurd2.h_i_gid_high
  333. #define i_author osd2.hurd2.h_i_author
  334. #elif defined(__masix__)
  335. #define i_reserved1 osd1.masix1.m_i_reserved1
  336. #define i_frag osd2.masix2.m_i_frag
  337. #define i_fsize osd2.masix2.m_i_fsize
  338. #define i_file_acl_high osd2.masix2.m_i_file_acl_high
  339. #define i_reserved2 osd2.masix2.m_i_reserved2
  340. #endif /* defined(__KERNEL__) || defined(__linux__) */
  341. /*
  342. * File system states
  343. */
  344. #define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
  345. #define EXT4_ERROR_FS 0x0002 /* Errors detected */
  346. #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
  347. /*
  348. * Mount flags
  349. */
  350. #define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */
  351. #define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
  352. #define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
  353. #define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
  354. #define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
  355. #define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
  356. #define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
  357. #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
  358. #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
  359. #define EXT4_MOUNT_ABORT 0x00200 /* Fatal error detected */
  360. #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
  361. #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
  362. #define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
  363. #define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
  364. #define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
  365. #define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
  366. #define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
  367. #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
  368. #define EXT4_MOUNT_RESERVATION 0x10000 /* Preallocation */
  369. #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
  370. #define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
  371. #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
  372. #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
  373. #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
  374. #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
  375. /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
  376. #ifndef _LINUX_EXT2_FS_H
  377. #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
  378. #define set_opt(o, opt) o |= EXT4_MOUNT_##opt
  379. #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
  380. EXT4_MOUNT_##opt)
  381. #else
  382. #define EXT2_MOUNT_NOLOAD EXT4_MOUNT_NOLOAD
  383. #define EXT2_MOUNT_ABORT EXT4_MOUNT_ABORT
  384. #define EXT2_MOUNT_DATA_FLAGS EXT4_MOUNT_DATA_FLAGS
  385. #endif
  386. #define ext4_set_bit ext2_set_bit
  387. #define ext4_set_bit_atomic ext2_set_bit_atomic
  388. #define ext4_clear_bit ext2_clear_bit
  389. #define ext4_clear_bit_atomic ext2_clear_bit_atomic
  390. #define ext4_test_bit ext2_test_bit
  391. #define ext4_find_first_zero_bit ext2_find_first_zero_bit
  392. #define ext4_find_next_zero_bit ext2_find_next_zero_bit
  393. /*
  394. * Maximal mount counts between two filesystem checks
  395. */
  396. #define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
  397. #define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
  398. /*
  399. * Behaviour when detecting errors
  400. */
  401. #define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
  402. #define EXT4_ERRORS_RO 2 /* Remount fs read-only */
  403. #define EXT4_ERRORS_PANIC 3 /* Panic */
  404. #define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
  405. /*
  406. * Structure of the super block
  407. */
  408. struct ext4_super_block {
  409. /*00*/ __le32 s_inodes_count; /* Inodes count */
  410. __le32 s_blocks_count; /* Blocks count */
  411. __le32 s_r_blocks_count; /* Reserved blocks count */
  412. __le32 s_free_blocks_count; /* Free blocks count */
  413. /*10*/ __le32 s_free_inodes_count; /* Free inodes count */
  414. __le32 s_first_data_block; /* First Data Block */
  415. __le32 s_log_block_size; /* Block size */
  416. __le32 s_log_frag_size; /* Fragment size */
  417. /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
  418. __le32 s_frags_per_group; /* # Fragments per group */
  419. __le32 s_inodes_per_group; /* # Inodes per group */
  420. __le32 s_mtime; /* Mount time */
  421. /*30*/ __le32 s_wtime; /* Write time */
  422. __le16 s_mnt_count; /* Mount count */
  423. __le16 s_max_mnt_count; /* Maximal mount count */
  424. __le16 s_magic; /* Magic signature */
  425. __le16 s_state; /* File system state */
  426. __le16 s_errors; /* Behaviour when detecting errors */
  427. __le16 s_minor_rev_level; /* minor revision level */
  428. /*40*/ __le32 s_lastcheck; /* time of last check */
  429. __le32 s_checkinterval; /* max. time between checks */
  430. __le32 s_creator_os; /* OS */
  431. __le32 s_rev_level; /* Revision level */
  432. /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
  433. __le16 s_def_resgid; /* Default gid for reserved blocks */
  434. /*
  435. * These fields are for EXT4_DYNAMIC_REV superblocks only.
  436. *
  437. * Note: the difference between the compatible feature set and
  438. * the incompatible feature set is that if there is a bit set
  439. * in the incompatible feature set that the kernel doesn't
  440. * know about, it should refuse to mount the filesystem.
  441. *
  442. * e2fsck's requirements are more strict; if it doesn't know
  443. * about a feature in either the compatible or incompatible
  444. * feature set, it must abort and not try to meddle with
  445. * things it doesn't understand...
  446. */
  447. __le32 s_first_ino; /* First non-reserved inode */
  448. __le16 s_inode_size; /* size of inode structure */
  449. __le16 s_block_group_nr; /* block group # of this superblock */
  450. __le32 s_feature_compat; /* compatible feature set */
  451. /*60*/ __le32 s_feature_incompat; /* incompatible feature set */
  452. __le32 s_feature_ro_compat; /* readonly-compatible feature set */
  453. /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
  454. /*78*/ char s_volume_name[16]; /* volume name */
  455. /*88*/ char s_last_mounted[64]; /* directory where last mounted */
  456. /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
  457. /*
  458. * Performance hints. Directory preallocation should only
  459. * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
  460. */
  461. __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
  462. __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
  463. __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
  464. /*
  465. * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
  466. */
  467. /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
  468. /*E0*/ __le32 s_journal_inum; /* inode number of journal file */
  469. __le32 s_journal_dev; /* device number of journal file */
  470. __le32 s_last_orphan; /* start of list of inodes to delete */
  471. __le32 s_hash_seed[4]; /* HTREE hash seed */
  472. __u8 s_def_hash_version; /* Default hash version to use */
  473. __u8 s_reserved_char_pad;
  474. __le16 s_desc_size; /* size of group descriptor */
  475. /*100*/ __le32 s_default_mount_opts;
  476. __le32 s_first_meta_bg; /* First metablock block group */
  477. __le32 s_mkfs_time; /* When the filesystem was created */
  478. __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
  479. /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
  480. /*150*/ __le32 s_blocks_count_hi; /* Blocks count */
  481. __le32 s_r_blocks_count_hi; /* Reserved blocks count */
  482. __le32 s_free_blocks_count_hi; /* Free blocks count */
  483. __u16 s_min_extra_isize; /* All inodes have at least # bytes */
  484. __u16 s_want_extra_isize; /* New inodes should reserve # bytes */
  485. __u32 s_flags; /* Miscellaneous flags */
  486. __u16 s_raid_stride; /* RAID stride */
  487. __u16 s_mmp_interval; /* # seconds to wait in MMP checking */
  488. __u64 s_mmp_block; /* Block for multi-mount protection */
  489. __u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
  490. __u32 s_reserved[163]; /* Padding to the end of the block */
  491. };
  492. #ifdef __KERNEL__
  493. static inline struct ext4_sb_info * EXT4_SB(struct super_block *sb)
  494. {
  495. return sb->s_fs_info;
  496. }
  497. static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
  498. {
  499. return container_of(inode, struct ext4_inode_info, vfs_inode);
  500. }
  501. static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
  502. {
  503. return ino == EXT4_ROOT_INO ||
  504. ino == EXT4_JOURNAL_INO ||
  505. ino == EXT4_RESIZE_INO ||
  506. (ino >= EXT4_FIRST_INO(sb) &&
  507. ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
  508. }
  509. #else
  510. /* Assume that user mode programs are passing in an ext4fs superblock, not
  511. * a kernel struct super_block. This will allow us to call the feature-test
  512. * macros from user land. */
  513. #define EXT4_SB(sb) (sb)
  514. #endif
  515. #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
  516. /*
  517. * Codes for operating systems
  518. */
  519. #define EXT4_OS_LINUX 0
  520. #define EXT4_OS_HURD 1
  521. #define EXT4_OS_MASIX 2
  522. #define EXT4_OS_FREEBSD 3
  523. #define EXT4_OS_LITES 4
  524. /*
  525. * Revision levels
  526. */
  527. #define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
  528. #define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
  529. #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
  530. #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
  531. #define EXT4_GOOD_OLD_INODE_SIZE 128
  532. /*
  533. * Feature set definitions
  534. */
  535. #define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
  536. ( EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
  537. #define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
  538. ( EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
  539. #define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \
  540. ( EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
  541. #define EXT4_SET_COMPAT_FEATURE(sb,mask) \
  542. EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
  543. #define EXT4_SET_RO_COMPAT_FEATURE(sb,mask) \
  544. EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
  545. #define EXT4_SET_INCOMPAT_FEATURE(sb,mask) \
  546. EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
  547. #define EXT4_CLEAR_COMPAT_FEATURE(sb,mask) \
  548. EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
  549. #define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
  550. EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
  551. #define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask) \
  552. EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
  553. #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
  554. #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
  555. #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
  556. #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
  557. #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
  558. #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
  559. #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
  560. #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
  561. #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
  562. #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
  563. #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
  564. #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
  565. #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
  566. #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
  567. #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
  568. #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
  569. #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
  570. #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
  571. EXT4_FEATURE_INCOMPAT_RECOVER| \
  572. EXT4_FEATURE_INCOMPAT_META_BG| \
  573. EXT4_FEATURE_INCOMPAT_EXTENTS| \
  574. EXT4_FEATURE_INCOMPAT_64BIT)
  575. #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
  576. EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
  577. EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
  578. /*
  579. * Default values for user and/or group using reserved blocks
  580. */
  581. #define EXT4_DEF_RESUID 0
  582. #define EXT4_DEF_RESGID 0
  583. /*
  584. * Default mount options
  585. */
  586. #define EXT4_DEFM_DEBUG 0x0001
  587. #define EXT4_DEFM_BSDGROUPS 0x0002
  588. #define EXT4_DEFM_XATTR_USER 0x0004
  589. #define EXT4_DEFM_ACL 0x0008
  590. #define EXT4_DEFM_UID16 0x0010
  591. #define EXT4_DEFM_JMODE 0x0060
  592. #define EXT4_DEFM_JMODE_DATA 0x0020
  593. #define EXT4_DEFM_JMODE_ORDERED 0x0040
  594. #define EXT4_DEFM_JMODE_WBACK 0x0060
  595. /*
  596. * Structure of a directory entry
  597. */
  598. #define EXT4_NAME_LEN 255
  599. struct ext4_dir_entry {
  600. __le32 inode; /* Inode number */
  601. __le16 rec_len; /* Directory entry length */
  602. __le16 name_len; /* Name length */
  603. char name[EXT4_NAME_LEN]; /* File name */
  604. };
  605. /*
  606. * The new version of the directory entry. Since EXT4 structures are
  607. * stored in intel byte order, and the name_len field could never be
  608. * bigger than 255 chars, it's safe to reclaim the extra byte for the
  609. * file_type field.
  610. */
  611. struct ext4_dir_entry_2 {
  612. __le32 inode; /* Inode number */
  613. __le16 rec_len; /* Directory entry length */
  614. __u8 name_len; /* Name length */
  615. __u8 file_type;
  616. char name[EXT4_NAME_LEN]; /* File name */
  617. };
  618. /*
  619. * Ext4 directory file types. Only the low 3 bits are used. The
  620. * other bits are reserved for now.
  621. */
  622. #define EXT4_FT_UNKNOWN 0
  623. #define EXT4_FT_REG_FILE 1
  624. #define EXT4_FT_DIR 2
  625. #define EXT4_FT_CHRDEV 3
  626. #define EXT4_FT_BLKDEV 4
  627. #define EXT4_FT_FIFO 5
  628. #define EXT4_FT_SOCK 6
  629. #define EXT4_FT_SYMLINK 7
  630. #define EXT4_FT_MAX 8
  631. /*
  632. * EXT4_DIR_PAD defines the directory entries boundaries
  633. *
  634. * NOTE: It must be a multiple of 4
  635. */
  636. #define EXT4_DIR_PAD 4
  637. #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
  638. #define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
  639. ~EXT4_DIR_ROUND)
  640. /*
  641. * Hash Tree Directory indexing
  642. * (c) Daniel Phillips, 2001
  643. */
  644. #ifdef CONFIG_EXT4_INDEX
  645. #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
  646. EXT4_FEATURE_COMPAT_DIR_INDEX) && \
  647. (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
  648. #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
  649. #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
  650. #else
  651. #define is_dx(dir) 0
  652. #define EXT4_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT4_LINK_MAX)
  653. #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2)
  654. #endif
  655. /* Legal values for the dx_root hash_version field: */
  656. #define DX_HASH_LEGACY 0
  657. #define DX_HASH_HALF_MD4 1
  658. #define DX_HASH_TEA 2
  659. #ifdef __KERNEL__
  660. /* hash info structure used by the directory hash */
  661. struct dx_hash_info
  662. {
  663. u32 hash;
  664. u32 minor_hash;
  665. int hash_version;
  666. u32 *seed;
  667. };
  668. #define EXT4_HTREE_EOF 0x7fffffff
  669. /*
  670. * Control parameters used by ext4_htree_next_block
  671. */
  672. #define HASH_NB_ALWAYS 1
  673. /*
  674. * Describe an inode's exact location on disk and in memory
  675. */
  676. struct ext4_iloc
  677. {
  678. struct buffer_head *bh;
  679. unsigned long offset;
  680. unsigned long block_group;
  681. };
  682. static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
  683. {
  684. return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
  685. }
  686. /*
  687. * This structure is stuffed into the struct file's private_data field
  688. * for directories. It is where we put information so that we can do
  689. * readdir operations in hash tree order.
  690. */
  691. struct dir_private_info {
  692. struct rb_root root;
  693. struct rb_node *curr_node;
  694. struct fname *extra_fname;
  695. loff_t last_pos;
  696. __u32 curr_hash;
  697. __u32 curr_minor_hash;
  698. __u32 next_hash;
  699. };
  700. /* calculate the first block number of the group */
  701. static inline ext4_fsblk_t
  702. ext4_group_first_block_no(struct super_block *sb, unsigned long group_no)
  703. {
  704. return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
  705. le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
  706. }
  707. /*
  708. * Special error return code only used by dx_probe() and its callers.
  709. */
  710. #define ERR_BAD_DX_DIR -75000
  711. void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
  712. unsigned long *blockgrpp, ext4_grpblk_t *offsetp);
  713. /*
  714. * Function prototypes
  715. */
  716. /*
  717. * Ok, these declarations are also in <linux/kernel.h> but none of the
  718. * ext4 source programs needs to include it so they are duplicated here.
  719. */
  720. # define NORET_TYPE /**/
  721. # define ATTRIB_NORET __attribute__((noreturn))
  722. # define NORET_AND noreturn,
  723. /* balloc.c */
  724. extern unsigned int ext4_block_group(struct super_block *sb,
  725. ext4_fsblk_t blocknr);
  726. extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
  727. ext4_fsblk_t blocknr);
  728. extern int ext4_bg_has_super(struct super_block *sb, int group);
  729. extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group);
  730. extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
  731. ext4_fsblk_t goal, int *errp);
  732. extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
  733. ext4_fsblk_t goal, unsigned long *count, int *errp);
  734. extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
  735. ext4_fsblk_t block, unsigned long count);
  736. extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
  737. ext4_fsblk_t block, unsigned long count,
  738. unsigned long *pdquot_freed_blocks);
  739. extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
  740. extern void ext4_check_blocks_bitmap (struct super_block *);
  741. extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
  742. unsigned int block_group,
  743. struct buffer_head ** bh);
  744. extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
  745. extern void ext4_init_block_alloc_info(struct inode *);
  746. extern void ext4_rsv_window_add(struct super_block *sb, struct ext4_reserve_window_node *rsv);
  747. /* dir.c */
  748. extern int ext4_check_dir_entry(const char *, struct inode *,
  749. struct ext4_dir_entry_2 *,
  750. struct buffer_head *, unsigned long);
  751. extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
  752. __u32 minor_hash,
  753. struct ext4_dir_entry_2 *dirent);
  754. extern void ext4_htree_free_dir_info(struct dir_private_info *p);
  755. /* fsync.c */
  756. extern int ext4_sync_file (struct file *, struct dentry *, int);
  757. /* hash.c */
  758. extern int ext4fs_dirhash(const char *name, int len, struct
  759. dx_hash_info *hinfo);
  760. /* ialloc.c */
  761. extern struct inode * ext4_new_inode (handle_t *, struct inode *, int);
  762. extern void ext4_free_inode (handle_t *, struct inode *);
  763. extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
  764. extern unsigned long ext4_count_free_inodes (struct super_block *);
  765. extern unsigned long ext4_count_dirs (struct super_block *);
  766. extern void ext4_check_inodes_bitmap (struct super_block *);
  767. extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
  768. /* inode.c */
  769. int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
  770. struct buffer_head *bh, ext4_fsblk_t blocknr);
  771. struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *);
  772. struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *);
  773. int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
  774. sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
  775. int create, int extend_disksize);
  776. extern void ext4_read_inode (struct inode *);
  777. extern int ext4_write_inode (struct inode *, int);
  778. extern int ext4_setattr (struct dentry *, struct iattr *);
  779. extern void ext4_delete_inode (struct inode *);
  780. extern int ext4_sync_inode (handle_t *, struct inode *);
  781. extern void ext4_discard_reservation (struct inode *);
  782. extern void ext4_dirty_inode(struct inode *);
  783. extern int ext4_change_inode_journal_flag(struct inode *, int);
  784. extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
  785. extern void ext4_truncate (struct inode *);
  786. extern void ext4_set_inode_flags(struct inode *);
  787. extern void ext4_get_inode_flags(struct ext4_inode_info *);
  788. extern void ext4_set_aops(struct inode *inode);
  789. extern int ext4_writepage_trans_blocks(struct inode *);
  790. extern int ext4_block_truncate_page(handle_t *handle, struct page *page,
  791. struct address_space *mapping, loff_t from);
  792. /* ioctl.c */
  793. extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
  794. unsigned long);
  795. extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
  796. /* namei.c */
  797. extern int ext4_orphan_add(handle_t *, struct inode *);
  798. extern int ext4_orphan_del(handle_t *, struct inode *);
  799. extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
  800. __u32 start_minor_hash, __u32 *next_hash);
  801. /* resize.c */
  802. extern int ext4_group_add(struct super_block *sb,
  803. struct ext4_new_group_data *input);
  804. extern int ext4_group_extend(struct super_block *sb,
  805. struct ext4_super_block *es,
  806. ext4_fsblk_t n_blocks_count);
  807. /* super.c */
  808. extern void ext4_error (struct super_block *, const char *, const char *, ...)
  809. __attribute__ ((format (printf, 3, 4)));
  810. extern void __ext4_std_error (struct super_block *, const char *, int);
  811. extern void ext4_abort (struct super_block *, const char *, const char *, ...)
  812. __attribute__ ((format (printf, 3, 4)));
  813. extern void ext4_warning (struct super_block *, const char *, const char *, ...)
  814. __attribute__ ((format (printf, 3, 4)));
  815. extern void ext4_update_dynamic_rev (struct super_block *sb);
  816. extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
  817. struct ext4_group_desc *bg);
  818. extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
  819. struct ext4_group_desc *bg);
  820. extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
  821. struct ext4_group_desc *bg);
  822. extern void ext4_block_bitmap_set(struct super_block *sb,
  823. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  824. extern void ext4_inode_bitmap_set(struct super_block *sb,
  825. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  826. extern void ext4_inode_table_set(struct super_block *sb,
  827. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  828. static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
  829. {
  830. return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
  831. le32_to_cpu(es->s_blocks_count);
  832. }
  833. static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
  834. {
  835. return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
  836. le32_to_cpu(es->s_r_blocks_count);
  837. }
  838. static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
  839. {
  840. return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
  841. le32_to_cpu(es->s_free_blocks_count);
  842. }
  843. static inline void ext4_blocks_count_set(struct ext4_super_block *es,
  844. ext4_fsblk_t blk)
  845. {
  846. es->s_blocks_count = cpu_to_le32((u32)blk);
  847. es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
  848. }
  849. static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
  850. ext4_fsblk_t blk)
  851. {
  852. es->s_free_blocks_count = cpu_to_le32((u32)blk);
  853. es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
  854. }
  855. static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
  856. ext4_fsblk_t blk)
  857. {
  858. es->s_r_blocks_count = cpu_to_le32((u32)blk);
  859. es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
  860. }
  861. #define ext4_std_error(sb, errno) \
  862. do { \
  863. if ((errno)) \
  864. __ext4_std_error((sb), __FUNCTION__, (errno)); \
  865. } while (0)
  866. /*
  867. * Inodes and files operations
  868. */
  869. /* dir.c */
  870. extern const struct file_operations ext4_dir_operations;
  871. /* file.c */
  872. extern const struct inode_operations ext4_file_inode_operations;
  873. extern const struct file_operations ext4_file_operations;
  874. /* namei.c */
  875. extern const struct inode_operations ext4_dir_inode_operations;
  876. extern const struct inode_operations ext4_special_inode_operations;
  877. /* symlink.c */
  878. extern const struct inode_operations ext4_symlink_inode_operations;
  879. extern const struct inode_operations ext4_fast_symlink_inode_operations;
  880. /* extents.c */
  881. extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
  882. extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
  883. extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
  884. ext4_fsblk_t iblock,
  885. unsigned long max_blocks, struct buffer_head *bh_result,
  886. int create, int extend_disksize);
  887. extern void ext4_ext_truncate(struct inode *, struct page *);
  888. extern void ext4_ext_init(struct super_block *);
  889. extern void ext4_ext_release(struct super_block *);
  890. extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
  891. loff_t len);
  892. static inline int
  893. ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
  894. unsigned long max_blocks, struct buffer_head *bh,
  895. int create, int extend_disksize)
  896. {
  897. if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
  898. return ext4_ext_get_blocks(handle, inode, block, max_blocks,
  899. bh, create, extend_disksize);
  900. return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
  901. create, extend_disksize);
  902. }
  903. #endif /* __KERNEL__ */
  904. #endif /* _LINUX_EXT4_FS_H */