ext4.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. /*
  2. * ext4.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 _EXT4_H
  16. #define _EXT4_H
  17. #include <linux/types.h>
  18. #include <linux/blkdev.h>
  19. #include <linux/magic.h>
  20. #include <linux/jbd2.h>
  21. #include <linux/quota.h>
  22. #include "ext4_i.h"
  23. /*
  24. * The fourth extended filesystem constants/structures
  25. */
  26. /*
  27. * Define EXT4FS_DEBUG to produce debug messages
  28. */
  29. #undef EXT4FS_DEBUG
  30. /*
  31. * Debug code
  32. */
  33. #ifdef EXT4FS_DEBUG
  34. #define ext4_debug(f, a...) \
  35. do { \
  36. printk(KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
  37. __FILE__, __LINE__, __func__); \
  38. printk(KERN_DEBUG f, ## a); \
  39. } while (0)
  40. #else
  41. #define ext4_debug(f, a...) do {} while (0)
  42. #endif
  43. /* prefer goal again. length */
  44. #define EXT4_MB_HINT_MERGE 1
  45. /* blocks already reserved */
  46. #define EXT4_MB_HINT_RESERVED 2
  47. /* metadata is being allocated */
  48. #define EXT4_MB_HINT_METADATA 4
  49. /* first blocks in the file */
  50. #define EXT4_MB_HINT_FIRST 8
  51. /* search for the best chunk */
  52. #define EXT4_MB_HINT_BEST 16
  53. /* data is being allocated */
  54. #define EXT4_MB_HINT_DATA 32
  55. /* don't preallocate (for tails) */
  56. #define EXT4_MB_HINT_NOPREALLOC 64
  57. /* allocate for locality group */
  58. #define EXT4_MB_HINT_GROUP_ALLOC 128
  59. /* allocate goal blocks or none */
  60. #define EXT4_MB_HINT_GOAL_ONLY 256
  61. /* goal is meaningful */
  62. #define EXT4_MB_HINT_TRY_GOAL 512
  63. /* blocks already pre-reserved by delayed allocation */
  64. #define EXT4_MB_DELALLOC_RESERVED 1024
  65. struct ext4_allocation_request {
  66. /* target inode for block we're allocating */
  67. struct inode *inode;
  68. /* logical block in target inode */
  69. ext4_lblk_t logical;
  70. /* phys. target (a hint) */
  71. ext4_fsblk_t goal;
  72. /* the closest logical allocated block to the left */
  73. ext4_lblk_t lleft;
  74. /* phys. block for ^^^ */
  75. ext4_fsblk_t pleft;
  76. /* the closest logical allocated block to the right */
  77. ext4_lblk_t lright;
  78. /* phys. block for ^^^ */
  79. ext4_fsblk_t pright;
  80. /* how many blocks we want to allocate */
  81. unsigned int len;
  82. /* flags. see above EXT4_MB_HINT_* */
  83. unsigned int flags;
  84. };
  85. /*
  86. * Special inodes numbers
  87. */
  88. #define EXT4_BAD_INO 1 /* Bad blocks inode */
  89. #define EXT4_ROOT_INO 2 /* Root inode */
  90. #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
  91. #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
  92. #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
  93. #define EXT4_JOURNAL_INO 8 /* Journal inode */
  94. /* First non-reserved inode for old ext4 filesystems */
  95. #define EXT4_GOOD_OLD_FIRST_INO 11
  96. /*
  97. * Maximal count of links to a file
  98. */
  99. #define EXT4_LINK_MAX 65000
  100. /*
  101. * Macro-instructions used to manage several block sizes
  102. */
  103. #define EXT4_MIN_BLOCK_SIZE 1024
  104. #define EXT4_MAX_BLOCK_SIZE 65536
  105. #define EXT4_MIN_BLOCK_LOG_SIZE 10
  106. #ifdef __KERNEL__
  107. # define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
  108. #else
  109. # define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  110. #endif
  111. #define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof(__u32))
  112. #ifdef __KERNEL__
  113. # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
  114. #else
  115. # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
  116. #endif
  117. #ifdef __KERNEL__
  118. #define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
  119. #define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
  120. #define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
  121. #else
  122. #define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
  123. EXT4_GOOD_OLD_INODE_SIZE : \
  124. (s)->s_inode_size)
  125. #define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
  126. EXT4_GOOD_OLD_FIRST_INO : \
  127. (s)->s_first_ino)
  128. #endif
  129. #define EXT4_BLOCK_ALIGN(size, blkbits) ALIGN((size), (1 << (blkbits)))
  130. /*
  131. * Structure of a blocks group descriptor
  132. */
  133. struct ext4_group_desc
  134. {
  135. __le32 bg_block_bitmap_lo; /* Blocks bitmap block */
  136. __le32 bg_inode_bitmap_lo; /* Inodes bitmap block */
  137. __le32 bg_inode_table_lo; /* Inodes table block */
  138. __le16 bg_free_blocks_count_lo;/* Free blocks count */
  139. __le16 bg_free_inodes_count_lo;/* Free inodes count */
  140. __le16 bg_used_dirs_count_lo; /* Directories count */
  141. __le16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
  142. __u32 bg_reserved[2]; /* Likely block/inode bitmap checksum */
  143. __le16 bg_itable_unused_lo; /* Unused inodes count */
  144. __le16 bg_checksum; /* crc16(sb_uuid+group+desc) */
  145. __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
  146. __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
  147. __le32 bg_inode_table_hi; /* Inodes table block MSB */
  148. __le16 bg_free_blocks_count_hi;/* Free blocks count MSB */
  149. __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */
  150. __le16 bg_used_dirs_count_hi; /* Directories count MSB */
  151. __le16 bg_itable_unused_hi; /* Unused inodes count MSB */
  152. __u32 bg_reserved2[3];
  153. };
  154. /*
  155. * Structure of a flex block group info
  156. */
  157. struct flex_groups {
  158. __u32 free_inodes;
  159. __u32 free_blocks;
  160. };
  161. #define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
  162. #define EXT4_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */
  163. #define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
  164. #ifdef __KERNEL__
  165. #include "ext4_sb.h"
  166. #endif
  167. /*
  168. * Macro-instructions used to manage group descriptors
  169. */
  170. #define EXT4_MIN_DESC_SIZE 32
  171. #define EXT4_MIN_DESC_SIZE_64BIT 64
  172. #define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
  173. #define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
  174. #ifdef __KERNEL__
  175. # define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
  176. # define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
  177. # define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
  178. # define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
  179. #else
  180. # define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
  181. # define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
  182. # define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
  183. #endif
  184. /*
  185. * Constants relative to the data blocks
  186. */
  187. #define EXT4_NDIR_BLOCKS 12
  188. #define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
  189. #define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
  190. #define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
  191. #define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
  192. /*
  193. * Inode flags
  194. */
  195. #define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
  196. #define EXT4_UNRM_FL 0x00000002 /* Undelete */
  197. #define EXT4_COMPR_FL 0x00000004 /* Compress file */
  198. #define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
  199. #define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
  200. #define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
  201. #define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
  202. #define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
  203. /* Reserved for compression usage... */
  204. #define EXT4_DIRTY_FL 0x00000100
  205. #define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
  206. #define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
  207. #define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
  208. /* End compression flags --- maybe not all used */
  209. #define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
  210. #define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
  211. #define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
  212. #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
  213. #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
  214. #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
  215. #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
  216. #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
  217. #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */
  218. #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
  219. #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
  220. #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
  221. /* Flags that should be inherited by new inodes from their parent. */
  222. #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
  223. EXT4_SYNC_FL | EXT4_IMMUTABLE_FL | EXT4_APPEND_FL |\
  224. EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
  225. EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
  226. EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL)
  227. /* Flags that are appropriate for regular files (all but dir-specific ones). */
  228. #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL))
  229. /* Flags that are appropriate for non-directories/regular files. */
  230. #define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
  231. /* Mask out flags that are inappropriate for the given type of inode. */
  232. static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
  233. {
  234. if (S_ISDIR(mode))
  235. return flags;
  236. else if (S_ISREG(mode))
  237. return flags & EXT4_REG_FLMASK;
  238. else
  239. return flags & EXT4_OTHER_FLMASK;
  240. }
  241. /*
  242. * Inode dynamic state flags
  243. */
  244. #define EXT4_STATE_JDATA 0x00000001 /* journaled data exists */
  245. #define EXT4_STATE_NEW 0x00000002 /* inode is newly created */
  246. #define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */
  247. #define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */
  248. /* Used to pass group descriptor data when online resize is done */
  249. struct ext4_new_group_input {
  250. __u32 group; /* Group number for this data */
  251. __u64 block_bitmap; /* Absolute block number of block bitmap */
  252. __u64 inode_bitmap; /* Absolute block number of inode bitmap */
  253. __u64 inode_table; /* Absolute block number of inode table start */
  254. __u32 blocks_count; /* Total number of blocks in this group */
  255. __u16 reserved_blocks; /* Number of reserved blocks in this group */
  256. __u16 unused;
  257. };
  258. /* The struct ext4_new_group_input in kernel space, with free_blocks_count */
  259. struct ext4_new_group_data {
  260. __u32 group;
  261. __u64 block_bitmap;
  262. __u64 inode_bitmap;
  263. __u64 inode_table;
  264. __u32 blocks_count;
  265. __u16 reserved_blocks;
  266. __u16 unused;
  267. __u32 free_blocks_count;
  268. };
  269. /*
  270. * Following is used by preallocation code to tell get_blocks() that we
  271. * want uninitialzed extents.
  272. */
  273. #define EXT4_CREATE_UNINITIALIZED_EXT 2
  274. /*
  275. * ioctl commands
  276. */
  277. #define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
  278. #define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
  279. #define EXT4_IOC_GETVERSION _IOR('f', 3, long)
  280. #define EXT4_IOC_SETVERSION _IOW('f', 4, long)
  281. #define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
  282. #define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
  283. #ifdef CONFIG_JBD2_DEBUG
  284. #define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
  285. #endif
  286. #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
  287. #define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
  288. #define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
  289. #define EXT4_IOC_GROUP_ADD _IOW('f', 8, struct ext4_new_group_input)
  290. #define EXT4_IOC_MIGRATE _IO('f', 9)
  291. /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */
  292. /*
  293. * ioctl commands in 32 bit emulation
  294. */
  295. #define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
  296. #define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
  297. #define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
  298. #define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
  299. #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
  300. #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
  301. #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
  302. #ifdef CONFIG_JBD2_DEBUG
  303. #define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
  304. #endif
  305. #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
  306. #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
  307. /*
  308. * Mount options
  309. */
  310. struct ext4_mount_options {
  311. unsigned long s_mount_opt;
  312. uid_t s_resuid;
  313. gid_t s_resgid;
  314. unsigned long s_commit_interval;
  315. u32 s_min_batch_time, s_max_batch_time;
  316. #ifdef CONFIG_QUOTA
  317. int s_jquota_fmt;
  318. char *s_qf_names[MAXQUOTAS];
  319. #endif
  320. };
  321. /*
  322. * Structure of an inode on the disk
  323. */
  324. struct ext4_inode {
  325. __le16 i_mode; /* File mode */
  326. __le16 i_uid; /* Low 16 bits of Owner Uid */
  327. __le32 i_size_lo; /* Size in bytes */
  328. __le32 i_atime; /* Access time */
  329. __le32 i_ctime; /* Inode Change time */
  330. __le32 i_mtime; /* Modification time */
  331. __le32 i_dtime; /* Deletion Time */
  332. __le16 i_gid; /* Low 16 bits of Group Id */
  333. __le16 i_links_count; /* Links count */
  334. __le32 i_blocks_lo; /* Blocks count */
  335. __le32 i_flags; /* File flags */
  336. union {
  337. struct {
  338. __le32 l_i_version;
  339. } linux1;
  340. struct {
  341. __u32 h_i_translator;
  342. } hurd1;
  343. struct {
  344. __u32 m_i_reserved1;
  345. } masix1;
  346. } osd1; /* OS dependent 1 */
  347. __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
  348. __le32 i_generation; /* File version (for NFS) */
  349. __le32 i_file_acl_lo; /* File ACL */
  350. __le32 i_size_high;
  351. __le32 i_obso_faddr; /* Obsoleted fragment address */
  352. union {
  353. struct {
  354. __le16 l_i_blocks_high; /* were l_i_reserved1 */
  355. __le16 l_i_file_acl_high;
  356. __le16 l_i_uid_high; /* these 2 fields */
  357. __le16 l_i_gid_high; /* were reserved2[0] */
  358. __u32 l_i_reserved2;
  359. } linux2;
  360. struct {
  361. __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
  362. __u16 h_i_mode_high;
  363. __u16 h_i_uid_high;
  364. __u16 h_i_gid_high;
  365. __u32 h_i_author;
  366. } hurd2;
  367. struct {
  368. __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
  369. __le16 m_i_file_acl_high;
  370. __u32 m_i_reserved2[2];
  371. } masix2;
  372. } osd2; /* OS dependent 2 */
  373. __le16 i_extra_isize;
  374. __le16 i_pad1;
  375. __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
  376. __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
  377. __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
  378. __le32 i_crtime; /* File Creation time */
  379. __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
  380. __le32 i_version_hi; /* high 32 bits for 64-bit version */
  381. };
  382. #define EXT4_EPOCH_BITS 2
  383. #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
  384. #define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
  385. /*
  386. * Extended fields will fit into an inode if the filesystem was formatted
  387. * with large inodes (-I 256 or larger) and there are not currently any EAs
  388. * consuming all of the available space. For new inodes we always reserve
  389. * enough space for the kernel's known extended fields, but for inodes
  390. * created with an old kernel this might not have been the case. None of
  391. * the extended inode fields is critical for correct filesystem operation.
  392. * This macro checks if a certain field fits in the inode. Note that
  393. * inode-size = GOOD_OLD_INODE_SIZE + i_extra_isize
  394. */
  395. #define EXT4_FITS_IN_INODE(ext4_inode, einode, field) \
  396. ((offsetof(typeof(*ext4_inode), field) + \
  397. sizeof((ext4_inode)->field)) \
  398. <= (EXT4_GOOD_OLD_INODE_SIZE + \
  399. (einode)->i_extra_isize)) \
  400. static inline __le32 ext4_encode_extra_time(struct timespec *time)
  401. {
  402. return cpu_to_le32((sizeof(time->tv_sec) > 4 ?
  403. time->tv_sec >> 32 : 0) |
  404. ((time->tv_nsec << 2) & EXT4_NSEC_MASK));
  405. }
  406. static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
  407. {
  408. if (sizeof(time->tv_sec) > 4)
  409. time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK)
  410. << 32;
  411. time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
  412. }
  413. #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \
  414. do { \
  415. (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
  416. if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
  417. (raw_inode)->xtime ## _extra = \
  418. ext4_encode_extra_time(&(inode)->xtime); \
  419. } while (0)
  420. #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \
  421. do { \
  422. if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
  423. (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec); \
  424. if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
  425. (raw_inode)->xtime ## _extra = \
  426. ext4_encode_extra_time(&(einode)->xtime); \
  427. } while (0)
  428. #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
  429. do { \
  430. (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
  431. if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
  432. ext4_decode_extra_time(&(inode)->xtime, \
  433. raw_inode->xtime ## _extra); \
  434. } while (0)
  435. #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \
  436. do { \
  437. if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
  438. (einode)->xtime.tv_sec = \
  439. (signed)le32_to_cpu((raw_inode)->xtime); \
  440. if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
  441. ext4_decode_extra_time(&(einode)->xtime, \
  442. raw_inode->xtime ## _extra); \
  443. } while (0)
  444. #define i_disk_version osd1.linux1.l_i_version
  445. #if defined(__KERNEL__) || defined(__linux__)
  446. #define i_reserved1 osd1.linux1.l_i_reserved1
  447. #define i_file_acl_high osd2.linux2.l_i_file_acl_high
  448. #define i_blocks_high osd2.linux2.l_i_blocks_high
  449. #define i_uid_low i_uid
  450. #define i_gid_low i_gid
  451. #define i_uid_high osd2.linux2.l_i_uid_high
  452. #define i_gid_high osd2.linux2.l_i_gid_high
  453. #define i_reserved2 osd2.linux2.l_i_reserved2
  454. #elif defined(__GNU__)
  455. #define i_translator osd1.hurd1.h_i_translator
  456. #define i_uid_high osd2.hurd2.h_i_uid_high
  457. #define i_gid_high osd2.hurd2.h_i_gid_high
  458. #define i_author osd2.hurd2.h_i_author
  459. #elif defined(__masix__)
  460. #define i_reserved1 osd1.masix1.m_i_reserved1
  461. #define i_file_acl_high osd2.masix2.m_i_file_acl_high
  462. #define i_reserved2 osd2.masix2.m_i_reserved2
  463. #endif /* defined(__KERNEL__) || defined(__linux__) */
  464. /*
  465. * File system states
  466. */
  467. #define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
  468. #define EXT4_ERROR_FS 0x0002 /* Errors detected */
  469. #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
  470. /*
  471. * Misc. filesystem flags
  472. */
  473. #define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */
  474. #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */
  475. #define EXT2_FLAGS_TEST_FILESYS 0x0004 /* to test development code */
  476. /*
  477. * Mount flags
  478. */
  479. #define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
  480. #define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
  481. #define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
  482. #define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
  483. #define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
  484. #define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
  485. #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
  486. #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
  487. #define EXT4_MOUNT_ABORT 0x00200 /* Fatal error detected */
  488. #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
  489. #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
  490. #define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
  491. #define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
  492. #define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
  493. #define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
  494. #define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
  495. #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
  496. #define EXT4_MOUNT_RESERVATION 0x10000 /* Preallocation */
  497. #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
  498. #define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
  499. #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
  500. #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
  501. #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
  502. #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
  503. #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
  504. #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
  505. #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
  506. #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
  507. /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
  508. #ifndef _LINUX_EXT2_FS_H
  509. #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
  510. #define set_opt(o, opt) o |= EXT4_MOUNT_##opt
  511. #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
  512. EXT4_MOUNT_##opt)
  513. #else
  514. #define EXT2_MOUNT_NOLOAD EXT4_MOUNT_NOLOAD
  515. #define EXT2_MOUNT_ABORT EXT4_MOUNT_ABORT
  516. #define EXT2_MOUNT_DATA_FLAGS EXT4_MOUNT_DATA_FLAGS
  517. #endif
  518. #define ext4_set_bit ext2_set_bit
  519. #define ext4_set_bit_atomic ext2_set_bit_atomic
  520. #define ext4_clear_bit ext2_clear_bit
  521. #define ext4_clear_bit_atomic ext2_clear_bit_atomic
  522. #define ext4_test_bit ext2_test_bit
  523. #define ext4_find_first_zero_bit ext2_find_first_zero_bit
  524. #define ext4_find_next_zero_bit ext2_find_next_zero_bit
  525. #define ext4_find_next_bit ext2_find_next_bit
  526. /*
  527. * Maximal mount counts between two filesystem checks
  528. */
  529. #define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
  530. #define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
  531. /*
  532. * Behaviour when detecting errors
  533. */
  534. #define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
  535. #define EXT4_ERRORS_RO 2 /* Remount fs read-only */
  536. #define EXT4_ERRORS_PANIC 3 /* Panic */
  537. #define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
  538. /*
  539. * Structure of the super block
  540. */
  541. struct ext4_super_block {
  542. /*00*/ __le32 s_inodes_count; /* Inodes count */
  543. __le32 s_blocks_count_lo; /* Blocks count */
  544. __le32 s_r_blocks_count_lo; /* Reserved blocks count */
  545. __le32 s_free_blocks_count_lo; /* Free blocks count */
  546. /*10*/ __le32 s_free_inodes_count; /* Free inodes count */
  547. __le32 s_first_data_block; /* First Data Block */
  548. __le32 s_log_block_size; /* Block size */
  549. __le32 s_obso_log_frag_size; /* Obsoleted fragment size */
  550. /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
  551. __le32 s_obso_frags_per_group; /* Obsoleted fragments per group */
  552. __le32 s_inodes_per_group; /* # Inodes per group */
  553. __le32 s_mtime; /* Mount time */
  554. /*30*/ __le32 s_wtime; /* Write time */
  555. __le16 s_mnt_count; /* Mount count */
  556. __le16 s_max_mnt_count; /* Maximal mount count */
  557. __le16 s_magic; /* Magic signature */
  558. __le16 s_state; /* File system state */
  559. __le16 s_errors; /* Behaviour when detecting errors */
  560. __le16 s_minor_rev_level; /* minor revision level */
  561. /*40*/ __le32 s_lastcheck; /* time of last check */
  562. __le32 s_checkinterval; /* max. time between checks */
  563. __le32 s_creator_os; /* OS */
  564. __le32 s_rev_level; /* Revision level */
  565. /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
  566. __le16 s_def_resgid; /* Default gid for reserved blocks */
  567. /*
  568. * These fields are for EXT4_DYNAMIC_REV superblocks only.
  569. *
  570. * Note: the difference between the compatible feature set and
  571. * the incompatible feature set is that if there is a bit set
  572. * in the incompatible feature set that the kernel doesn't
  573. * know about, it should refuse to mount the filesystem.
  574. *
  575. * e2fsck's requirements are more strict; if it doesn't know
  576. * about a feature in either the compatible or incompatible
  577. * feature set, it must abort and not try to meddle with
  578. * things it doesn't understand...
  579. */
  580. __le32 s_first_ino; /* First non-reserved inode */
  581. __le16 s_inode_size; /* size of inode structure */
  582. __le16 s_block_group_nr; /* block group # of this superblock */
  583. __le32 s_feature_compat; /* compatible feature set */
  584. /*60*/ __le32 s_feature_incompat; /* incompatible feature set */
  585. __le32 s_feature_ro_compat; /* readonly-compatible feature set */
  586. /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
  587. /*78*/ char s_volume_name[16]; /* volume name */
  588. /*88*/ char s_last_mounted[64]; /* directory where last mounted */
  589. /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
  590. /*
  591. * Performance hints. Directory preallocation should only
  592. * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
  593. */
  594. __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
  595. __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
  596. __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
  597. /*
  598. * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
  599. */
  600. /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
  601. /*E0*/ __le32 s_journal_inum; /* inode number of journal file */
  602. __le32 s_journal_dev; /* device number of journal file */
  603. __le32 s_last_orphan; /* start of list of inodes to delete */
  604. __le32 s_hash_seed[4]; /* HTREE hash seed */
  605. __u8 s_def_hash_version; /* Default hash version to use */
  606. __u8 s_reserved_char_pad;
  607. __le16 s_desc_size; /* size of group descriptor */
  608. /*100*/ __le32 s_default_mount_opts;
  609. __le32 s_first_meta_bg; /* First metablock block group */
  610. __le32 s_mkfs_time; /* When the filesystem was created */
  611. __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
  612. /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
  613. /*150*/ __le32 s_blocks_count_hi; /* Blocks count */
  614. __le32 s_r_blocks_count_hi; /* Reserved blocks count */
  615. __le32 s_free_blocks_count_hi; /* Free blocks count */
  616. __le16 s_min_extra_isize; /* All inodes have at least # bytes */
  617. __le16 s_want_extra_isize; /* New inodes should reserve # bytes */
  618. __le32 s_flags; /* Miscellaneous flags */
  619. __le16 s_raid_stride; /* RAID stride */
  620. __le16 s_mmp_interval; /* # seconds to wait in MMP checking */
  621. __le64 s_mmp_block; /* Block for multi-mount protection */
  622. __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
  623. __u8 s_log_groups_per_flex; /* FLEX_BG group size */
  624. __u8 s_reserved_char_pad2;
  625. __le16 s_reserved_pad;
  626. __u32 s_reserved[162]; /* Padding to the end of the block */
  627. };
  628. #ifdef __KERNEL__
  629. static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
  630. {
  631. return sb->s_fs_info;
  632. }
  633. static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
  634. {
  635. return container_of(inode, struct ext4_inode_info, vfs_inode);
  636. }
  637. static inline struct timespec ext4_current_time(struct inode *inode)
  638. {
  639. return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
  640. current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
  641. }
  642. static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
  643. {
  644. return ino == EXT4_ROOT_INO ||
  645. ino == EXT4_JOURNAL_INO ||
  646. ino == EXT4_RESIZE_INO ||
  647. (ino >= EXT4_FIRST_INO(sb) &&
  648. ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
  649. }
  650. #else
  651. /* Assume that user mode programs are passing in an ext4fs superblock, not
  652. * a kernel struct super_block. This will allow us to call the feature-test
  653. * macros from user land. */
  654. #define EXT4_SB(sb) (sb)
  655. #endif
  656. #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
  657. /*
  658. * Codes for operating systems
  659. */
  660. #define EXT4_OS_LINUX 0
  661. #define EXT4_OS_HURD 1
  662. #define EXT4_OS_MASIX 2
  663. #define EXT4_OS_FREEBSD 3
  664. #define EXT4_OS_LITES 4
  665. /*
  666. * Revision levels
  667. */
  668. #define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
  669. #define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
  670. #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
  671. #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
  672. #define EXT4_GOOD_OLD_INODE_SIZE 128
  673. /*
  674. * Feature set definitions
  675. */
  676. #define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
  677. ((EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask)) != 0)
  678. #define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
  679. ((EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask)) != 0)
  680. #define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \
  681. ((EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask)) != 0)
  682. #define EXT4_SET_COMPAT_FEATURE(sb,mask) \
  683. EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
  684. #define EXT4_SET_RO_COMPAT_FEATURE(sb,mask) \
  685. EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
  686. #define EXT4_SET_INCOMPAT_FEATURE(sb,mask) \
  687. EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
  688. #define EXT4_CLEAR_COMPAT_FEATURE(sb,mask) \
  689. EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
  690. #define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
  691. EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
  692. #define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask) \
  693. EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
  694. #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
  695. #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
  696. #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
  697. #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
  698. #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
  699. #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
  700. #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
  701. #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
  702. #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
  703. #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
  704. #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
  705. #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
  706. #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
  707. #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
  708. #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
  709. #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
  710. #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
  711. #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
  712. #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
  713. #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
  714. #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
  715. #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
  716. #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
  717. #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
  718. EXT4_FEATURE_INCOMPAT_RECOVER| \
  719. EXT4_FEATURE_INCOMPAT_META_BG| \
  720. EXT4_FEATURE_INCOMPAT_EXTENTS| \
  721. EXT4_FEATURE_INCOMPAT_64BIT| \
  722. EXT4_FEATURE_INCOMPAT_FLEX_BG)
  723. #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
  724. EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
  725. EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
  726. EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
  727. EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
  728. EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
  729. EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
  730. /*
  731. * Default values for user and/or group using reserved blocks
  732. */
  733. #define EXT4_DEF_RESUID 0
  734. #define EXT4_DEF_RESGID 0
  735. #define EXT4_DEF_INODE_READAHEAD_BLKS 32
  736. /*
  737. * Default mount options
  738. */
  739. #define EXT4_DEFM_DEBUG 0x0001
  740. #define EXT4_DEFM_BSDGROUPS 0x0002
  741. #define EXT4_DEFM_XATTR_USER 0x0004
  742. #define EXT4_DEFM_ACL 0x0008
  743. #define EXT4_DEFM_UID16 0x0010
  744. #define EXT4_DEFM_JMODE 0x0060
  745. #define EXT4_DEFM_JMODE_DATA 0x0020
  746. #define EXT4_DEFM_JMODE_ORDERED 0x0040
  747. #define EXT4_DEFM_JMODE_WBACK 0x0060
  748. /*
  749. * Default journal batch times
  750. */
  751. #define EXT4_DEF_MIN_BATCH_TIME 0
  752. #define EXT4_DEF_MAX_BATCH_TIME 15000 /* 15ms */
  753. /*
  754. * Structure of a directory entry
  755. */
  756. #define EXT4_NAME_LEN 255
  757. struct ext4_dir_entry {
  758. __le32 inode; /* Inode number */
  759. __le16 rec_len; /* Directory entry length */
  760. __le16 name_len; /* Name length */
  761. char name[EXT4_NAME_LEN]; /* File name */
  762. };
  763. /*
  764. * The new version of the directory entry. Since EXT4 structures are
  765. * stored in intel byte order, and the name_len field could never be
  766. * bigger than 255 chars, it's safe to reclaim the extra byte for the
  767. * file_type field.
  768. */
  769. struct ext4_dir_entry_2 {
  770. __le32 inode; /* Inode number */
  771. __le16 rec_len; /* Directory entry length */
  772. __u8 name_len; /* Name length */
  773. __u8 file_type;
  774. char name[EXT4_NAME_LEN]; /* File name */
  775. };
  776. /*
  777. * Ext4 directory file types. Only the low 3 bits are used. The
  778. * other bits are reserved for now.
  779. */
  780. #define EXT4_FT_UNKNOWN 0
  781. #define EXT4_FT_REG_FILE 1
  782. #define EXT4_FT_DIR 2
  783. #define EXT4_FT_CHRDEV 3
  784. #define EXT4_FT_BLKDEV 4
  785. #define EXT4_FT_FIFO 5
  786. #define EXT4_FT_SOCK 6
  787. #define EXT4_FT_SYMLINK 7
  788. #define EXT4_FT_MAX 8
  789. /*
  790. * EXT4_DIR_PAD defines the directory entries boundaries
  791. *
  792. * NOTE: It must be a multiple of 4
  793. */
  794. #define EXT4_DIR_PAD 4
  795. #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
  796. #define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
  797. ~EXT4_DIR_ROUND)
  798. #define EXT4_MAX_REC_LEN ((1<<16)-1)
  799. /*
  800. * Hash Tree Directory indexing
  801. * (c) Daniel Phillips, 2001
  802. */
  803. #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
  804. EXT4_FEATURE_COMPAT_DIR_INDEX) && \
  805. (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
  806. #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
  807. #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
  808. /* Legal values for the dx_root hash_version field: */
  809. #define DX_HASH_LEGACY 0
  810. #define DX_HASH_HALF_MD4 1
  811. #define DX_HASH_TEA 2
  812. #define DX_HASH_LEGACY_UNSIGNED 3
  813. #define DX_HASH_HALF_MD4_UNSIGNED 4
  814. #define DX_HASH_TEA_UNSIGNED 5
  815. #ifdef __KERNEL__
  816. /* hash info structure used by the directory hash */
  817. struct dx_hash_info
  818. {
  819. u32 hash;
  820. u32 minor_hash;
  821. int hash_version;
  822. u32 *seed;
  823. };
  824. #define EXT4_HTREE_EOF 0x7fffffff
  825. /*
  826. * Control parameters used by ext4_htree_next_block
  827. */
  828. #define HASH_NB_ALWAYS 1
  829. /*
  830. * Describe an inode's exact location on disk and in memory
  831. */
  832. struct ext4_iloc
  833. {
  834. struct buffer_head *bh;
  835. unsigned long offset;
  836. ext4_group_t block_group;
  837. };
  838. static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
  839. {
  840. return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
  841. }
  842. /*
  843. * This structure is stuffed into the struct file's private_data field
  844. * for directories. It is where we put information so that we can do
  845. * readdir operations in hash tree order.
  846. */
  847. struct dir_private_info {
  848. struct rb_root root;
  849. struct rb_node *curr_node;
  850. struct fname *extra_fname;
  851. loff_t last_pos;
  852. __u32 curr_hash;
  853. __u32 curr_minor_hash;
  854. __u32 next_hash;
  855. };
  856. /* calculate the first block number of the group */
  857. static inline ext4_fsblk_t
  858. ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
  859. {
  860. return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
  861. le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
  862. }
  863. /*
  864. * Special error return code only used by dx_probe() and its callers.
  865. */
  866. #define ERR_BAD_DX_DIR -75000
  867. void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
  868. ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp);
  869. extern struct proc_dir_entry *ext4_proc_root;
  870. #ifdef CONFIG_PROC_FS
  871. extern const struct file_operations ext4_ui_proc_fops;
  872. #define EXT4_PROC_HANDLER(name, var) \
  873. do { \
  874. proc = proc_create_data(name, mode, sbi->s_proc, \
  875. &ext4_ui_proc_fops, &sbi->s_##var); \
  876. if (proc == NULL) { \
  877. printk(KERN_ERR "EXT4-fs: can't create %s\n", name); \
  878. goto err_out; \
  879. } \
  880. } while (0)
  881. #else
  882. #define EXT4_PROC_HANDLER(name, var)
  883. #endif
  884. /*
  885. * Function prototypes
  886. */
  887. /*
  888. * Ok, these declarations are also in <linux/kernel.h> but none of the
  889. * ext4 source programs needs to include it so they are duplicated here.
  890. */
  891. # define NORET_TYPE /**/
  892. # define ATTRIB_NORET __attribute__((noreturn))
  893. # define NORET_AND noreturn,
  894. /* bitmap.c */
  895. extern unsigned int ext4_count_free(struct buffer_head *, unsigned);
  896. /* balloc.c */
  897. extern unsigned int ext4_block_group(struct super_block *sb,
  898. ext4_fsblk_t blocknr);
  899. extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
  900. ext4_fsblk_t blocknr);
  901. extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
  902. extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
  903. ext4_group_t group);
  904. extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
  905. ext4_fsblk_t goal, unsigned long *count, int *errp);
  906. extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
  907. extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
  908. extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
  909. ext4_fsblk_t block, unsigned long count, int metadata);
  910. extern void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
  911. ext4_fsblk_t block, unsigned long count);
  912. extern ext4_fsblk_t ext4_count_free_blocks(struct super_block *);
  913. extern void ext4_check_blocks_bitmap(struct super_block *);
  914. extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
  915. ext4_group_t block_group,
  916. struct buffer_head ** bh);
  917. extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
  918. /* dir.c */
  919. extern int ext4_check_dir_entry(const char *, struct inode *,
  920. struct ext4_dir_entry_2 *,
  921. struct buffer_head *, unsigned int);
  922. extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
  923. __u32 minor_hash,
  924. struct ext4_dir_entry_2 *dirent);
  925. extern void ext4_htree_free_dir_info(struct dir_private_info *p);
  926. /* fsync.c */
  927. extern int ext4_sync_file(struct file *, struct dentry *, int);
  928. /* hash.c */
  929. extern int ext4fs_dirhash(const char *name, int len, struct
  930. dx_hash_info *hinfo);
  931. /* ialloc.c */
  932. extern struct inode * ext4_new_inode(handle_t *, struct inode *, int);
  933. extern void ext4_free_inode(handle_t *, struct inode *);
  934. extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
  935. extern unsigned long ext4_count_free_inodes(struct super_block *);
  936. extern unsigned long ext4_count_dirs(struct super_block *);
  937. extern void ext4_check_inodes_bitmap(struct super_block *);
  938. /* mballoc.c */
  939. extern long ext4_mb_stats;
  940. extern long ext4_mb_max_to_scan;
  941. extern int ext4_mb_init(struct super_block *, int);
  942. extern int ext4_mb_release(struct super_block *);
  943. extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
  944. struct ext4_allocation_request *, int *);
  945. extern int ext4_mb_reserve_blocks(struct super_block *, int);
  946. extern void ext4_discard_preallocations(struct inode *);
  947. extern int __init init_ext4_mballoc(void);
  948. extern void exit_ext4_mballoc(void);
  949. extern void ext4_mb_free_blocks(handle_t *, struct inode *,
  950. unsigned long, unsigned long, int, unsigned long *);
  951. extern int ext4_mb_add_groupinfo(struct super_block *sb,
  952. ext4_group_t i, struct ext4_group_desc *desc);
  953. extern void ext4_mb_update_group_info(struct ext4_group_info *grp,
  954. ext4_grpblk_t add);
  955. extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
  956. extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
  957. ext4_group_t, int);
  958. /* inode.c */
  959. int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
  960. struct buffer_head *bh, ext4_fsblk_t blocknr);
  961. struct buffer_head *ext4_getblk(handle_t *, struct inode *,
  962. ext4_lblk_t, int, int *);
  963. struct buffer_head *ext4_bread(handle_t *, struct inode *,
  964. ext4_lblk_t, int, int *);
  965. int ext4_get_block(struct inode *inode, sector_t iblock,
  966. struct buffer_head *bh_result, int create);
  967. extern struct inode *ext4_iget(struct super_block *, unsigned long);
  968. extern int ext4_write_inode(struct inode *, int);
  969. extern int ext4_setattr(struct dentry *, struct iattr *);
  970. extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
  971. struct kstat *stat);
  972. extern void ext4_delete_inode(struct inode *);
  973. extern int ext4_sync_inode(handle_t *, struct inode *);
  974. extern void ext4_dirty_inode(struct inode *);
  975. extern int ext4_change_inode_journal_flag(struct inode *, int);
  976. extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
  977. extern int ext4_can_truncate(struct inode *inode);
  978. extern void ext4_truncate(struct inode *);
  979. extern void ext4_set_inode_flags(struct inode *);
  980. extern void ext4_get_inode_flags(struct ext4_inode_info *);
  981. extern void ext4_set_aops(struct inode *inode);
  982. extern int ext4_writepage_trans_blocks(struct inode *);
  983. extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int idxblocks);
  984. extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
  985. extern int ext4_block_truncate_page(handle_t *handle,
  986. struct address_space *mapping, loff_t from);
  987. extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page);
  988. extern qsize_t ext4_get_reserved_space(struct inode *inode);
  989. /* ioctl.c */
  990. extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
  991. extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
  992. /* migrate.c */
  993. extern int ext4_ext_migrate(struct inode *);
  994. /* namei.c */
  995. extern unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize);
  996. extern __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize);
  997. extern int ext4_orphan_add(handle_t *, struct inode *);
  998. extern int ext4_orphan_del(handle_t *, struct inode *);
  999. extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
  1000. __u32 start_minor_hash, __u32 *next_hash);
  1001. /* resize.c */
  1002. extern int ext4_group_add(struct super_block *sb,
  1003. struct ext4_new_group_data *input);
  1004. extern int ext4_group_extend(struct super_block *sb,
  1005. struct ext4_super_block *es,
  1006. ext4_fsblk_t n_blocks_count);
  1007. /* super.c */
  1008. extern void ext4_error(struct super_block *, const char *, const char *, ...)
  1009. __attribute__ ((format (printf, 3, 4)));
  1010. extern void __ext4_std_error(struct super_block *, const char *, int);
  1011. extern void ext4_abort(struct super_block *, const char *, const char *, ...)
  1012. __attribute__ ((format (printf, 3, 4)));
  1013. extern void ext4_warning(struct super_block *, const char *, const char *, ...)
  1014. __attribute__ ((format (printf, 3, 4)));
  1015. extern void ext4_grp_locked_error(struct super_block *, ext4_group_t,
  1016. const char *, const char *, ...)
  1017. __attribute__ ((format (printf, 4, 5)));
  1018. extern void ext4_update_dynamic_rev(struct super_block *sb);
  1019. extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
  1020. __u32 compat);
  1021. extern int ext4_update_rocompat_feature(handle_t *handle,
  1022. struct super_block *sb, __u32 rocompat);
  1023. extern int ext4_update_incompat_feature(handle_t *handle,
  1024. struct super_block *sb, __u32 incompat);
  1025. extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
  1026. struct ext4_group_desc *bg);
  1027. extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
  1028. struct ext4_group_desc *bg);
  1029. extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
  1030. struct ext4_group_desc *bg);
  1031. extern __u32 ext4_free_blks_count(struct super_block *sb,
  1032. struct ext4_group_desc *bg);
  1033. extern __u32 ext4_free_inodes_count(struct super_block *sb,
  1034. struct ext4_group_desc *bg);
  1035. extern __u32 ext4_used_dirs_count(struct super_block *sb,
  1036. struct ext4_group_desc *bg);
  1037. extern __u32 ext4_itable_unused_count(struct super_block *sb,
  1038. struct ext4_group_desc *bg);
  1039. extern void ext4_block_bitmap_set(struct super_block *sb,
  1040. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  1041. extern void ext4_inode_bitmap_set(struct super_block *sb,
  1042. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  1043. extern void ext4_inode_table_set(struct super_block *sb,
  1044. struct ext4_group_desc *bg, ext4_fsblk_t blk);
  1045. extern void ext4_free_blks_set(struct super_block *sb,
  1046. struct ext4_group_desc *bg, __u32 count);
  1047. extern void ext4_free_inodes_set(struct super_block *sb,
  1048. struct ext4_group_desc *bg, __u32 count);
  1049. extern void ext4_used_dirs_set(struct super_block *sb,
  1050. struct ext4_group_desc *bg, __u32 count);
  1051. extern void ext4_itable_unused_set(struct super_block *sb,
  1052. struct ext4_group_desc *bg, __u32 count);
  1053. static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
  1054. {
  1055. return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
  1056. le32_to_cpu(es->s_blocks_count_lo);
  1057. }
  1058. static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
  1059. {
  1060. return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
  1061. le32_to_cpu(es->s_r_blocks_count_lo);
  1062. }
  1063. static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
  1064. {
  1065. return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
  1066. le32_to_cpu(es->s_free_blocks_count_lo);
  1067. }
  1068. static inline void ext4_blocks_count_set(struct ext4_super_block *es,
  1069. ext4_fsblk_t blk)
  1070. {
  1071. es->s_blocks_count_lo = cpu_to_le32((u32)blk);
  1072. es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
  1073. }
  1074. static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
  1075. ext4_fsblk_t blk)
  1076. {
  1077. es->s_free_blocks_count_lo = cpu_to_le32((u32)blk);
  1078. es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
  1079. }
  1080. static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
  1081. ext4_fsblk_t blk)
  1082. {
  1083. es->s_r_blocks_count_lo = cpu_to_le32((u32)blk);
  1084. es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
  1085. }
  1086. static inline loff_t ext4_isize(struct ext4_inode *raw_inode)
  1087. {
  1088. if (S_ISREG(le16_to_cpu(raw_inode->i_mode)))
  1089. return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) |
  1090. le32_to_cpu(raw_inode->i_size_lo);
  1091. else
  1092. return (loff_t) le32_to_cpu(raw_inode->i_size_lo);
  1093. }
  1094. static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size)
  1095. {
  1096. raw_inode->i_size_lo = cpu_to_le32(i_size);
  1097. raw_inode->i_size_high = cpu_to_le32(i_size >> 32);
  1098. }
  1099. static inline
  1100. struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
  1101. ext4_group_t group)
  1102. {
  1103. struct ext4_group_info ***grp_info;
  1104. long indexv, indexh;
  1105. grp_info = EXT4_SB(sb)->s_group_info;
  1106. indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
  1107. indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
  1108. return grp_info[indexv][indexh];
  1109. }
  1110. static inline ext4_group_t ext4_flex_group(struct ext4_sb_info *sbi,
  1111. ext4_group_t block_group)
  1112. {
  1113. return block_group >> sbi->s_log_groups_per_flex;
  1114. }
  1115. static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
  1116. {
  1117. return 1 << sbi->s_log_groups_per_flex;
  1118. }
  1119. #define ext4_std_error(sb, errno) \
  1120. do { \
  1121. if ((errno)) \
  1122. __ext4_std_error((sb), __func__, (errno)); \
  1123. } while (0)
  1124. #ifdef CONFIG_SMP
  1125. /* Each CPU can accumulate percpu_counter_batch blocks in their local
  1126. * counters. So we need to make sure we have free blocks more
  1127. * than percpu_counter_batch * nr_cpu_ids. Also add a window of 4 times.
  1128. */
  1129. #define EXT4_FREEBLOCKS_WATERMARK (4 * (percpu_counter_batch * nr_cpu_ids))
  1130. #else
  1131. #define EXT4_FREEBLOCKS_WATERMARK 0
  1132. #endif
  1133. static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
  1134. {
  1135. /*
  1136. * XXX: replace with spinlock if seen contended -bzzz
  1137. */
  1138. down_write(&EXT4_I(inode)->i_data_sem);
  1139. if (newsize > EXT4_I(inode)->i_disksize)
  1140. EXT4_I(inode)->i_disksize = newsize;
  1141. up_write(&EXT4_I(inode)->i_data_sem);
  1142. return ;
  1143. }
  1144. struct ext4_group_info {
  1145. unsigned long bb_state;
  1146. struct rb_root bb_free_root;
  1147. unsigned short bb_first_free;
  1148. unsigned short bb_free;
  1149. unsigned short bb_fragments;
  1150. struct list_head bb_prealloc_list;
  1151. #ifdef DOUBLE_CHECK
  1152. void *bb_bitmap;
  1153. #endif
  1154. struct rw_semaphore alloc_sem;
  1155. unsigned short bb_counters[];
  1156. };
  1157. #define EXT4_GROUP_INFO_NEED_INIT_BIT 0
  1158. #define EXT4_GROUP_INFO_LOCKED_BIT 1
  1159. #define EXT4_MB_GRP_NEED_INIT(grp) \
  1160. (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
  1161. static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
  1162. {
  1163. struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
  1164. bit_spin_lock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
  1165. }
  1166. static inline void ext4_unlock_group(struct super_block *sb,
  1167. ext4_group_t group)
  1168. {
  1169. struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
  1170. bit_spin_unlock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
  1171. }
  1172. static inline int ext4_is_group_locked(struct super_block *sb,
  1173. ext4_group_t group)
  1174. {
  1175. struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
  1176. return bit_spin_is_locked(EXT4_GROUP_INFO_LOCKED_BIT,
  1177. &(grinfo->bb_state));
  1178. }
  1179. /*
  1180. * Inodes and files operations
  1181. */
  1182. /* dir.c */
  1183. extern const struct file_operations ext4_dir_operations;
  1184. /* file.c */
  1185. extern const struct inode_operations ext4_file_inode_operations;
  1186. extern const struct file_operations ext4_file_operations;
  1187. /* namei.c */
  1188. extern const struct inode_operations ext4_dir_inode_operations;
  1189. extern const struct inode_operations ext4_special_inode_operations;
  1190. /* symlink.c */
  1191. extern const struct inode_operations ext4_symlink_inode_operations;
  1192. extern const struct inode_operations ext4_fast_symlink_inode_operations;
  1193. /* extents.c */
  1194. extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
  1195. extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
  1196. extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks,
  1197. int chunk);
  1198. extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
  1199. ext4_lblk_t iblock, unsigned int max_blocks,
  1200. struct buffer_head *bh_result,
  1201. int create, int extend_disksize);
  1202. extern void ext4_ext_truncate(struct inode *);
  1203. extern void ext4_ext_init(struct super_block *);
  1204. extern void ext4_ext_release(struct super_block *);
  1205. extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
  1206. loff_t len);
  1207. extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
  1208. sector_t block, unsigned int max_blocks,
  1209. struct buffer_head *bh, int create,
  1210. int extend_disksize, int flag);
  1211. extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  1212. __u64 start, __u64 len);
  1213. /*
  1214. * Add new method to test wether block and inode bitmaps are properly
  1215. * initialized. With uninit_bg reading the block from disk is not enough
  1216. * to mark the bitmap uptodate. We need to also zero-out the bitmap
  1217. */
  1218. #define BH_BITMAP_UPTODATE BH_JBDPrivateStart
  1219. static inline int bitmap_uptodate(struct buffer_head *bh)
  1220. {
  1221. return (buffer_uptodate(bh) &&
  1222. test_bit(BH_BITMAP_UPTODATE, &(bh)->b_state));
  1223. }
  1224. static inline void set_bitmap_uptodate(struct buffer_head *bh)
  1225. {
  1226. set_bit(BH_BITMAP_UPTODATE, &(bh)->b_state);
  1227. }
  1228. #endif /* __KERNEL__ */
  1229. #endif /* _EXT4_H */