diff options
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 127 |
1 files changed, 114 insertions, 13 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4daaf2b753f4..a74b89c09f90 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -108,7 +108,8 @@ typedef unsigned int ext4_group_t; | |||
108 | #define EXT4_MB_DELALLOC_RESERVED 0x0400 | 108 | #define EXT4_MB_DELALLOC_RESERVED 0x0400 |
109 | /* We are doing stream allocation */ | 109 | /* We are doing stream allocation */ |
110 | #define EXT4_MB_STREAM_ALLOC 0x0800 | 110 | #define EXT4_MB_STREAM_ALLOC 0x0800 |
111 | 111 | /* Use reserved root blocks if needed */ | |
112 | #define EXT4_MB_USE_ROOT_BLOCKS 0x1000 | ||
112 | 113 | ||
113 | struct ext4_allocation_request { | 114 | struct ext4_allocation_request { |
114 | /* target inode for block we're allocating */ | 115 | /* target inode for block we're allocating */ |
@@ -209,6 +210,8 @@ struct ext4_io_submit { | |||
209 | */ | 210 | */ |
210 | #define EXT4_BAD_INO 1 /* Bad blocks inode */ | 211 | #define EXT4_BAD_INO 1 /* Bad blocks inode */ |
211 | #define EXT4_ROOT_INO 2 /* Root inode */ | 212 | #define EXT4_ROOT_INO 2 /* Root inode */ |
213 | #define EXT4_USR_QUOTA_INO 3 /* User quota inode */ | ||
214 | #define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */ | ||
212 | #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */ | 215 | #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */ |
213 | #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */ | 216 | #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */ |
214 | #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */ | 217 | #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */ |
@@ -512,6 +515,10 @@ struct ext4_new_group_data { | |||
512 | /* Convert extent to initialized after IO complete */ | 515 | /* Convert extent to initialized after IO complete */ |
513 | #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\ | 516 | #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\ |
514 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT) | 517 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT) |
518 | /* Punch out blocks of an extent */ | ||
519 | #define EXT4_GET_BLOCKS_PUNCH_OUT_EXT 0x0020 | ||
520 | /* Don't normalize allocation size (used for fallocate) */ | ||
521 | #define EXT4_GET_BLOCKS_NO_NORMALIZE 0x0040 | ||
515 | 522 | ||
516 | /* | 523 | /* |
517 | * Flags used by ext4_free_blocks | 524 | * Flags used by ext4_free_blocks |
@@ -1028,7 +1035,7 @@ struct ext4_super_block { | |||
1028 | __le16 s_want_extra_isize; /* New inodes should reserve # bytes */ | 1035 | __le16 s_want_extra_isize; /* New inodes should reserve # bytes */ |
1029 | __le32 s_flags; /* Miscellaneous flags */ | 1036 | __le32 s_flags; /* Miscellaneous flags */ |
1030 | __le16 s_raid_stride; /* RAID stride */ | 1037 | __le16 s_raid_stride; /* RAID stride */ |
1031 | __le16 s_mmp_interval; /* # seconds to wait in MMP checking */ | 1038 | __le16 s_mmp_update_interval; /* # seconds to wait in MMP checking */ |
1032 | __le64 s_mmp_block; /* Block for multi-mount protection */ | 1039 | __le64 s_mmp_block; /* Block for multi-mount protection */ |
1033 | __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ | 1040 | __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ |
1034 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ | 1041 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ |
@@ -1144,6 +1151,9 @@ struct ext4_sb_info { | |||
1144 | unsigned long s_ext_blocks; | 1151 | unsigned long s_ext_blocks; |
1145 | unsigned long s_ext_extents; | 1152 | unsigned long s_ext_extents; |
1146 | #endif | 1153 | #endif |
1154 | /* ext4 extent cache stats */ | ||
1155 | unsigned long extent_cache_hits; | ||
1156 | unsigned long extent_cache_misses; | ||
1147 | 1157 | ||
1148 | /* for buddy allocator */ | 1158 | /* for buddy allocator */ |
1149 | struct ext4_group_info ***s_group_info; | 1159 | struct ext4_group_info ***s_group_info; |
@@ -1201,6 +1211,9 @@ struct ext4_sb_info { | |||
1201 | struct ext4_li_request *s_li_request; | 1211 | struct ext4_li_request *s_li_request; |
1202 | /* Wait multiplier for lazy initialization thread */ | 1212 | /* Wait multiplier for lazy initialization thread */ |
1203 | unsigned int s_li_wait_mult; | 1213 | unsigned int s_li_wait_mult; |
1214 | |||
1215 | /* Kernel thread for multiple mount protection */ | ||
1216 | struct task_struct *s_mmp_tsk; | ||
1204 | }; | 1217 | }; |
1205 | 1218 | ||
1206 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) | 1219 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) |
@@ -1338,6 +1351,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | |||
1338 | #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 | 1351 | #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 |
1339 | #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 | 1352 | #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 |
1340 | #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 | 1353 | #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 |
1354 | #define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100 | ||
1341 | 1355 | ||
1342 | #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001 | 1356 | #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001 |
1343 | #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002 | 1357 | #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002 |
@@ -1351,13 +1365,29 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | |||
1351 | #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */ | 1365 | #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */ |
1352 | #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */ | 1366 | #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */ |
1353 | 1367 | ||
1368 | #define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR | ||
1369 | #define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ | ||
1370 | EXT4_FEATURE_INCOMPAT_META_BG) | ||
1371 | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ | ||
1372 | EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ | ||
1373 | EXT4_FEATURE_RO_COMPAT_BTREE_DIR) | ||
1374 | |||
1375 | #define EXT3_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR | ||
1376 | #define EXT3_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ | ||
1377 | EXT4_FEATURE_INCOMPAT_RECOVER| \ | ||
1378 | EXT4_FEATURE_INCOMPAT_META_BG) | ||
1379 | #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ | ||
1380 | EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ | ||
1381 | EXT4_FEATURE_RO_COMPAT_BTREE_DIR) | ||
1382 | |||
1354 | #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR | 1383 | #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR |
1355 | #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ | 1384 | #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ |
1356 | EXT4_FEATURE_INCOMPAT_RECOVER| \ | 1385 | EXT4_FEATURE_INCOMPAT_RECOVER| \ |
1357 | EXT4_FEATURE_INCOMPAT_META_BG| \ | 1386 | EXT4_FEATURE_INCOMPAT_META_BG| \ |
1358 | EXT4_FEATURE_INCOMPAT_EXTENTS| \ | 1387 | EXT4_FEATURE_INCOMPAT_EXTENTS| \ |
1359 | EXT4_FEATURE_INCOMPAT_64BIT| \ | 1388 | EXT4_FEATURE_INCOMPAT_64BIT| \ |
1360 | EXT4_FEATURE_INCOMPAT_FLEX_BG) | 1389 | EXT4_FEATURE_INCOMPAT_FLEX_BG| \ |
1390 | EXT4_FEATURE_INCOMPAT_MMP) | ||
1361 | #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ | 1391 | #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ |
1362 | EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ | 1392 | EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ |
1363 | EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ | 1393 | EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ |
@@ -1590,12 +1620,6 @@ void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, | |||
1590 | */ | 1620 | */ |
1591 | struct ext4_lazy_init { | 1621 | struct ext4_lazy_init { |
1592 | unsigned long li_state; | 1622 | unsigned long li_state; |
1593 | |||
1594 | wait_queue_head_t li_wait_daemon; | ||
1595 | wait_queue_head_t li_wait_task; | ||
1596 | struct timer_list li_timer; | ||
1597 | struct task_struct *li_task; | ||
1598 | |||
1599 | struct list_head li_request_list; | 1623 | struct list_head li_request_list; |
1600 | struct mutex li_list_mtx; | 1624 | struct mutex li_list_mtx; |
1601 | }; | 1625 | }; |
@@ -1615,6 +1639,67 @@ struct ext4_features { | |||
1615 | }; | 1639 | }; |
1616 | 1640 | ||
1617 | /* | 1641 | /* |
1642 | * This structure will be used for multiple mount protection. It will be | ||
1643 | * written into the block number saved in the s_mmp_block field in the | ||
1644 | * superblock. Programs that check MMP should assume that if | ||
1645 | * SEQ_FSCK (or any unknown code above SEQ_MAX) is present then it is NOT safe | ||
1646 | * to use the filesystem, regardless of how old the timestamp is. | ||
1647 | */ | ||
1648 | #define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */ | ||
1649 | #define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */ | ||
1650 | #define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */ | ||
1651 | #define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */ | ||
1652 | |||
1653 | struct mmp_struct { | ||
1654 | __le32 mmp_magic; /* Magic number for MMP */ | ||
1655 | __le32 mmp_seq; /* Sequence no. updated periodically */ | ||
1656 | |||
1657 | /* | ||
1658 | * mmp_time, mmp_nodename & mmp_bdevname are only used for information | ||
1659 | * purposes and do not affect the correctness of the algorithm | ||
1660 | */ | ||
1661 | __le64 mmp_time; /* Time last updated */ | ||
1662 | char mmp_nodename[64]; /* Node which last updated MMP block */ | ||
1663 | char mmp_bdevname[32]; /* Bdev which last updated MMP block */ | ||
1664 | |||
1665 | /* | ||
1666 | * mmp_check_interval is used to verify if the MMP block has been | ||
1667 | * updated on the block device. The value is updated based on the | ||
1668 | * maximum time to write the MMP block during an update cycle. | ||
1669 | */ | ||
1670 | __le16 mmp_check_interval; | ||
1671 | |||
1672 | __le16 mmp_pad1; | ||
1673 | __le32 mmp_pad2[227]; | ||
1674 | }; | ||
1675 | |||
1676 | /* arguments passed to the mmp thread */ | ||
1677 | struct mmpd_data { | ||
1678 | struct buffer_head *bh; /* bh from initial read_mmp_block() */ | ||
1679 | struct super_block *sb; /* super block of the fs */ | ||
1680 | }; | ||
1681 | |||
1682 | /* | ||
1683 | * Check interval multiplier | ||
1684 | * The MMP block is written every update interval and initially checked every | ||
1685 | * update interval x the multiplier (the value is then adapted based on the | ||
1686 | * write latency). The reason is that writes can be delayed under load and we | ||
1687 | * don't want readers to incorrectly assume that the filesystem is no longer | ||
1688 | * in use. | ||
1689 | */ | ||
1690 | #define EXT4_MMP_CHECK_MULT 2UL | ||
1691 | |||
1692 | /* | ||
1693 | * Minimum interval for MMP checking in seconds. | ||
1694 | */ | ||
1695 | #define EXT4_MMP_MIN_CHECK_INTERVAL 5UL | ||
1696 | |||
1697 | /* | ||
1698 | * Maximum interval for MMP checking in seconds. | ||
1699 | */ | ||
1700 | #define EXT4_MMP_MAX_CHECK_INTERVAL 300UL | ||
1701 | |||
1702 | /* | ||
1618 | * Function prototypes | 1703 | * Function prototypes |
1619 | */ | 1704 | */ |
1620 | 1705 | ||
@@ -1638,10 +1723,12 @@ extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group); | |||
1638 | extern unsigned long ext4_bg_num_gdb(struct super_block *sb, | 1723 | extern unsigned long ext4_bg_num_gdb(struct super_block *sb, |
1639 | ext4_group_t group); | 1724 | ext4_group_t group); |
1640 | extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, | 1725 | extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, |
1641 | ext4_fsblk_t goal, unsigned long *count, int *errp); | 1726 | ext4_fsblk_t goal, |
1642 | extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks); | 1727 | unsigned int flags, |
1643 | extern void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, | 1728 | unsigned long *count, |
1644 | ext4_fsblk_t block, unsigned long count); | 1729 | int *errp); |
1730 | extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | ||
1731 | s64 nblocks, unsigned int flags); | ||
1645 | extern ext4_fsblk_t ext4_count_free_blocks(struct super_block *); | 1732 | extern ext4_fsblk_t ext4_count_free_blocks(struct super_block *); |
1646 | extern void ext4_check_blocks_bitmap(struct super_block *); | 1733 | extern void ext4_check_blocks_bitmap(struct super_block *); |
1647 | extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb, | 1734 | extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb, |
@@ -1706,6 +1793,8 @@ extern void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
1706 | unsigned long count, int flags); | 1793 | unsigned long count, int flags); |
1707 | extern int ext4_mb_add_groupinfo(struct super_block *sb, | 1794 | extern int ext4_mb_add_groupinfo(struct super_block *sb, |
1708 | ext4_group_t i, struct ext4_group_desc *desc); | 1795 | ext4_group_t i, struct ext4_group_desc *desc); |
1796 | extern void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, | ||
1797 | ext4_fsblk_t block, unsigned long count); | ||
1709 | extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); | 1798 | extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); |
1710 | 1799 | ||
1711 | /* inode.c */ | 1800 | /* inode.c */ |
@@ -1729,6 +1818,7 @@ extern int ext4_change_inode_journal_flag(struct inode *, int); | |||
1729 | extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); | 1818 | extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); |
1730 | extern int ext4_can_truncate(struct inode *inode); | 1819 | extern int ext4_can_truncate(struct inode *inode); |
1731 | extern void ext4_truncate(struct inode *); | 1820 | extern void ext4_truncate(struct inode *); |
1821 | extern int ext4_punch_hole(struct file *file, loff_t offset, loff_t length); | ||
1732 | extern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks); | 1822 | extern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks); |
1733 | extern void ext4_set_inode_flags(struct inode *); | 1823 | extern void ext4_set_inode_flags(struct inode *); |
1734 | extern void ext4_get_inode_flags(struct ext4_inode_info *); | 1824 | extern void ext4_get_inode_flags(struct ext4_inode_info *); |
@@ -1738,6 +1828,8 @@ extern int ext4_writepage_trans_blocks(struct inode *); | |||
1738 | extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); | 1828 | extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); |
1739 | extern int ext4_block_truncate_page(handle_t *handle, | 1829 | extern int ext4_block_truncate_page(handle_t *handle, |
1740 | struct address_space *mapping, loff_t from); | 1830 | struct address_space *mapping, loff_t from); |
1831 | extern int ext4_block_zero_page_range(handle_t *handle, | ||
1832 | struct address_space *mapping, loff_t from, loff_t length); | ||
1741 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); | 1833 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); |
1742 | extern qsize_t *ext4_get_reserved_space(struct inode *inode); | 1834 | extern qsize_t *ext4_get_reserved_space(struct inode *inode); |
1743 | extern void ext4_da_update_reserve_space(struct inode *inode, | 1835 | extern void ext4_da_update_reserve_space(struct inode *inode, |
@@ -1788,6 +1880,10 @@ extern void __ext4_warning(struct super_block *, const char *, unsigned int, | |||
1788 | __LINE__, ## message) | 1880 | __LINE__, ## message) |
1789 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) | 1881 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) |
1790 | __attribute__ ((format (printf, 3, 4))); | 1882 | __attribute__ ((format (printf, 3, 4))); |
1883 | extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp, | ||
1884 | const char *, unsigned int, const char *); | ||
1885 | #define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \ | ||
1886 | __LINE__, msg) | ||
1791 | extern void __ext4_grp_locked_error(const char *, unsigned int, \ | 1887 | extern void __ext4_grp_locked_error(const char *, unsigned int, \ |
1792 | struct super_block *, ext4_group_t, \ | 1888 | struct super_block *, ext4_group_t, \ |
1793 | unsigned long, ext4_fsblk_t, \ | 1889 | unsigned long, ext4_fsblk_t, \ |
@@ -2064,6 +2160,8 @@ extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, | |||
2064 | extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | 2160 | extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, |
2065 | struct ext4_map_blocks *map, int flags); | 2161 | struct ext4_map_blocks *map, int flags); |
2066 | extern void ext4_ext_truncate(struct inode *); | 2162 | extern void ext4_ext_truncate(struct inode *); |
2163 | extern int ext4_ext_punch_hole(struct file *file, loff_t offset, | ||
2164 | loff_t length); | ||
2067 | extern void ext4_ext_init(struct super_block *); | 2165 | extern void ext4_ext_init(struct super_block *); |
2068 | extern void ext4_ext_release(struct super_block *); | 2166 | extern void ext4_ext_release(struct super_block *); |
2069 | extern long ext4_fallocate(struct file *file, int mode, loff_t offset, | 2167 | extern long ext4_fallocate(struct file *file, int mode, loff_t offset, |
@@ -2092,6 +2190,9 @@ extern int ext4_bio_write_page(struct ext4_io_submit *io, | |||
2092 | int len, | 2190 | int len, |
2093 | struct writeback_control *wbc); | 2191 | struct writeback_control *wbc); |
2094 | 2192 | ||
2193 | /* mmp.c */ | ||
2194 | extern int ext4_multi_mount_protect(struct super_block *, ext4_fsblk_t); | ||
2195 | |||
2095 | /* BH_Uninit flag: blocks are allocated but uninitialized on disk */ | 2196 | /* BH_Uninit flag: blocks are allocated but uninitialized on disk */ |
2096 | enum ext4_state_bits { | 2197 | enum ext4_state_bits { |
2097 | BH_Uninit /* blocks are allocated but uninitialized on disk */ | 2198 | BH_Uninit /* blocks are allocated but uninitialized on disk */ |