]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.18/ext4-don-t-update-s_rev_level-if-not-required.patch
Linux 5.0.18
[thirdparty/kernel/stable-queue.git] / releases / 5.0.18 / ext4-don-t-update-s_rev_level-if-not-required.patch
CommitLineData
0ee08727
GKH
1From c9e716eb9b3455a83ed7c5f5a81256a3da779a95 Mon Sep 17 00:00:00 2001
2From: Andreas Dilger <adilger@dilger.ca>
3Date: Thu, 14 Feb 2019 17:52:18 -0500
4Subject: ext4: don't update s_rev_level if not required
5
6From: Andreas Dilger <adilger@dilger.ca>
7
8commit c9e716eb9b3455a83ed7c5f5a81256a3da779a95 upstream.
9
10Don't update the superblock s_rev_level during mount if it isn't
11actually necessary, only if superblock features are being set by
12the kernel. This was originally added for ext3 since it always
13set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount,
14but this is not needed since no journal mode was added to ext4.
15
16That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k
17filesystem, as a testament of the backward compatibility of ext4.
18
19Fixes: 0390131ba84f ("ext4: Allow ext4 to run without a journal")
20Signed-off-by: Andreas Dilger <adilger@dilger.ca>
21Signed-off-by: Theodore Ts'o <tytso@mit.edu>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 fs/ext4/ext4.h | 6 +++++-
26 fs/ext4/inode.c | 1 -
27 fs/ext4/super.c | 1 -
28 3 files changed, 5 insertions(+), 3 deletions(-)
29
30--- a/fs/ext4/ext4.h
31+++ b/fs/ext4/ext4.h
32@@ -1665,6 +1665,8 @@ static inline void ext4_clear_state_flag
33 #define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
34 #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
35
36+extern void ext4_update_dynamic_rev(struct super_block *sb);
37+
38 #define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
39 static inline bool ext4_has_feature_##name(struct super_block *sb) \
40 { \
41@@ -1673,6 +1675,7 @@ static inline bool ext4_has_feature_##na
42 } \
43 static inline void ext4_set_feature_##name(struct super_block *sb) \
44 { \
45+ ext4_update_dynamic_rev(sb); \
46 EXT4_SB(sb)->s_es->s_feature_compat |= \
47 cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
48 } \
49@@ -1690,6 +1693,7 @@ static inline bool ext4_has_feature_##na
50 } \
51 static inline void ext4_set_feature_##name(struct super_block *sb) \
52 { \
53+ ext4_update_dynamic_rev(sb); \
54 EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
55 cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
56 } \
57@@ -1707,6 +1711,7 @@ static inline bool ext4_has_feature_##na
58 } \
59 static inline void ext4_set_feature_##name(struct super_block *sb) \
60 { \
61+ ext4_update_dynamic_rev(sb); \
62 EXT4_SB(sb)->s_es->s_feature_incompat |= \
63 cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
64 } \
65@@ -2675,7 +2680,6 @@ do { \
66
67 #endif
68
69-extern void ext4_update_dynamic_rev(struct super_block *sb);
70 extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
71 __u32 compat);
72 extern int ext4_update_rocompat_feature(handle_t *handle,
73--- a/fs/ext4/inode.c
74+++ b/fs/ext4/inode.c
514377f9 75@@ -5351,7 +5351,6 @@ static int ext4_do_update_inode(handle_t
0ee08727
GKH
76 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
77 if (err)
78 goto out_brelse;
79- ext4_update_dynamic_rev(sb);
80 ext4_set_feature_large_file(sb);
81 ext4_handle_sync(handle);
82 err = ext4_handle_dirty_super(handle, sb);
83--- a/fs/ext4/super.c
84+++ b/fs/ext4/super.c
85@@ -2259,7 +2259,6 @@ static int ext4_setup_super(struct super
86 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
87 le16_add_cpu(&es->s_mnt_count, 1);
88 ext4_update_tstamp(es, s_mtime);
89- ext4_update_dynamic_rev(sb);
90 if (sbi->s_journal)
91 ext4_set_feature_journal_needs_recovery(sb);
92