aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2015-10-17 16:18:43 -0400
committerTheodore Ts'o <tytso@mit.edu>2015-10-17 16:18:43 -0400
commite2b911c53584a92266943f3b7f2cdbc19c1a4e80 (patch)
tree2f1fd1771ef5e3a24b05c1fad3dc9026b3ecd73d /fs/ext4
parent6a797d2737838906f2ea0a31686e87c3151e21ca (diff)
ext4: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags, thereby replacing the wordy old macros. Furthermore, clean out the places where we open-coded feature tests. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/balloc.c16
-rw-r--r--fs/ext4/dir.c3
-rw-r--r--fs/ext4/ext4.h146
-rw-r--r--fs/ext4/ext4_jbd2.h10
-rw-r--r--fs/ext4/extents.c4
-rw-r--r--fs/ext4/ialloc.c4
-rw-r--r--fs/ext4/indirect.c3
-rw-r--r--fs/ext4/inline.c3
-rw-r--r--fs/ext4/inode.c16
-rw-r--r--fs/ext4/ioctl.c15
-rw-r--r--fs/ext4/migrate.c9
-rw-r--r--fs/ext4/namei.c8
-rw-r--r--fs/ext4/resize.c30
-rw-r--r--fs/ext4/super.c165
-rw-r--r--fs/ext4/xattr.c4
15 files changed, 252 insertions, 184 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index f831e10a7475..32184c16af16 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -213,7 +213,7 @@ static int ext4_init_block_bitmap(struct super_block *sb,
213 213
214 start = ext4_group_first_block_no(sb, block_group); 214 start = ext4_group_first_block_no(sb, block_group);
215 215
216 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 216 if (ext4_has_feature_flex_bg(sb))
217 flex_bg = 1; 217 flex_bg = 1;
218 218
219 /* Set bits for block and inode bitmaps, and inode table */ 219 /* Set bits for block and inode bitmaps, and inode table */
@@ -322,7 +322,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
322 ext4_fsblk_t blk; 322 ext4_fsblk_t blk;
323 ext4_fsblk_t group_first_block; 323 ext4_fsblk_t group_first_block;
324 324
325 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) { 325 if (ext4_has_feature_flex_bg(sb)) {
326 /* with FLEX_BG, the inode/block bitmaps and itable 326 /* with FLEX_BG, the inode/block bitmaps and itable
327 * blocks may not be in the group at all 327 * blocks may not be in the group at all
328 * so the bitmap validation will be skipped for those groups 328 * so the bitmap validation will be skipped for those groups
@@ -740,14 +740,13 @@ int ext4_bg_has_super(struct super_block *sb, ext4_group_t group)
740 740
741 if (group == 0) 741 if (group == 0)
742 return 1; 742 return 1;
743 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_SPARSE_SUPER2)) { 743 if (ext4_has_feature_sparse_super2(sb)) {
744 if (group == le32_to_cpu(es->s_backup_bgs[0]) || 744 if (group == le32_to_cpu(es->s_backup_bgs[0]) ||
745 group == le32_to_cpu(es->s_backup_bgs[1])) 745 group == le32_to_cpu(es->s_backup_bgs[1]))
746 return 1; 746 return 1;
747 return 0; 747 return 0;
748 } 748 }
749 if ((group <= 1) || !EXT4_HAS_RO_COMPAT_FEATURE(sb, 749 if ((group <= 1) || !ext4_has_feature_sparse_super(sb))
750 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER))
751 return 1; 750 return 1;
752 if (!(group & 1)) 751 if (!(group & 1))
753 return 0; 752 return 0;
@@ -776,7 +775,7 @@ static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb,
776 if (!ext4_bg_has_super(sb, group)) 775 if (!ext4_bg_has_super(sb, group))
777 return 0; 776 return 0;
778 777
779 if (EXT4_HAS_INCOMPAT_FEATURE(sb,EXT4_FEATURE_INCOMPAT_META_BG)) 778 if (ext4_has_feature_meta_bg(sb))
780 return le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg); 779 return le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg);
781 else 780 else
782 return EXT4_SB(sb)->s_gdb_count; 781 return EXT4_SB(sb)->s_gdb_count;
@@ -797,8 +796,7 @@ unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
797 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg); 796 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg);
798 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb); 797 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
799 798
800 if (!EXT4_HAS_INCOMPAT_FEATURE(sb,EXT4_FEATURE_INCOMPAT_META_BG) || 799 if (!ext4_has_feature_meta_bg(sb) || metagroup < first_meta_bg)
801 metagroup < first_meta_bg)
802 return ext4_bg_num_gdb_nometa(sb, group); 800 return ext4_bg_num_gdb_nometa(sb, group);
803 801
804 return ext4_bg_num_gdb_meta(sb,group); 802 return ext4_bg_num_gdb_meta(sb,group);
@@ -818,7 +816,7 @@ static unsigned ext4_num_base_meta_clusters(struct super_block *sb,
818 /* Check for superblock and gdt backups in this group */ 816 /* Check for superblock and gdt backups in this group */
819 num = ext4_bg_has_super(sb, block_group); 817 num = ext4_bg_has_super(sb, block_group);
820 818
821 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) || 819 if (!ext4_has_feature_meta_bg(sb) ||
822 block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) * 820 block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
823 sbi->s_desc_per_block) { 821 sbi->s_desc_per_block) {
824 if (num) { 822 if (num) {
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index b29cb707539f..1d1bca74f844 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -40,8 +40,7 @@ static int is_dx_dir(struct inode *inode)
40{ 40{
41 struct super_block *sb = inode->i_sb; 41 struct super_block *sb = inode->i_sb;
42 42
43 if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb, 43 if (ext4_has_feature_dir_index(inode->i_sb) &&
44 EXT4_FEATURE_COMPAT_DIR_INDEX) &&
45 ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) || 44 ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) ||
46 ((inode->i_size >> sb->s_blocksize_bits) == 1) || 45 ((inode->i_size >> sb->s_blocksize_bits) == 1) ||
47 ext4_has_inline_data(inode))) 46 ext4_has_inline_data(inode)))
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 6c0797346da1..b1d04aa724be 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1528,6 +1528,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
1528 * Feature set definitions 1528 * Feature set definitions
1529 */ 1529 */
1530 1530
1531/* Use the ext4_{has,set,clear}_feature_* helpers; these will be removed */
1531#define EXT4_HAS_COMPAT_FEATURE(sb,mask) \ 1532#define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
1532 ((EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask)) != 0) 1533 ((EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask)) != 0)
1533#define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \ 1534#define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
@@ -1590,6 +1591,94 @@ static inline int ext4_encrypted_inode(struct inode *inode)
1590#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */ 1591#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
1591#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 1592#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
1592 1593
1594#define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
1595static inline bool ext4_has_feature_##name(struct super_block *sb) \
1596{ \
1597 return ((EXT4_SB(sb)->s_es->s_feature_compat & \
1598 cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname)) != 0); \
1599} \
1600static inline void ext4_set_feature_##name(struct super_block *sb) \
1601{ \
1602 EXT4_SB(sb)->s_es->s_feature_compat |= \
1603 cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
1604} \
1605static inline void ext4_clear_feature_##name(struct super_block *sb) \
1606{ \
1607 EXT4_SB(sb)->s_es->s_feature_compat &= \
1608 ~cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
1609}
1610
1611#define EXT4_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
1612static inline bool ext4_has_feature_##name(struct super_block *sb) \
1613{ \
1614 return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
1615 cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname)) != 0); \
1616} \
1617static inline void ext4_set_feature_##name(struct super_block *sb) \
1618{ \
1619 EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
1620 cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
1621} \
1622static inline void ext4_clear_feature_##name(struct super_block *sb) \
1623{ \
1624 EXT4_SB(sb)->s_es->s_feature_ro_compat &= \
1625 ~cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
1626}
1627
1628#define EXT4_FEATURE_INCOMPAT_FUNCS(name, flagname) \
1629static inline bool ext4_has_feature_##name(struct super_block *sb) \
1630{ \
1631 return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
1632 cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname)) != 0); \
1633} \
1634static inline void ext4_set_feature_##name(struct super_block *sb) \
1635{ \
1636 EXT4_SB(sb)->s_es->s_feature_incompat |= \
1637 cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
1638} \
1639static inline void ext4_clear_feature_##name(struct super_block *sb) \
1640{ \
1641 EXT4_SB(sb)->s_es->s_feature_incompat &= \
1642 ~cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
1643}
1644
1645EXT4_FEATURE_COMPAT_FUNCS(dir_prealloc, DIR_PREALLOC)
1646EXT4_FEATURE_COMPAT_FUNCS(imagic_inodes, IMAGIC_INODES)
1647EXT4_FEATURE_COMPAT_FUNCS(journal, HAS_JOURNAL)
1648EXT4_FEATURE_COMPAT_FUNCS(xattr, EXT_ATTR)
1649EXT4_FEATURE_COMPAT_FUNCS(resize_inode, RESIZE_INODE)
1650EXT4_FEATURE_COMPAT_FUNCS(dir_index, DIR_INDEX)
1651EXT4_FEATURE_COMPAT_FUNCS(sparse_super2, SPARSE_SUPER2)
1652
1653EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super, SPARSE_SUPER)
1654EXT4_FEATURE_RO_COMPAT_FUNCS(large_file, LARGE_FILE)
1655EXT4_FEATURE_RO_COMPAT_FUNCS(btree_dir, BTREE_DIR)
1656EXT4_FEATURE_RO_COMPAT_FUNCS(huge_file, HUGE_FILE)
1657EXT4_FEATURE_RO_COMPAT_FUNCS(gdt_csum, GDT_CSUM)
1658EXT4_FEATURE_RO_COMPAT_FUNCS(dir_nlink, DIR_NLINK)
1659EXT4_FEATURE_RO_COMPAT_FUNCS(extra_isize, EXTRA_ISIZE)
1660EXT4_FEATURE_RO_COMPAT_FUNCS(quota, QUOTA)
1661EXT4_FEATURE_RO_COMPAT_FUNCS(bigalloc, BIGALLOC)
1662EXT4_FEATURE_RO_COMPAT_FUNCS(metadata_csum, METADATA_CSUM)
1663EXT4_FEATURE_RO_COMPAT_FUNCS(readonly, READONLY)
1664EXT4_FEATURE_RO_COMPAT_FUNCS(project, PROJECT)
1665
1666EXT4_FEATURE_INCOMPAT_FUNCS(compression, COMPRESSION)
1667EXT4_FEATURE_INCOMPAT_FUNCS(filetype, FILETYPE)
1668EXT4_FEATURE_INCOMPAT_FUNCS(journal_needs_recovery, RECOVER)
1669EXT4_FEATURE_INCOMPAT_FUNCS(journal_dev, JOURNAL_DEV)
1670EXT4_FEATURE_INCOMPAT_FUNCS(meta_bg, META_BG)
1671EXT4_FEATURE_INCOMPAT_FUNCS(extents, EXTENTS)
1672EXT4_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
1673EXT4_FEATURE_INCOMPAT_FUNCS(mmp, MMP)
1674EXT4_FEATURE_INCOMPAT_FUNCS(flex_bg, FLEX_BG)
1675EXT4_FEATURE_INCOMPAT_FUNCS(ea_inode, EA_INODE)
1676EXT4_FEATURE_INCOMPAT_FUNCS(dirdata, DIRDATA)
1677EXT4_FEATURE_INCOMPAT_FUNCS(csum_seed, CSUM_SEED)
1678EXT4_FEATURE_INCOMPAT_FUNCS(largedir, LARGEDIR)
1679EXT4_FEATURE_INCOMPAT_FUNCS(inline_data, INLINE_DATA)
1680EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT)
1681
1593#define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR 1682#define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
1594#define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ 1683#define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
1595 EXT4_FEATURE_INCOMPAT_META_BG) 1684 EXT4_FEATURE_INCOMPAT_META_BG)
@@ -1605,7 +1694,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
1605 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ 1694 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
1606 EXT4_FEATURE_RO_COMPAT_BTREE_DIR) 1695 EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
1607 1696
1608#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR 1697#define EXT4_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
1609#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ 1698#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
1610 EXT4_FEATURE_INCOMPAT_RECOVER| \ 1699 EXT4_FEATURE_INCOMPAT_RECOVER| \
1611 EXT4_FEATURE_INCOMPAT_META_BG| \ 1700 EXT4_FEATURE_INCOMPAT_META_BG| \
@@ -1627,6 +1716,40 @@ static inline int ext4_encrypted_inode(struct inode *inode)
1627 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\ 1716 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
1628 EXT4_FEATURE_RO_COMPAT_QUOTA) 1717 EXT4_FEATURE_RO_COMPAT_QUOTA)
1629 1718
1719#define EXTN_FEATURE_FUNCS(ver) \
1720static inline bool ext4_has_unknown_ext##ver##_compat_features(struct super_block *sb) \
1721{ \
1722 return ((EXT4_SB(sb)->s_es->s_feature_compat & \
1723 cpu_to_le32(~EXT##ver##_FEATURE_COMPAT_SUPP)) != 0); \
1724} \
1725static inline bool ext4_has_unknown_ext##ver##_ro_compat_features(struct super_block *sb) \
1726{ \
1727 return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
1728 cpu_to_le32(~EXT##ver##_FEATURE_RO_COMPAT_SUPP)) != 0); \
1729} \
1730static inline bool ext4_has_unknown_ext##ver##_incompat_features(struct super_block *sb) \
1731{ \
1732 return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
1733 cpu_to_le32(~EXT##ver##_FEATURE_INCOMPAT_SUPP)) != 0); \
1734}
1735
1736EXTN_FEATURE_FUNCS(2)
1737EXTN_FEATURE_FUNCS(3)
1738EXTN_FEATURE_FUNCS(4)
1739
1740static inline bool ext4_has_compat_features(struct super_block *sb)
1741{
1742 return (EXT4_SB(sb)->s_es->s_feature_compat != 0);
1743}
1744static inline bool ext4_has_ro_compat_features(struct super_block *sb)
1745{
1746 return (EXT4_SB(sb)->s_es->s_feature_ro_compat != 0);
1747}
1748static inline bool ext4_has_incompat_features(struct super_block *sb)
1749{
1750 return (EXT4_SB(sb)->s_es->s_feature_incompat != 0);
1751}
1752
1630/* 1753/*
1631 * Default values for user and/or group using reserved blocks 1754 * Default values for user and/or group using reserved blocks
1632 */ 1755 */
@@ -1777,8 +1900,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
1777 * (c) Daniel Phillips, 2001 1900 * (c) Daniel Phillips, 2001
1778 */ 1901 */
1779 1902
1780#define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ 1903#define is_dx(dir) (ext4_has_feature_dir_index((dir)->i_sb) && \
1781 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
1782 ext4_test_inode_flag((dir), EXT4_INODE_INDEX)) 1904 ext4_test_inode_flag((dir), EXT4_INODE_INDEX))
1783#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX) 1905#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
1784#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) 1906#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
@@ -2079,7 +2201,7 @@ int ext4_init_crypto(void);
2079void ext4_exit_crypto(void); 2201void ext4_exit_crypto(void);
2080static inline int ext4_sb_has_crypto(struct super_block *sb) 2202static inline int ext4_sb_has_crypto(struct super_block *sb)
2081{ 2203{
2082 return EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT); 2204 return ext4_has_feature_encrypt(sb);
2083} 2205}
2084#else 2206#else
2085static inline int ext4_init_crypto(void) { return 0; } 2207static inline int ext4_init_crypto(void) { return 0; }
@@ -2200,8 +2322,7 @@ int ext4_insert_dentry(struct inode *dir,
2200 struct ext4_filename *fname); 2322 struct ext4_filename *fname);
2201static inline void ext4_update_dx_flag(struct inode *inode) 2323static inline void ext4_update_dx_flag(struct inode *inode)
2202{ 2324{
2203 if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, 2325 if (!ext4_has_feature_dir_index(inode->i_sb))
2204 EXT4_FEATURE_COMPAT_DIR_INDEX))
2205 ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); 2326 ext4_clear_inode_flag(inode, EXT4_INODE_INDEX);
2206} 2327}
2207static unsigned char ext4_filetype_table[] = { 2328static unsigned char ext4_filetype_table[] = {
@@ -2210,8 +2331,7 @@ static unsigned char ext4_filetype_table[] = {
2210 2331
2211static inline unsigned char get_dtype(struct super_block *sb, int filetype) 2332static inline unsigned char get_dtype(struct super_block *sb, int filetype)
2212{ 2333{
2213 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE) || 2334 if (!ext4_has_feature_filetype(sb) || filetype >= EXT4_FT_MAX)
2214 (filetype >= EXT4_FT_MAX))
2215 return DT_UNKNOWN; 2335 return DT_UNKNOWN;
2216 2336
2217 return ext4_filetype_table[filetype]; 2337 return ext4_filetype_table[filetype];
@@ -2543,15 +2663,13 @@ extern int ext4_register_li_request(struct super_block *sb,
2543 2663
2544static inline int ext4_has_group_desc_csum(struct super_block *sb) 2664static inline int ext4_has_group_desc_csum(struct super_block *sb)
2545{ 2665{
2546 return EXT4_HAS_RO_COMPAT_FEATURE(sb, 2666 return ext4_has_feature_gdt_csum(sb) ||
2547 EXT4_FEATURE_RO_COMPAT_GDT_CSUM) || 2667 EXT4_SB(sb)->s_chksum_driver != NULL;
2548 (EXT4_SB(sb)->s_chksum_driver != NULL);
2549} 2668}
2550 2669
2551static inline int ext4_has_metadata_csum(struct super_block *sb) 2670static inline int ext4_has_metadata_csum(struct super_block *sb)
2552{ 2671{
2553 WARN_ON_ONCE(EXT4_HAS_RO_COMPAT_FEATURE(sb, 2672 WARN_ON_ONCE(ext4_has_feature_metadata_csum(sb) &&
2554 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
2555 !EXT4_SB(sb)->s_chksum_driver); 2673 !EXT4_SB(sb)->s_chksum_driver);
2556 2674
2557 return (EXT4_SB(sb)->s_chksum_driver != NULL); 2675 return (EXT4_SB(sb)->s_chksum_driver != NULL);
@@ -2898,7 +3016,7 @@ static unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
2898static inline void ext4_set_de_type(struct super_block *sb, 3016static inline void ext4_set_de_type(struct super_block *sb,
2899 struct ext4_dir_entry_2 *de, 3017 struct ext4_dir_entry_2 *de,
2900 umode_t mode) { 3018 umode_t mode) {
2901 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE)) 3019 if (ext4_has_feature_filetype(sb))
2902 de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 3020 de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
2903} 3021}
2904 3022
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index 9c5b49fb281e..5f5846211095 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -34,8 +34,7 @@
34 */ 34 */
35 35
36#define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \ 36#define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
37 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \ 37 (ext4_has_feature_extents(sb) ? 20U : 8U)
38 ? 20U : 8U)
39 38
40/* Extended attribute operations touch at most two data buffers, 39/* Extended attribute operations touch at most two data buffers,
41 * two bitmap buffers, and two group summaries, in addition to the inode 40 * two bitmap buffers, and two group summaries, in addition to the inode
@@ -84,17 +83,16 @@
84/* Amount of blocks needed for quota update - we know that the structure was 83/* Amount of blocks needed for quota update - we know that the structure was
85 * allocated so we need to update only data block */ 84 * allocated so we need to update only data block */
86#define EXT4_QUOTA_TRANS_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ 85#define EXT4_QUOTA_TRANS_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
87 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ 86 ext4_has_feature_quota(sb)) ? 1 : 0)
88 1 : 0)
89/* Amount of blocks needed for quota insert/delete - we do some block writes 87/* Amount of blocks needed for quota insert/delete - we do some block writes
90 * but inode, sb and group updates are done only once */ 88 * but inode, sb and group updates are done only once */
91#define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ 89#define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
92 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ 90 ext4_has_feature_quota(sb)) ?\
93 (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\ 91 (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
94 +3+DQUOT_INIT_REWRITE) : 0) 92 +3+DQUOT_INIT_REWRITE) : 0)
95 93
96#define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ 94#define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
97 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ 95 ext4_has_feature_quota(sb)) ?\
98 (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\ 96 (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
99 +3+DQUOT_DEL_REWRITE) : 0) 97 +3+DQUOT_DEL_REWRITE) : 0)
100#else 98#else
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index faeaba8582d7..3a6197a2e270 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3055,7 +3055,7 @@ void ext4_ext_init(struct super_block *sb)
3055 * possible initialization would be here 3055 * possible initialization would be here
3056 */ 3056 */
3057 3057
3058 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) { 3058 if (ext4_has_feature_extents(sb)) {
3059#if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS) 3059#if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS)
3060 printk(KERN_INFO "EXT4-fs: file extents enabled" 3060 printk(KERN_INFO "EXT4-fs: file extents enabled"
3061#ifdef AGGRESSIVE_TEST 3061#ifdef AGGRESSIVE_TEST
@@ -3082,7 +3082,7 @@ void ext4_ext_init(struct super_block *sb)
3082 */ 3082 */
3083void ext4_ext_release(struct super_block *sb) 3083void ext4_ext_release(struct super_block *sb)
3084{ 3084{
3085 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) 3085 if (!ext4_has_feature_extents(sb))
3086 return; 3086 return;
3087 3087
3088#ifdef EXTENTS_STATS 3088#ifdef EXTENTS_STATS
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index f34b1aa8bbb5..0d7f06ed7ee2 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1045,7 +1045,7 @@ got:
1045 1045
1046 ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; 1046 ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
1047 ei->i_inline_off = 0; 1047 ei->i_inline_off = 0;
1048 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_INLINE_DATA)) 1048 if (ext4_has_feature_inline_data(sb))
1049 ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); 1049 ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
1050 ret = inode; 1050 ret = inode;
1051 err = dquot_alloc_inode(inode); 1051 err = dquot_alloc_inode(inode);
@@ -1060,7 +1060,7 @@ got:
1060 if (err) 1060 if (err)
1061 goto fail_free_drop; 1061 goto fail_free_drop;
1062 1062
1063 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) { 1063 if (ext4_has_feature_extents(sb)) {
1064 /* set extent flag only for directory, file and normal symlink*/ 1064 /* set extent flag only for directory, file and normal symlink*/
1065 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) { 1065 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) {
1066 ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS); 1066 ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index d96ea53bbece..355ef9c36c87 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -562,8 +562,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
562 /* 562 /*
563 * Okay, we need to do block allocation. 563 * Okay, we need to do block allocation.
564 */ 564 */
565 if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, 565 if (ext4_has_feature_bigalloc(inode->i_sb)) {
566 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
567 EXT4_ERROR_INODE(inode, "Can't allocate blocks for " 566 EXT4_ERROR_INODE(inode, "Can't allocate blocks for "
568 "non-extent mapped inodes with bigalloc"); 567 "non-extent mapped inodes with bigalloc");
569 return -EFSCORRUPTED; 568 return -EFSCORRUPTED;
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index cd944a7a99cd..d884989cc83d 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -434,8 +434,7 @@ static int ext4_destroy_inline_data_nolock(handle_t *handle,
434 memset((void *)ext4_raw_inode(&is.iloc)->i_block, 434 memset((void *)ext4_raw_inode(&is.iloc)->i_block,
435 0, EXT4_MIN_INLINE_DATA_SIZE); 435 0, EXT4_MIN_INLINE_DATA_SIZE);
436 436
437 if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, 437 if (ext4_has_feature_extents(inode->i_sb)) {
438 EXT4_FEATURE_INCOMPAT_EXTENTS)) {
439 if (S_ISDIR(inode->i_mode) || 438 if (S_ISDIR(inode->i_mode) ||
440 S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) { 439 S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) {
441 ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS); 440 ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2b9278867caf..e8d620a484f6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2642,8 +2642,7 @@ static int ext4_nonda_switch(struct super_block *sb)
2642/* We always reserve for an inode update; the superblock could be there too */ 2642/* We always reserve for an inode update; the superblock could be there too */
2643static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len) 2643static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
2644{ 2644{
2645 if (likely(EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, 2645 if (likely(ext4_has_feature_large_file(inode->i_sb)))
2646 EXT4_FEATURE_RO_COMPAT_LARGE_FILE)))
2647 return 1; 2646 return 1;
2648 2647
2649 if (pos + len <= 0x7fffffffULL) 2648 if (pos + len <= 0x7fffffffULL)
@@ -4049,8 +4048,7 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
4049 struct inode *inode = &(ei->vfs_inode); 4048 struct inode *inode = &(ei->vfs_inode);
4050 struct super_block *sb = inode->i_sb; 4049 struct super_block *sb = inode->i_sb;
4051 4050
4052 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 4051 if (ext4_has_feature_huge_file(sb)) {
4053 EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
4054 /* we are using combined 48 bit field */ 4052 /* we are using combined 48 bit field */
4055 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 | 4053 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 |
4056 le32_to_cpu(raw_inode->i_blocks_lo); 4054 le32_to_cpu(raw_inode->i_blocks_lo);
@@ -4173,7 +4171,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4173 ei->i_flags = le32_to_cpu(raw_inode->i_flags); 4171 ei->i_flags = le32_to_cpu(raw_inode->i_flags);
4174 inode->i_blocks = ext4_inode_blocks(raw_inode, ei); 4172 inode->i_blocks = ext4_inode_blocks(raw_inode, ei);
4175 ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl_lo); 4173 ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl_lo);
4176 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) 4174 if (ext4_has_feature_64bit(sb))
4177 ei->i_file_acl |= 4175 ei->i_file_acl |=
4178 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; 4176 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
4179 inode->i_size = ext4_isize(raw_inode); 4177 inode->i_size = ext4_isize(raw_inode);
@@ -4337,7 +4335,7 @@ static int ext4_inode_blocks_set(handle_t *handle,
4337 ext4_clear_inode_flag(inode, EXT4_INODE_HUGE_FILE); 4335 ext4_clear_inode_flag(inode, EXT4_INODE_HUGE_FILE);
4338 return 0; 4336 return 0;
4339 } 4337 }
4340 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) 4338 if (!ext4_has_feature_huge_file(sb))
4341 return -EFBIG; 4339 return -EFBIG;
4342 4340
4343 if (i_blocks <= 0xffffffffffffULL) { 4341 if (i_blocks <= 0xffffffffffffULL) {
@@ -4498,8 +4496,7 @@ static int ext4_do_update_inode(handle_t *handle,
4498 need_datasync = 1; 4496 need_datasync = 1;
4499 } 4497 }
4500 if (ei->i_disksize > 0x7fffffffULL) { 4498 if (ei->i_disksize > 0x7fffffffULL) {
4501 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 4499 if (!ext4_has_feature_large_file(sb) ||
4502 EXT4_FEATURE_RO_COMPAT_LARGE_FILE) ||
4503 EXT4_SB(sb)->s_es->s_rev_level == 4500 EXT4_SB(sb)->s_es->s_rev_level ==
4504 cpu_to_le32(EXT4_GOOD_OLD_REV)) 4501 cpu_to_le32(EXT4_GOOD_OLD_REV))
4505 set_large_file = 1; 4502 set_large_file = 1;
@@ -4548,8 +4545,7 @@ static int ext4_do_update_inode(handle_t *handle,
4548 if (err) 4545 if (err)
4549 goto out_brelse; 4546 goto out_brelse;
4550 ext4_update_dynamic_rev(sb); 4547 ext4_update_dynamic_rev(sb);
4551 EXT4_SET_RO_COMPAT_FEATURE(sb, 4548 ext4_set_feature_large_file(sb);
4552 EXT4_FEATURE_RO_COMPAT_LARGE_FILE);
4553 ext4_handle_sync(handle); 4549 ext4_handle_sync(handle);
4554 err = ext4_handle_dirty_super(handle, sb); 4550 err = ext4_handle_dirty_super(handle, sb);
4555 } 4551 }
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 1346cfa355d0..5e872fd40e5e 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -145,8 +145,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
145 inode_bl->i_version = 1; 145 inode_bl->i_version = 1;
146 i_size_write(inode_bl, 0); 146 i_size_write(inode_bl, 0);
147 inode_bl->i_mode = S_IFREG; 147 inode_bl->i_mode = S_IFREG;
148 if (EXT4_HAS_INCOMPAT_FEATURE(sb, 148 if (ext4_has_feature_extents(sb)) {
149 EXT4_FEATURE_INCOMPAT_EXTENTS)) {
150 ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS); 149 ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS);
151 ext4_ext_tree_init(handle, inode_bl); 150 ext4_ext_tree_init(handle, inode_bl);
152 } else 151 } else
@@ -383,8 +382,7 @@ setversion_out:
383 goto group_extend_out; 382 goto group_extend_out;
384 } 383 }
385 384
386 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 385 if (ext4_has_feature_bigalloc(sb)) {
387 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
388 ext4_msg(sb, KERN_ERR, 386 ext4_msg(sb, KERN_ERR,
389 "Online resizing not supported with bigalloc"); 387 "Online resizing not supported with bigalloc");
390 err = -EOPNOTSUPP; 388 err = -EOPNOTSUPP;
@@ -432,8 +430,7 @@ group_extend_out:
432 goto mext_out; 430 goto mext_out;
433 } 431 }
434 432
435 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 433 if (ext4_has_feature_bigalloc(sb)) {
436 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
437 ext4_msg(sb, KERN_ERR, 434 ext4_msg(sb, KERN_ERR,
438 "Online defrag not supported with bigalloc"); 435 "Online defrag not supported with bigalloc");
439 err = -EOPNOTSUPP; 436 err = -EOPNOTSUPP;
@@ -470,8 +467,7 @@ mext_out:
470 goto group_add_out; 467 goto group_add_out;
471 } 468 }
472 469
473 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 470 if (ext4_has_feature_bigalloc(sb)) {
474 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
475 ext4_msg(sb, KERN_ERR, 471 ext4_msg(sb, KERN_ERR,
476 "Online resizing not supported with bigalloc"); 472 "Online resizing not supported with bigalloc");
477 err = -EOPNOTSUPP; 473 err = -EOPNOTSUPP;
@@ -553,8 +549,7 @@ group_add_out:
553 int err = 0, err2 = 0; 549 int err = 0, err2 = 0;
554 ext4_group_t o_group = EXT4_SB(sb)->s_groups_count; 550 ext4_group_t o_group = EXT4_SB(sb)->s_groups_count;
555 551
556 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 552 if (ext4_has_feature_bigalloc(sb)) {
557 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
558 ext4_msg(sb, KERN_ERR, 553 ext4_msg(sb, KERN_ERR,
559 "Online resizing not (yet) supported with bigalloc"); 554 "Online resizing not (yet) supported with bigalloc");
560 return -EOPNOTSUPP; 555 return -EOPNOTSUPP;
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 6163ad21cb0e..a4651894cc33 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -448,8 +448,7 @@ int ext4_ext_migrate(struct inode *inode)
448 * If the filesystem does not support extents, or the inode 448 * If the filesystem does not support extents, or the inode
449 * already is extent-based, error out. 449 * already is extent-based, error out.
450 */ 450 */
451 if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, 451 if (!ext4_has_feature_extents(inode->i_sb) ||
452 EXT4_FEATURE_INCOMPAT_EXTENTS) ||
453 (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) 452 (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
454 return -EINVAL; 453 return -EINVAL;
455 454
@@ -625,13 +624,11 @@ int ext4_ind_migrate(struct inode *inode)
625 handle_t *handle; 624 handle_t *handle;
626 int ret; 625 int ret;
627 626
628 if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, 627 if (!ext4_has_feature_extents(inode->i_sb) ||
629 EXT4_FEATURE_INCOMPAT_EXTENTS) ||
630 (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) 628 (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
631 return -EINVAL; 629 return -EINVAL;
632 630
633 if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, 631 if (ext4_has_feature_bigalloc(inode->i_sb))
634 EXT4_FEATURE_RO_COMPAT_BIGALLOC))
635 return -EOPNOTSUPP; 632 return -EOPNOTSUPP;
636 633
637 /* 634 /*
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 8fd8e0d4c75e..52a79d48752c 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2118,7 +2118,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
2118 goto out; 2118 goto out;
2119 2119
2120 if (blocks == 1 && !dx_fallback && 2120 if (blocks == 1 && !dx_fallback &&
2121 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) { 2121 ext4_has_feature_dir_index(sb)) {
2122 retval = make_indexed_dir(handle, &fname, dentry, 2122 retval = make_indexed_dir(handle, &fname, dentry,
2123 inode, bh); 2123 inode, bh);
2124 bh = NULL; /* make_indexed_dir releases bh */ 2124 bh = NULL; /* make_indexed_dir releases bh */
@@ -2388,8 +2388,7 @@ static void ext4_inc_count(handle_t *handle, struct inode *inode)
2388 /* limit is 16-bit i_links_count */ 2388 /* limit is 16-bit i_links_count */
2389 if (inode->i_nlink >= EXT4_LINK_MAX || inode->i_nlink == 2) { 2389 if (inode->i_nlink >= EXT4_LINK_MAX || inode->i_nlink == 2) {
2390 set_nlink(inode, 1); 2390 set_nlink(inode, 1);
2391 EXT4_SET_RO_COMPAT_FEATURE(inode->i_sb, 2391 ext4_set_feature_dir_nlink(inode->i_sb);
2392 EXT4_FEATURE_RO_COMPAT_DIR_NLINK);
2393 } 2392 }
2394 } 2393 }
2395} 2394}
@@ -3352,8 +3351,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
3352 if (retval) 3351 if (retval)
3353 return retval; 3352 return retval;
3354 ent->de->inode = cpu_to_le32(ino); 3353 ent->de->inode = cpu_to_le32(ino);
3355 if (EXT4_HAS_INCOMPAT_FEATURE(ent->dir->i_sb, 3354 if (ext4_has_feature_filetype(ent->dir->i_sb))
3356 EXT4_FEATURE_INCOMPAT_FILETYPE))
3357 ent->de->file_type = file_type; 3355 ent->de->file_type = file_type;
3358 ent->dir->i_version++; 3356 ent->dir->i_version++;
3359 ent->dir->i_ctime = ent->dir->i_mtime = 3357 ent->dir->i_ctime = ent->dir->i_mtime =
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index cf0c472047e3..469eeccee0bf 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -490,7 +490,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
490 group_data[0].group != sbi->s_groups_count); 490 group_data[0].group != sbi->s_groups_count);
491 491
492 reserved_gdb = le16_to_cpu(es->s_reserved_gdt_blocks); 492 reserved_gdb = le16_to_cpu(es->s_reserved_gdt_blocks);
493 meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); 493 meta_bg = ext4_has_feature_meta_bg(sb);
494 494
495 /* This transaction may be extended/restarted along the way */ 495 /* This transaction may be extended/restarted along the way */
496 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA); 496 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA);
@@ -680,8 +680,7 @@ static unsigned ext4_list_backups(struct super_block *sb, unsigned *three,
680 int mult = 3; 680 int mult = 3;
681 unsigned ret; 681 unsigned ret;
682 682
683 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 683 if (!ext4_has_feature_sparse_super(sb)) {
684 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
685 ret = *min; 684 ret = *min;
686 *min += 1; 685 *min += 1;
687 return ret; 686 return ret;
@@ -1158,7 +1157,7 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
1158 int i, gdb_off, gdb_num, err = 0; 1157 int i, gdb_off, gdb_num, err = 0;
1159 int meta_bg; 1158 int meta_bg;
1160 1159
1161 meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); 1160 meta_bg = ext4_has_feature_meta_bg(sb);
1162 for (i = 0; i < count; i++, group++) { 1161 for (i = 0; i < count; i++, group++) {
1163 int reserved_gdb = ext4_bg_has_super(sb, group) ? 1162 int reserved_gdb = ext4_bg_has_super(sb, group) ?
1164 le16_to_cpu(es->s_reserved_gdt_blocks) : 0; 1163 le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
@@ -1381,9 +1380,7 @@ static void ext4_update_super(struct super_block *sb,
1381 1380
1382 ext4_debug("free blocks count %llu", 1381 ext4_debug("free blocks count %llu",
1383 percpu_counter_read(&sbi->s_freeclusters_counter)); 1382 percpu_counter_read(&sbi->s_freeclusters_counter));
1384 if (EXT4_HAS_INCOMPAT_FEATURE(sb, 1383 if (ext4_has_feature_flex_bg(sb) && sbi->s_log_groups_per_flex) {
1385 EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
1386 sbi->s_log_groups_per_flex) {
1387 ext4_group_t flex_group; 1384 ext4_group_t flex_group;
1388 flex_group = ext4_flex_group(sbi, group_data[0].group); 1385 flex_group = ext4_flex_group(sbi, group_data[0].group);
1389 atomic64_add(EXT4_NUM_B2C(sbi, free_blocks), 1386 atomic64_add(EXT4_NUM_B2C(sbi, free_blocks),
@@ -1476,8 +1473,7 @@ exit_journal:
1476 int gdb_num = group / EXT4_DESC_PER_BLOCK(sb); 1473 int gdb_num = group / EXT4_DESC_PER_BLOCK(sb);
1477 int gdb_num_end = ((group + flex_gd->count - 1) / 1474 int gdb_num_end = ((group + flex_gd->count - 1) /
1478 EXT4_DESC_PER_BLOCK(sb)); 1475 EXT4_DESC_PER_BLOCK(sb));
1479 int meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, 1476 int meta_bg = ext4_has_feature_meta_bg(sb);
1480 EXT4_FEATURE_INCOMPAT_META_BG);
1481 sector_t old_gdb = 0; 1477 sector_t old_gdb = 0;
1482 1478
1483 update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es, 1479 update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
@@ -1585,8 +1581,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
1585 1581
1586 gdb_off = input->group % EXT4_DESC_PER_BLOCK(sb); 1582 gdb_off = input->group % EXT4_DESC_PER_BLOCK(sb);
1587 1583
1588 if (gdb_off == 0 && !EXT4_HAS_RO_COMPAT_FEATURE(sb, 1584 if (gdb_off == 0 && !ext4_has_feature_sparse_super(sb)) {
1589 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
1590 ext4_warning(sb, "Can't resize non-sparse filesystem further"); 1585 ext4_warning(sb, "Can't resize non-sparse filesystem further");
1591 return -EPERM; 1586 return -EPERM;
1592 } 1587 }
@@ -1604,9 +1599,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
1604 } 1599 }
1605 1600
1606 if (reserved_gdb || gdb_off == 0) { 1601 if (reserved_gdb || gdb_off == 0) {
1607 if (!EXT4_HAS_COMPAT_FEATURE(sb, 1602 if (ext4_has_feature_resize_inode(sb) ||
1608 EXT4_FEATURE_COMPAT_RESIZE_INODE) 1603 !le16_to_cpu(es->s_reserved_gdt_blocks)) {
1609 || !le16_to_cpu(es->s_reserved_gdt_blocks)) {
1610 ext4_warning(sb, 1604 ext4_warning(sb,
1611 "No reserved GDT blocks, can't resize"); 1605 "No reserved GDT blocks, can't resize");
1612 return -EPERM; 1606 return -EPERM;
@@ -1825,8 +1819,8 @@ static int ext4_convert_meta_bg(struct super_block *sb, struct inode *inode)
1825 if (err) 1819 if (err)
1826 goto errout; 1820 goto errout;
1827 1821
1828 EXT4_CLEAR_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_RESIZE_INODE); 1822 ext4_clear_feature_resize_inode(sb);
1829 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); 1823 ext4_set_feature_meta_bg(sb);
1830 sbi->s_es->s_first_meta_bg = 1824 sbi->s_es->s_first_meta_bg =
1831 cpu_to_le32(num_desc_blocks(sb, sbi->s_groups_count)); 1825 cpu_to_le32(num_desc_blocks(sb, sbi->s_groups_count));
1832 1826
@@ -1918,9 +1912,9 @@ retry:
1918 n_desc_blocks = num_desc_blocks(sb, n_group + 1); 1912 n_desc_blocks = num_desc_blocks(sb, n_group + 1);
1919 o_desc_blocks = num_desc_blocks(sb, sbi->s_groups_count); 1913 o_desc_blocks = num_desc_blocks(sb, sbi->s_groups_count);
1920 1914
1921 meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); 1915 meta_bg = ext4_has_feature_meta_bg(sb);
1922 1916
1923 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_RESIZE_INODE)) { 1917 if (ext4_has_feature_resize_inode(sb)) {
1924 if (meta_bg) { 1918 if (meta_bg) {
1925 ext4_error(sb, "resize_inode and meta_bg enabled " 1919 ext4_error(sb, "resize_inode and meta_bg enabled "
1926 "simultaneously"); 1920 "simultaneously");
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f7519ad25cce..49fa4d48b6a4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -110,8 +110,7 @@ MODULE_ALIAS("ext3");
110static int ext4_verify_csum_type(struct super_block *sb, 110static int ext4_verify_csum_type(struct super_block *sb,
111 struct ext4_super_block *es) 111 struct ext4_super_block *es)
112{ 112{
113 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 113 if (!ext4_has_feature_metadata_csum(sb))
114 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
115 return 1; 114 return 1;
116 115
117 return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 116 return es->s_checksum_type == EXT4_CRC32C_CHKSUM;
@@ -810,7 +809,7 @@ static void ext4_put_super(struct super_block *sb)
810 ext4_xattr_put_super(sb); 809 ext4_xattr_put_super(sb);
811 810
812 if (!(sb->s_flags & MS_RDONLY)) { 811 if (!(sb->s_flags & MS_RDONLY)) {
813 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 812 ext4_clear_feature_journal_needs_recovery(sb);
814 es->s_state = cpu_to_le16(sbi->s_mount_state); 813 es->s_state = cpu_to_le16(sbi->s_mount_state);
815 } 814 }
816 if (!(sb->s_flags & MS_RDONLY)) 815 if (!(sb->s_flags & MS_RDONLY))
@@ -1284,7 +1283,7 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
1284 "quota options when quota turned on"); 1283 "quota options when quota turned on");
1285 return -1; 1284 return -1;
1286 } 1285 }
1287 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) { 1286 if (ext4_has_feature_quota(sb)) {
1288 ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options " 1287 ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options "
1289 "when QUOTA feature is enabled"); 1288 "when QUOTA feature is enabled");
1290 return -1; 1289 return -1;
@@ -1643,8 +1642,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1643 "quota options when quota turned on"); 1642 "quota options when quota turned on");
1644 return -1; 1643 return -1;
1645 } 1644 }
1646 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 1645 if (ext4_has_feature_quota(sb)) {
1647 EXT4_FEATURE_RO_COMPAT_QUOTA)) {
1648 ext4_msg(sb, KERN_ERR, 1646 ext4_msg(sb, KERN_ERR,
1649 "Cannot set journaled quota options " 1647 "Cannot set journaled quota options "
1650 "when QUOTA feature is enabled"); 1648 "when QUOTA feature is enabled");
@@ -1703,7 +1701,7 @@ static int parse_options(char *options, struct super_block *sb,
1703 return 0; 1701 return 0;
1704 } 1702 }
1705#ifdef CONFIG_QUOTA 1703#ifdef CONFIG_QUOTA
1706 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && 1704 if (ext4_has_feature_quota(sb) &&
1707 (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) { 1705 (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) {
1708 ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA " 1706 ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA "
1709 "feature is enabled"); 1707 "feature is enabled");
@@ -1927,7 +1925,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1927 es->s_mtime = cpu_to_le32(get_seconds()); 1925 es->s_mtime = cpu_to_le32(get_seconds());
1928 ext4_update_dynamic_rev(sb); 1926 ext4_update_dynamic_rev(sb);
1929 if (sbi->s_journal) 1927 if (sbi->s_journal)
1930 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 1928 ext4_set_feature_journal_needs_recovery(sb);
1931 1929
1932 ext4_commit_super(sb, 1); 1930 ext4_commit_super(sb, 1);
1933done: 1931done:
@@ -2010,12 +2008,13 @@ failed:
2010 return 0; 2008 return 0;
2011} 2009}
2012 2010
2013static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group, 2011static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group,
2014 struct ext4_group_desc *gdp) 2012 struct ext4_group_desc *gdp)
2015{ 2013{
2016 int offset; 2014 int offset;
2017 __u16 crc = 0; 2015 __u16 crc = 0;
2018 __le32 le_group = cpu_to_le32(block_group); 2016 __le32 le_group = cpu_to_le32(block_group);
2017 struct ext4_sb_info *sbi = EXT4_SB(sb);
2019 2018
2020 if (ext4_has_metadata_csum(sbi->s_sb)) { 2019 if (ext4_has_metadata_csum(sbi->s_sb)) {
2021 /* Use new metadata_csum algorithm */ 2020 /* Use new metadata_csum algorithm */
@@ -2035,8 +2034,7 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
2035 } 2034 }
2036 2035
2037 /* old crc16 code */ 2036 /* old crc16 code */
2038 if (!(sbi->s_es->s_feature_ro_compat & 2037 if (!ext4_has_feature_gdt_csum(sb))
2039 cpu_to_le32(EXT4_FEATURE_RO_COMPAT_GDT_CSUM)))
2040 return 0; 2038 return 0;
2041 2039
2042 offset = offsetof(struct ext4_group_desc, bg_checksum); 2040 offset = offsetof(struct ext4_group_desc, bg_checksum);
@@ -2046,8 +2044,7 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
2046 crc = crc16(crc, (__u8 *)gdp, offset); 2044 crc = crc16(crc, (__u8 *)gdp, offset);
2047 offset += sizeof(gdp->bg_checksum); /* skip checksum */ 2045 offset += sizeof(gdp->bg_checksum); /* skip checksum */
2048 /* for checksum of struct ext4_group_desc do the rest...*/ 2046 /* for checksum of struct ext4_group_desc do the rest...*/
2049 if ((sbi->s_es->s_feature_incompat & 2047 if (ext4_has_feature_64bit(sb) &&
2050 cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT)) &&
2051 offset < le16_to_cpu(sbi->s_es->s_desc_size)) 2048 offset < le16_to_cpu(sbi->s_es->s_desc_size))
2052 crc = crc16(crc, (__u8 *)gdp + offset, 2049 crc = crc16(crc, (__u8 *)gdp + offset,
2053 le16_to_cpu(sbi->s_es->s_desc_size) - 2050 le16_to_cpu(sbi->s_es->s_desc_size) -
@@ -2061,8 +2058,7 @@ int ext4_group_desc_csum_verify(struct super_block *sb, __u32 block_group,
2061 struct ext4_group_desc *gdp) 2058 struct ext4_group_desc *gdp)
2062{ 2059{
2063 if (ext4_has_group_desc_csum(sb) && 2060 if (ext4_has_group_desc_csum(sb) &&
2064 (gdp->bg_checksum != ext4_group_desc_csum(EXT4_SB(sb), 2061 (gdp->bg_checksum != ext4_group_desc_csum(sb, block_group, gdp)))
2065 block_group, gdp)))
2066 return 0; 2062 return 0;
2067 2063
2068 return 1; 2064 return 1;
@@ -2073,7 +2069,7 @@ void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group,
2073{ 2069{
2074 if (!ext4_has_group_desc_csum(sb)) 2070 if (!ext4_has_group_desc_csum(sb))
2075 return; 2071 return;
2076 gdp->bg_checksum = ext4_group_desc_csum(EXT4_SB(sb), block_group, gdp); 2072 gdp->bg_checksum = ext4_group_desc_csum(sb, block_group, gdp);
2077} 2073}
2078 2074
2079/* Called at mount-time, super-block is locked */ 2075/* Called at mount-time, super-block is locked */
@@ -2089,7 +2085,7 @@ static int ext4_check_descriptors(struct super_block *sb,
2089 int flexbg_flag = 0; 2085 int flexbg_flag = 0;
2090 ext4_group_t i, grp = sbi->s_groups_count; 2086 ext4_group_t i, grp = sbi->s_groups_count;
2091 2087
2092 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 2088 if (ext4_has_feature_flex_bg(sb))
2093 flexbg_flag = 1; 2089 flexbg_flag = 1;
2094 2090
2095 ext4_debug("Checking group descriptors"); 2091 ext4_debug("Checking group descriptors");
@@ -2133,7 +2129,7 @@ static int ext4_check_descriptors(struct super_block *sb,
2133 if (!ext4_group_desc_csum_verify(sb, i, gdp)) { 2129 if (!ext4_group_desc_csum_verify(sb, i, gdp)) {
2134 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2130 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2135 "Checksum for group %u failed (%u!=%u)", 2131 "Checksum for group %u failed (%u!=%u)",
2136 i, le16_to_cpu(ext4_group_desc_csum(sbi, i, 2132 i, le16_to_cpu(ext4_group_desc_csum(sb, i,
2137 gdp)), le16_to_cpu(gdp->bg_checksum)); 2133 gdp)), le16_to_cpu(gdp->bg_checksum));
2138 if (!(sb->s_flags & MS_RDONLY)) { 2134 if (!(sb->s_flags & MS_RDONLY)) {
2139 ext4_unlock_group(sb, i); 2135 ext4_unlock_group(sb, i);
@@ -2396,8 +2392,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
2396 2392
2397 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); 2393 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
2398 2394
2399 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) || 2395 if (!ext4_has_feature_meta_bg(sb) || nr < first_meta_bg)
2400 nr < first_meta_bg)
2401 return logical_sb_block + nr + 1; 2396 return logical_sb_block + nr + 1;
2402 bg = sbi->s_desc_per_block * nr; 2397 bg = sbi->s_desc_per_block * nr;
2403 if (ext4_bg_has_super(sb, bg)) 2398 if (ext4_bg_has_super(sb, bg))
@@ -2461,7 +2456,7 @@ static unsigned long ext4_get_stripe_size(struct ext4_sb_info *sbi)
2461 */ 2456 */
2462static int ext4_feature_set_ok(struct super_block *sb, int readonly) 2457static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2463{ 2458{
2464 if (EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP)) { 2459 if (ext4_has_unknown_ext4_incompat_features(sb)) {
2465 ext4_msg(sb, KERN_ERR, 2460 ext4_msg(sb, KERN_ERR,
2466 "Couldn't mount because of " 2461 "Couldn't mount because of "
2467 "unsupported optional features (%x)", 2462 "unsupported optional features (%x)",
@@ -2473,14 +2468,14 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2473 if (readonly) 2468 if (readonly)
2474 return 1; 2469 return 1;
2475 2470
2476 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_READONLY)) { 2471 if (ext4_has_feature_readonly(sb)) {
2477 ext4_msg(sb, KERN_INFO, "filesystem is read-only"); 2472 ext4_msg(sb, KERN_INFO, "filesystem is read-only");
2478 sb->s_flags |= MS_RDONLY; 2473 sb->s_flags |= MS_RDONLY;
2479 return 1; 2474 return 1;
2480 } 2475 }
2481 2476
2482 /* Check that feature set is OK for a read-write mount */ 2477 /* Check that feature set is OK for a read-write mount */
2483 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP)) { 2478 if (ext4_has_unknown_ext4_ro_compat_features(sb)) {
2484 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " 2479 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
2485 "unsupported optional features (%x)", 2480 "unsupported optional features (%x)",
2486 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & 2481 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) &
@@ -2491,7 +2486,7 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2491 * Large file size enabled file system can only be mounted 2486 * Large file size enabled file system can only be mounted
2492 * read-write on 32-bit systems if kernel is built with CONFIG_LBDAF 2487 * read-write on 32-bit systems if kernel is built with CONFIG_LBDAF
2493 */ 2488 */
2494 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) { 2489 if (ext4_has_feature_huge_file(sb)) {
2495 if (sizeof(blkcnt_t) < sizeof(u64)) { 2490 if (sizeof(blkcnt_t) < sizeof(u64)) {
2496 ext4_msg(sb, KERN_ERR, "Filesystem with huge files " 2491 ext4_msg(sb, KERN_ERR, "Filesystem with huge files "
2497 "cannot be mounted RDWR without " 2492 "cannot be mounted RDWR without "
@@ -2499,8 +2494,7 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2499 return 0; 2494 return 0;
2500 } 2495 }
2501 } 2496 }
2502 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC) && 2497 if (ext4_has_feature_bigalloc(sb) && !ext4_has_feature_extents(sb)) {
2503 !EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
2504 ext4_msg(sb, KERN_ERR, 2498 ext4_msg(sb, KERN_ERR,
2505 "Can't support bigalloc feature without " 2499 "Can't support bigalloc feature without "
2506 "extents feature\n"); 2500 "extents feature\n");
@@ -2508,8 +2502,7 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2508 } 2502 }
2509 2503
2510#ifndef CONFIG_QUOTA 2504#ifndef CONFIG_QUOTA
2511 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && 2505 if (ext4_has_feature_quota(sb) && !readonly) {
2512 !readonly) {
2513 ext4_msg(sb, KERN_ERR, 2506 ext4_msg(sb, KERN_ERR,
2514 "Filesystem with quota feature cannot be mounted RDWR " 2507 "Filesystem with quota feature cannot be mounted RDWR "
2515 "without CONFIG_QUOTA"); 2508 "without CONFIG_QUOTA");
@@ -2966,7 +2959,7 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp,
2966 ext4_group_t i, ngroups = ext4_get_groups_count(sb); 2959 ext4_group_t i, ngroups = ext4_get_groups_count(sb);
2967 int s, j, count = 0; 2960 int s, j, count = 0;
2968 2961
2969 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_BIGALLOC)) 2962 if (!ext4_has_feature_bigalloc(sb))
2970 return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) + 2963 return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) +
2971 sbi->s_itb_per_group + 2); 2964 sbi->s_itb_per_group + 2);
2972 2965
@@ -3068,7 +3061,7 @@ static void ext4_set_resv_clusters(struct super_block *sb)
3068 * hole punching doesn't need new metadata... This is needed especially 3061 * hole punching doesn't need new metadata... This is needed especially
3069 * to keep ext2/3 backward compatibility. 3062 * to keep ext2/3 backward compatibility.
3070 */ 3063 */
3071 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) 3064 if (!ext4_has_feature_extents(sb))
3072 return; 3065 return;
3073 /* 3066 /*
3074 * By default we reserve 2% or 4096 clusters, whichever is smaller. 3067 * By default we reserve 2% or 4096 clusters, whichever is smaller.
@@ -3167,9 +3160,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3167 sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written); 3160 sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written);
3168 3161
3169 /* Warn if metadata_csum and gdt_csum are both set. */ 3162 /* Warn if metadata_csum and gdt_csum are both set. */
3170 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3163 if (ext4_has_feature_metadata_csum(sb) &&
3171 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) && 3164 ext4_has_feature_gdt_csum(sb))
3172 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
3173 ext4_warning(sb, "metadata_csum and uninit_bg are " 3165 ext4_warning(sb, "metadata_csum and uninit_bg are "
3174 "redundant flags; please run fsck."); 3166 "redundant flags; please run fsck.");
3175 3167
@@ -3182,8 +3174,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3182 } 3174 }
3183 3175
3184 /* Load the checksum driver */ 3176 /* Load the checksum driver */
3185 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3177 if (ext4_has_feature_metadata_csum(sb)) {
3186 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
3187 sbi->s_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); 3178 sbi->s_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
3188 if (IS_ERR(sbi->s_chksum_driver)) { 3179 if (IS_ERR(sbi->s_chksum_driver)) {
3189 ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); 3180 ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver.");
@@ -3203,7 +3194,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3203 } 3194 }
3204 3195
3205 /* Precompute checksum seed for all metadata */ 3196 /* Precompute checksum seed for all metadata */
3206 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_CSUM_SEED)) 3197 if (ext4_has_feature_csum_seed(sb))
3207 sbi->s_csum_seed = le32_to_cpu(es->s_checksum_seed); 3198 sbi->s_csum_seed = le32_to_cpu(es->s_checksum_seed);
3208 else if (ext4_has_metadata_csum(sb)) 3199 else if (ext4_has_metadata_csum(sb))
3209 sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid, 3200 sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
@@ -3308,17 +3299,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3308 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); 3299 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3309 3300
3310 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV && 3301 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
3311 (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || 3302 (ext4_has_compat_features(sb) ||
3312 EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 3303 ext4_has_ro_compat_features(sb) ||
3313 EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U))) 3304 ext4_has_incompat_features(sb)))
3314 ext4_msg(sb, KERN_WARNING, 3305 ext4_msg(sb, KERN_WARNING,
3315 "feature flags set on rev 0 fs, " 3306 "feature flags set on rev 0 fs, "
3316 "running e2fsck is recommended"); 3307 "running e2fsck is recommended");
3317 3308
3318 if (es->s_creator_os == cpu_to_le32(EXT4_OS_HURD)) { 3309 if (es->s_creator_os == cpu_to_le32(EXT4_OS_HURD)) {
3319 set_opt2(sb, HURD_COMPAT); 3310 set_opt2(sb, HURD_COMPAT);
3320 if (EXT4_HAS_INCOMPAT_FEATURE(sb, 3311 if (ext4_has_feature_64bit(sb)) {
3321 EXT4_FEATURE_INCOMPAT_64BIT)) {
3322 ext4_msg(sb, KERN_ERR, 3312 ext4_msg(sb, KERN_ERR,
3323 "The Hurd can't support 64-bit file systems"); 3313 "The Hurd can't support 64-bit file systems");
3324 goto failed_mount; 3314 goto failed_mount;
@@ -3376,8 +3366,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3376 } 3366 }
3377 } 3367 }
3378 3368
3379 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT) && 3369 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) {
3380 es->s_encryption_level) {
3381 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", 3370 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d",
3382 es->s_encryption_level); 3371 es->s_encryption_level);
3383 goto failed_mount; 3372 goto failed_mount;
@@ -3409,8 +3398,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3409 } 3398 }
3410 } 3399 }
3411 3400
3412 has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, 3401 has_huge_files = ext4_has_feature_huge_file(sb);
3413 EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
3414 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, 3402 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits,
3415 has_huge_files); 3403 has_huge_files);
3416 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); 3404 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files);
@@ -3434,7 +3422,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3434 } 3422 }
3435 3423
3436 sbi->s_desc_size = le16_to_cpu(es->s_desc_size); 3424 sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
3437 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { 3425 if (ext4_has_feature_64bit(sb)) {
3438 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || 3426 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
3439 sbi->s_desc_size > EXT4_MAX_DESC_SIZE || 3427 sbi->s_desc_size > EXT4_MAX_DESC_SIZE ||
3440 !is_power_of_2(sbi->s_desc_size)) { 3428 !is_power_of_2(sbi->s_desc_size)) {
@@ -3465,7 +3453,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3465 for (i = 0; i < 4; i++) 3453 for (i = 0; i < 4; i++)
3466 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 3454 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
3467 sbi->s_def_hash_version = es->s_def_hash_version; 3455 sbi->s_def_hash_version = es->s_def_hash_version;
3468 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) { 3456 if (ext4_has_feature_dir_index(sb)) {
3469 i = le32_to_cpu(es->s_flags); 3457 i = le32_to_cpu(es->s_flags);
3470 if (i & EXT2_FLAGS_UNSIGNED_HASH) 3458 if (i & EXT2_FLAGS_UNSIGNED_HASH)
3471 sbi->s_hash_unsigned = 3; 3459 sbi->s_hash_unsigned = 3;
@@ -3485,8 +3473,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3485 3473
3486 /* Handle clustersize */ 3474 /* Handle clustersize */
3487 clustersize = BLOCK_SIZE << le32_to_cpu(es->s_log_cluster_size); 3475 clustersize = BLOCK_SIZE << le32_to_cpu(es->s_log_cluster_size);
3488 has_bigalloc = EXT4_HAS_RO_COMPAT_FEATURE(sb, 3476 has_bigalloc = ext4_has_feature_bigalloc(sb);
3489 EXT4_FEATURE_RO_COMPAT_BIGALLOC);
3490 if (has_bigalloc) { 3477 if (has_bigalloc) {
3491 if (clustersize < blocksize) { 3478 if (clustersize < blocksize) {
3492 ext4_msg(sb, KERN_ERR, 3479 ext4_msg(sb, KERN_ERR,
@@ -3645,7 +3632,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3645 sb->s_xattr = ext4_xattr_handlers; 3632 sb->s_xattr = ext4_xattr_handlers;
3646#ifdef CONFIG_QUOTA 3633#ifdef CONFIG_QUOTA
3647 sb->dq_op = &ext4_quota_operations; 3634 sb->dq_op = &ext4_quota_operations;
3648 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) 3635 if (ext4_has_feature_quota(sb))
3649 sb->s_qcop = &dquot_quotactl_sysfile_ops; 3636 sb->s_qcop = &dquot_quotactl_sysfile_ops;
3650 else 3637 else
3651 sb->s_qcop = &ext4_qctl_operations; 3638 sb->s_qcop = &ext4_qctl_operations;
@@ -3659,11 +3646,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3659 sb->s_root = NULL; 3646 sb->s_root = NULL;
3660 3647
3661 needs_recovery = (es->s_last_orphan != 0 || 3648 needs_recovery = (es->s_last_orphan != 0 ||
3662 EXT4_HAS_INCOMPAT_FEATURE(sb, 3649 ext4_has_feature_journal_needs_recovery(sb));
3663 EXT4_FEATURE_INCOMPAT_RECOVER));
3664 3650
3665 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) && 3651 if (ext4_has_feature_mmp(sb) && !(sb->s_flags & MS_RDONLY))
3666 !(sb->s_flags & MS_RDONLY))
3667 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 3652 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
3668 goto failed_mount3a; 3653 goto failed_mount3a;
3669 3654
@@ -3671,12 +3656,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3671 * The first inode we look at is the journal inode. Don't try 3656 * The first inode we look at is the journal inode. Don't try
3672 * root first: it may be modified in the journal! 3657 * root first: it may be modified in the journal!
3673 */ 3658 */
3674 if (!test_opt(sb, NOLOAD) && 3659 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) {
3675 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
3676 if (ext4_load_journal(sb, es, journal_devnum)) 3660 if (ext4_load_journal(sb, es, journal_devnum))
3677 goto failed_mount3a; 3661 goto failed_mount3a;
3678 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && 3662 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
3679 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 3663 ext4_has_feature_journal_needs_recovery(sb)) {
3680 ext4_msg(sb, KERN_ERR, "required journal recovery " 3664 ext4_msg(sb, KERN_ERR, "required journal recovery "
3681 "suppressed and not mounted read-only"); 3665 "suppressed and not mounted read-only");
3682 goto failed_mount_wq; 3666 goto failed_mount_wq;
@@ -3687,7 +3671,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3687 goto no_journal; 3671 goto no_journal;
3688 } 3672 }
3689 3673
3690 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT) && 3674 if (ext4_has_feature_64bit(sb) &&
3691 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, 3675 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
3692 JBD2_FEATURE_INCOMPAT_64BIT)) { 3676 JBD2_FEATURE_INCOMPAT_64BIT)) {
3693 ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); 3677 ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature");
@@ -3739,18 +3723,16 @@ no_journal:
3739 } 3723 }
3740 } 3724 }
3741 3725
3742 if ((DUMMY_ENCRYPTION_ENABLED(sbi) || 3726 if ((DUMMY_ENCRYPTION_ENABLED(sbi) || ext4_has_feature_encrypt(sb)) &&
3743 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT)) &&
3744 (blocksize != PAGE_CACHE_SIZE)) { 3727 (blocksize != PAGE_CACHE_SIZE)) {
3745 ext4_msg(sb, KERN_ERR, 3728 ext4_msg(sb, KERN_ERR,
3746 "Unsupported blocksize for fs encryption"); 3729 "Unsupported blocksize for fs encryption");
3747 goto failed_mount_wq; 3730 goto failed_mount_wq;
3748 } 3731 }
3749 3732
3750 if (DUMMY_ENCRYPTION_ENABLED(sbi) && 3733 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !(sb->s_flags & MS_RDONLY) &&
3751 !(sb->s_flags & MS_RDONLY) && 3734 !ext4_has_feature_encrypt(sb)) {
3752 !EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT)) { 3735 ext4_set_feature_encrypt(sb);
3753 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT);
3754 ext4_commit_super(sb, 1); 3736 ext4_commit_super(sb, 1);
3755 } 3737 }
3756 3738
@@ -3809,8 +3791,7 @@ no_journal:
3809 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) { 3791 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
3810 sbi->s_want_extra_isize = sizeof(struct ext4_inode) - 3792 sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
3811 EXT4_GOOD_OLD_INODE_SIZE; 3793 EXT4_GOOD_OLD_INODE_SIZE;
3812 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3794 if (ext4_has_feature_extra_isize(sb)) {
3813 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)) {
3814 if (sbi->s_want_extra_isize < 3795 if (sbi->s_want_extra_isize <
3815 le16_to_cpu(es->s_want_extra_isize)) 3796 le16_to_cpu(es->s_want_extra_isize))
3816 sbi->s_want_extra_isize = 3797 sbi->s_want_extra_isize =
@@ -3869,7 +3850,7 @@ no_journal:
3869 goto failed_mount6; 3850 goto failed_mount6;
3870 } 3851 }
3871 3852
3872 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 3853 if (ext4_has_feature_flex_bg(sb))
3873 if (!ext4_fill_flex_info(sb)) { 3854 if (!ext4_fill_flex_info(sb)) {
3874 ext4_msg(sb, KERN_ERR, 3855 ext4_msg(sb, KERN_ERR,
3875 "unable to initialize " 3856 "unable to initialize "
@@ -3887,8 +3868,7 @@ no_journal:
3887 3868
3888#ifdef CONFIG_QUOTA 3869#ifdef CONFIG_QUOTA
3889 /* Enable quota usage during mount. */ 3870 /* Enable quota usage during mount. */
3890 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && 3871 if (ext4_has_feature_quota(sb) && !(sb->s_flags & MS_RDONLY)) {
3891 !(sb->s_flags & MS_RDONLY)) {
3892 err = ext4_enable_quotas(sb); 3872 err = ext4_enable_quotas(sb);
3893 if (err) 3873 if (err)
3894 goto failed_mount8; 3874 goto failed_mount8;
@@ -4029,7 +4009,7 @@ static journal_t *ext4_get_journal(struct super_block *sb,
4029 struct inode *journal_inode; 4009 struct inode *journal_inode;
4030 journal_t *journal; 4010 journal_t *journal;
4031 4011
4032 BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); 4012 BUG_ON(!ext4_has_feature_journal(sb));
4033 4013
4034 /* First, test for the existence of a valid inode on disk. Bad 4014 /* First, test for the existence of a valid inode on disk. Bad
4035 * things happen if we iget() an unused inode, as the subsequent 4015 * things happen if we iget() an unused inode, as the subsequent
@@ -4079,7 +4059,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
4079 struct ext4_super_block *es; 4059 struct ext4_super_block *es;
4080 struct block_device *bdev; 4060 struct block_device *bdev;
4081 4061
4082 BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); 4062 BUG_ON(!ext4_has_feature_journal(sb));
4083 4063
4084 bdev = ext4_blkdev_get(j_dev, sb); 4064 bdev = ext4_blkdev_get(j_dev, sb);
4085 if (bdev == NULL) 4065 if (bdev == NULL)
@@ -4171,7 +4151,7 @@ static int ext4_load_journal(struct super_block *sb,
4171 int err = 0; 4151 int err = 0;
4172 int really_read_only; 4152 int really_read_only;
4173 4153
4174 BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); 4154 BUG_ON(!ext4_has_feature_journal(sb));
4175 4155
4176 if (journal_devnum && 4156 if (journal_devnum &&
4177 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 4157 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -4188,7 +4168,7 @@ static int ext4_load_journal(struct super_block *sb,
4188 * crash? For recovery, we need to check in advance whether we 4168 * crash? For recovery, we need to check in advance whether we
4189 * can get read-write access to the device. 4169 * can get read-write access to the device.
4190 */ 4170 */
4191 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 4171 if (ext4_has_feature_journal_needs_recovery(sb)) {
4192 if (sb->s_flags & MS_RDONLY) { 4172 if (sb->s_flags & MS_RDONLY) {
4193 ext4_msg(sb, KERN_INFO, "INFO: recovery " 4173 ext4_msg(sb, KERN_INFO, "INFO: recovery "
4194 "required on readonly filesystem"); 4174 "required on readonly filesystem");
@@ -4219,7 +4199,7 @@ static int ext4_load_journal(struct super_block *sb,
4219 if (!(journal->j_flags & JBD2_BARRIER)) 4199 if (!(journal->j_flags & JBD2_BARRIER))
4220 ext4_msg(sb, KERN_INFO, "barriers disabled"); 4200 ext4_msg(sb, KERN_INFO, "barriers disabled");
4221 4201
4222 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) 4202 if (!ext4_has_feature_journal_needs_recovery(sb))
4223 err = jbd2_journal_wipe(journal, !really_read_only); 4203 err = jbd2_journal_wipe(journal, !really_read_only);
4224 if (!err) { 4204 if (!err) {
4225 char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); 4205 char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL);
@@ -4333,7 +4313,7 @@ static void ext4_mark_recovery_complete(struct super_block *sb,
4333{ 4313{
4334 journal_t *journal = EXT4_SB(sb)->s_journal; 4314 journal_t *journal = EXT4_SB(sb)->s_journal;
4335 4315
4336 if (!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { 4316 if (!ext4_has_feature_journal(sb)) {
4337 BUG_ON(journal != NULL); 4317 BUG_ON(journal != NULL);
4338 return; 4318 return;
4339 } 4319 }
@@ -4341,9 +4321,9 @@ static void ext4_mark_recovery_complete(struct super_block *sb,
4341 if (jbd2_journal_flush(journal) < 0) 4321 if (jbd2_journal_flush(journal) < 0)
4342 goto out; 4322 goto out;
4343 4323
4344 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && 4324 if (ext4_has_feature_journal_needs_recovery(sb) &&
4345 sb->s_flags & MS_RDONLY) { 4325 sb->s_flags & MS_RDONLY) {
4346 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 4326 ext4_clear_feature_journal_needs_recovery(sb);
4347 ext4_commit_super(sb, 1); 4327 ext4_commit_super(sb, 1);
4348 } 4328 }
4349 4329
@@ -4363,7 +4343,7 @@ static void ext4_clear_journal_err(struct super_block *sb,
4363 int j_errno; 4343 int j_errno;
4364 const char *errstr; 4344 const char *errstr;
4365 4345
4366 BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); 4346 BUG_ON(!ext4_has_feature_journal(sb));
4367 4347
4368 journal = EXT4_SB(sb)->s_journal; 4348 journal = EXT4_SB(sb)->s_journal;
4369 4349
@@ -4478,7 +4458,7 @@ static int ext4_freeze(struct super_block *sb)
4478 goto out; 4458 goto out;
4479 4459
4480 /* Journal blocked and flushed, clear needs_recovery flag. */ 4460 /* Journal blocked and flushed, clear needs_recovery flag. */
4481 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 4461 ext4_clear_feature_journal_needs_recovery(sb);
4482 } 4462 }
4483 4463
4484 error = ext4_commit_super(sb, 1); 4464 error = ext4_commit_super(sb, 1);
@@ -4500,7 +4480,7 @@ static int ext4_unfreeze(struct super_block *sb)
4500 4480
4501 if (EXT4_SB(sb)->s_journal) { 4481 if (EXT4_SB(sb)->s_journal) {
4502 /* Reset the needs_recovery flag before the fs is unlocked. */ 4482 /* Reset the needs_recovery flag before the fs is unlocked. */
4503 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 4483 ext4_set_feature_journal_needs_recovery(sb);
4504 } 4484 }
4505 4485
4506 ext4_commit_super(sb, 1); 4486 ext4_commit_super(sb, 1);
@@ -4653,8 +4633,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4653 ext4_mark_recovery_complete(sb, es); 4633 ext4_mark_recovery_complete(sb, es);
4654 } else { 4634 } else {
4655 /* Make sure we can mount this feature set readwrite */ 4635 /* Make sure we can mount this feature set readwrite */
4656 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 4636 if (ext4_has_feature_readonly(sb) ||
4657 EXT4_FEATURE_RO_COMPAT_READONLY) ||
4658 !ext4_feature_set_ok(sb, 0)) { 4637 !ext4_feature_set_ok(sb, 0)) {
4659 err = -EROFS; 4638 err = -EROFS;
4660 goto restore_opts; 4639 goto restore_opts;
@@ -4670,7 +4649,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4670 if (!ext4_group_desc_csum_verify(sb, g, gdp)) { 4649 if (!ext4_group_desc_csum_verify(sb, g, gdp)) {
4671 ext4_msg(sb, KERN_ERR, 4650 ext4_msg(sb, KERN_ERR,
4672 "ext4_remount: Checksum for group %u failed (%u!=%u)", 4651 "ext4_remount: Checksum for group %u failed (%u!=%u)",
4673 g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), 4652 g, le16_to_cpu(ext4_group_desc_csum(sb, g, gdp)),
4674 le16_to_cpu(gdp->bg_checksum)); 4653 le16_to_cpu(gdp->bg_checksum));
4675 err = -EFSBADCRC; 4654 err = -EFSBADCRC;
4676 goto restore_opts; 4655 goto restore_opts;
@@ -4702,8 +4681,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4702 sbi->s_mount_state = le16_to_cpu(es->s_state); 4681 sbi->s_mount_state = le16_to_cpu(es->s_state);
4703 if (!ext4_setup_super(sb, es, 0)) 4682 if (!ext4_setup_super(sb, es, 0))
4704 sb->s_flags &= ~MS_RDONLY; 4683 sb->s_flags &= ~MS_RDONLY;
4705 if (EXT4_HAS_INCOMPAT_FEATURE(sb, 4684 if (ext4_has_feature_mmp(sb))
4706 EXT4_FEATURE_INCOMPAT_MMP))
4707 if (ext4_multi_mount_protect(sb, 4685 if (ext4_multi_mount_protect(sb,
4708 le64_to_cpu(es->s_mmp_block))) { 4686 le64_to_cpu(es->s_mmp_block))) {
4709 err = -EROFS; 4687 err = -EROFS;
@@ -4736,8 +4714,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4736 if (enable_quota) { 4714 if (enable_quota) {
4737 if (sb_any_quota_suspended(sb)) 4715 if (sb_any_quota_suspended(sb))
4738 dquot_resume(sb, -1); 4716 dquot_resume(sb, -1);
4739 else if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 4717 else if (ext4_has_feature_quota(sb)) {
4740 EXT4_FEATURE_RO_COMPAT_QUOTA)) {
4741 err = ext4_enable_quotas(sb); 4718 err = ext4_enable_quotas(sb);
4742 if (err) 4719 if (err)
4743 goto restore_opts; 4720 goto restore_opts;
@@ -4881,7 +4858,7 @@ static int ext4_mark_dquot_dirty(struct dquot *dquot)
4881 struct ext4_sb_info *sbi = EXT4_SB(sb); 4858 struct ext4_sb_info *sbi = EXT4_SB(sb);
4882 4859
4883 /* Are we journaling quotas? */ 4860 /* Are we journaling quotas? */
4884 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) || 4861 if (ext4_has_feature_quota(sb) ||
4885 sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { 4862 sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
4886 dquot_mark_dquot_dirty(dquot); 4863 dquot_mark_dquot_dirty(dquot);
4887 return ext4_write_dquot(dquot); 4864 return ext4_write_dquot(dquot);
@@ -4969,7 +4946,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
4969 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum) 4946 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
4970 }; 4947 };
4971 4948
4972 BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)); 4949 BUG_ON(!ext4_has_feature_quota(sb));
4973 4950
4974 if (!qf_inums[type]) 4951 if (!qf_inums[type])
4975 return -EPERM; 4952 return -EPERM;
@@ -5163,11 +5140,11 @@ static inline void unregister_as_ext2(void)
5163 5140
5164static inline int ext2_feature_set_ok(struct super_block *sb) 5141static inline int ext2_feature_set_ok(struct super_block *sb)
5165{ 5142{
5166 if (EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP)) 5143 if (ext4_has_unknown_ext2_incompat_features(sb))
5167 return 0; 5144 return 0;
5168 if (sb->s_flags & MS_RDONLY) 5145 if (sb->s_flags & MS_RDONLY)
5169 return 1; 5146 return 1;
5170 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP)) 5147 if (ext4_has_unknown_ext2_ro_compat_features(sb))
5171 return 0; 5148 return 0;
5172 return 1; 5149 return 1;
5173} 5150}
@@ -5192,13 +5169,13 @@ static inline void unregister_as_ext3(void)
5192 5169
5193static inline int ext3_feature_set_ok(struct super_block *sb) 5170static inline int ext3_feature_set_ok(struct super_block *sb)
5194{ 5171{
5195 if (EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP)) 5172 if (ext4_has_unknown_ext3_incompat_features(sb))
5196 return 0; 5173 return 0;
5197 if (!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) 5174 if (!ext4_has_feature_journal(sb))
5198 return 0; 5175 return 0;
5199 if (sb->s_flags & MS_RDONLY) 5176 if (sb->s_flags & MS_RDONLY)
5200 return 1; 5177 return 1;
5201 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP)) 5178 if (ext4_has_unknown_ext3_ro_compat_features(sb))
5202 return 0; 5179 return 0;
5203 return 1; 5180 return 1;
5204} 5181}
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 7649422ed7a1..984448c6f5f0 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -525,12 +525,12 @@ errout:
525static void ext4_xattr_update_super_block(handle_t *handle, 525static void ext4_xattr_update_super_block(handle_t *handle,
526 struct super_block *sb) 526 struct super_block *sb)
527{ 527{
528 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR)) 528 if (ext4_has_feature_xattr(sb))
529 return; 529 return;
530 530
531 BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access"); 531 BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
532 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { 532 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
533 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); 533 ext4_set_feature_xattr(sb);
534 ext4_handle_dirty_super(handle, sb); 534 ext4_handle_dirty_super(handle, sb);
535 } 535 }
536} 536}