Skip to contentSkip to conversation

ext4: Fix tune2fs checksum failure for mounted filesystem

PATCH Applied Jan Kara 2 participants 2 messages Aug 12, 2021 – Aug 14, 2021 ext4 file system

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 ext4: Fix tune2fs checksum failure for mounted filesystem

Commit 81414b4dd48 ("ext4: remove redundant sb checksum recomputation") removed checksum recalculation after updating superblock free space / inode counters in ext4_fill_super() based on the fact that we will recalculate the checksum on superblock writeout. That is correct assumption but until the writeout happens (which can take a long time) the checksum is incorrect in the buffer cache and if tune2fs is called in that time window it will complain. So return back the checksum recalculation and add a comment explaining the tune2fs peculiarity.

Fixes 81414b4dd48f ("ext4: remove redundant sb checksum recomputation")
---
 fs/ext4/super.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/ext4/super.c +6 -0
index dfa09a277b56..8f2474618f7e 100644
@@ -5032,6 +5032,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		err = percpu_counter_init(&sbi->s_freeinodes_counter, freei,
 					  GFP_KERNEL);
 	}
+	/*
+	 * Let's update the checksum after updating free space/inode counters.
+	 * Otherwise sb will have incorrect checksum in the buffer cache until
+	 * sb is written out and tune2fs can get confused.
+	 */
+	ext4_superblock_csum_set(sb);
 	if (!err)
 		err = percpu_counter_init(&sbi->s_dirs_counter,
 					  ext4_count_dirs(sb), GFP_KERNEL);
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 10 lines · Jan Kara

Commit 81414b4dd48 ("ext4: remove redundant sb checksum recomputation") removed checksum recalculation after updating superblock free space / inode counters in ext4_fill_super() based on the fact that we will recalculate the checksum on superblock writeout. That is correct assumption but until the writeout happens (which can take a long time) the checksum is incorrect in the buffer cache and if tune2fs is called in that time window it will complain. So return back the checksum recalculation and add a comment explaining the tune2fs peculiarity.

[...]

Applied, thanks!

[1/1] ext4: Fix tune2fs checksum failure for mounted filesystem

      commit: e905fbe3fd0fdb90052f6efdf88f50a78833cfe7

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>