]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/ext4-don-t-update-s_rev_level-if-not-required.patch
Linux 4.14.121
[thirdparty/kernel/stable-queue.git] / queue-4.19 / ext4-don-t-update-s_rev_level-if-not-required.patch
1 From c9e716eb9b3455a83ed7c5f5a81256a3da779a95 Mon Sep 17 00:00:00 2001
2 From: Andreas Dilger <adilger@dilger.ca>
3 Date: Thu, 14 Feb 2019 17:52:18 -0500
4 Subject: ext4: don't update s_rev_level if not required
5
6 From: Andreas Dilger <adilger@dilger.ca>
7
8 commit c9e716eb9b3455a83ed7c5f5a81256a3da779a95 upstream.
9
10 Don't update the superblock s_rev_level during mount if it isn't
11 actually necessary, only if superblock features are being set by
12 the kernel. This was originally added for ext3 since it always
13 set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount,
14 but this is not needed since no journal mode was added to ext4.
15
16 That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k
17 filesystem, as a testament of the backward compatibility of ext4.
18
19 Fixes: 0390131ba84f ("ext4: Allow ext4 to run without a journal")
20 Signed-off-by: Andreas Dilger <adilger@dilger.ca>
21 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
22 Signed-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 @@ -1670,6 +1670,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 @@ -1678,6 +1680,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 @@ -1695,6 +1698,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 @@ -1712,6 +1716,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 @@ -2679,7 +2684,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
75 @@ -5320,7 +5320,6 @@ static int ext4_do_update_inode(handle_t
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