All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: Boyang Xue <bxue@redhat.com>, <linux-ext4@vger.kernel.org>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH] ext4: Fix tune2fs checksum failure for mounted filesystem
Date: Thu, 12 Aug 2021 14:47:37 +0200	[thread overview]
Message-ID: <20210812124737.21981-1-jack@suse.cz> (raw)

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")
Reported-by: Boyang Xue <bxue@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index dfa09a277b56..8f2474618f7e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -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);
-- 
2.26.2


             reply	other threads:[~2021-08-12 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 12:47 Jan Kara [this message]
2021-08-14 14:24 ` [PATCH] ext4: Fix tune2fs checksum failure for mounted filesystem Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210812124737.21981-1-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=bxue@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.