1 ext4: don't update s_rev_level if not required
3 From: Andreas Dilger <adilger@dilger.ca>
5 Don't update the superblock s_rev_level during mount if it isn't
6 actually necessary, only if superblock features are being set by
7 the kernel. This was originally added for ext3 since it always
8 set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount,
9 but this is not needed since no journal mode was added to ext4.
11 That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k
12 filesystem, as a testament of the backward compatibility of ext4.
14 Fixes: 0390131ba84f ("ext4: Allow ext4 to run without a journal")
15 Signed-off-by: Andreas Dilger <adilger@dilger.ca>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18 fs/ext4/ext4.h | 6 +++++-
21 3 files changed, 5 insertions(+), 3 deletions(-)
23 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
24 index 508a37ec9271..b8fde74ff76d 100644
27 @@ -1665,6 +1665,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
28 #define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
29 #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
31 +extern void ext4_update_dynamic_rev(struct super_block *sb);
33 #define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
34 static inline bool ext4_has_feature_##name(struct super_block *sb) \
36 @@ -1673,6 +1675,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
38 static inline void ext4_set_feature_##name(struct super_block *sb) \
40 + ext4_update_dynamic_rev(sb); \
41 EXT4_SB(sb)->s_es->s_feature_compat |= \
42 cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
44 @@ -1690,6 +1693,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
46 static inline void ext4_set_feature_##name(struct super_block *sb) \
48 + ext4_update_dynamic_rev(sb); \
49 EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
50 cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
52 @@ -1707,6 +1711,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
54 static inline void ext4_set_feature_##name(struct super_block *sb) \
56 + ext4_update_dynamic_rev(sb); \
57 EXT4_SB(sb)->s_es->s_feature_incompat |= \
58 cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
60 @@ -2675,7 +2680,6 @@ do { \
64 -extern void ext4_update_dynamic_rev(struct super_block *sb);
65 extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
67 extern int ext4_update_rocompat_feature(handle_t *handle,
68 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
69 index 9c3402ec85bc..2b6eefbc3b34 100644
72 @@ -5345,7 +5345,6 @@ static int ext4_do_update_inode(handle_t *handle,
73 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
76 - ext4_update_dynamic_rev(sb);
77 ext4_set_feature_large_file(sb);
78 ext4_handle_sync(handle);
79 err = ext4_handle_dirty_super(handle, sb);
80 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
81 index fb12d3c17c1b..6e4cac646345 100644
84 @@ -2249,7 +2249,6 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
85 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
86 le16_add_cpu(&es->s_mnt_count, 1);
87 ext4_update_tstamp(es, s_mtime);
88 - ext4_update_dynamic_rev(sb);
90 ext4_set_feature_journal_needs_recovery(sb);