Skip to content

Commit c9e716e

Browse files
adilgertytso
authored andcommitted
ext4: don't update s_rev_level if not required
Don't update the superblock s_rev_level during mount if it isn't actually necessary, only if superblock features are being set by the kernel. This was originally added for ext3 since it always set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount, but this is not needed since no journal mode was added to ext4. That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k filesystem, as a testament of the backward compatibility of ext4. Fixes: 0390131 ("ext4: Allow ext4 to run without a journal") Signed-off-by: Andreas Dilger <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent a58ca99 commit c9e716e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

fs/ext4/ext4.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
16651665
#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
16661666
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
16671667

1668+
extern void ext4_update_dynamic_rev(struct super_block *sb);
1669+
16681670
#define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
16691671
static inline bool ext4_has_feature_##name(struct super_block *sb) \
16701672
{ \
@@ -1673,6 +1675,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
16731675
} \
16741676
static inline void ext4_set_feature_##name(struct super_block *sb) \
16751677
{ \
1678+
ext4_update_dynamic_rev(sb); \
16761679
EXT4_SB(sb)->s_es->s_feature_compat |= \
16771680
cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
16781681
} \
@@ -1690,6 +1693,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
16901693
} \
16911694
static inline void ext4_set_feature_##name(struct super_block *sb) \
16921695
{ \
1696+
ext4_update_dynamic_rev(sb); \
16931697
EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
16941698
cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
16951699
} \
@@ -1707,6 +1711,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
17071711
} \
17081712
static inline void ext4_set_feature_##name(struct super_block *sb) \
17091713
{ \
1714+
ext4_update_dynamic_rev(sb); \
17101715
EXT4_SB(sb)->s_es->s_feature_incompat |= \
17111716
cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
17121717
} \
@@ -2675,7 +2680,6 @@ do { \
26752680

26762681
#endif
26772682

2678-
extern void ext4_update_dynamic_rev(struct super_block *sb);
26792683
extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
26802684
__u32 compat);
26812685
extern int ext4_update_rocompat_feature(handle_t *handle,

fs/ext4/inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5345,7 +5345,6 @@ static int ext4_do_update_inode(handle_t *handle,
53455345
err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
53465346
if (err)
53475347
goto out_brelse;
5348-
ext4_update_dynamic_rev(sb);
53495348
ext4_set_feature_large_file(sb);
53505349
ext4_handle_sync(handle);
53515350
err = ext4_handle_dirty_super(handle, sb);

fs/ext4/super.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,6 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
22492249
es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
22502250
le16_add_cpu(&es->s_mnt_count, 1);
22512251
ext4_update_tstamp(es, s_mtime);
2252-
ext4_update_dynamic_rev(sb);
22532252
if (sbi->s_journal)
22542253
ext4_set_feature_journal_needs_recovery(sb);
22552254

0 commit comments

Comments
 (0)