author: Jan Kara <jack@suse.cz> 2021-08-12 14:47:37 +0200
committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2021-09-08 08:50:19 +0200
commit: b6de6ec37320d28c02d256d94144c6108174c4e7
parent: c764e8fa4491da66780fcb30a0d43bfd3fccd12c
Commit Summary:
Diffstat:
1 file changed, 8 insertions, 0 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6a4e040ea9b3..079bb0f6b343 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5051,6 +5051,14 @@ no_journal:
err = percpu_counter_init(&sbi->s_freeinodes_counter, freei,
GFP_KERNEL);
}
+ /*
+ * Update the checksum after updating free space/inode
+ * counters. Otherwise the superblock can have an incorrect
+ * checksum in the buffer cache until it is written out and
+ * e2fsprogs programs trying to open a file system immediately
+ * after it is mounted can fail.
+ */
+ ext4_superblock_csum_set(sb);
if (!err)
err = percpu_counter_init(&sbi->s_dirs_counter,
ext4_count_dirs(sb), GFP_KERNEL);