From: yebin <yebin10@huawei.com>
To: Ritesh Harjani <ritesh.list@gmail.com>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
<linux-ext4@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<jack@suse.cz>
Subject: Re: [PATCH -next] ext4: fix super block checksum incorrect after mount
Date: Wed, 25 May 2022 19:33:59 +0800 [thread overview]
Message-ID: <628E1427.8080205@huawei.com> (raw)
In-Reply-To: <20220525075123.rx5v7fe6ocn354wn@riteshh-domain>
On 2022/5/25 15:51, Ritesh Harjani wrote:
> On 22/05/25 09:29AM, Ye Bin wrote:
>> We got issue as follows:
>> [home]# mount /dev/sda test
>> EXT4-fs (sda): warning: mounting fs with errors, running e2fsck is recommended
>> [home]# dmesg
>> EXT4-fs (sda): warning: mounting fs with errors, running e2fsck is recommended
>> EXT4-fs (sda): Errors on filesystem, clearing orphan list.
>> EXT4-fs (sda): recovery complete
>> EXT4-fs (sda): mounted filesystem with ordered data mode. Quota mode: none.
>> [home]# debugfs /dev/sda
>> debugfs 1.46.5 (30-Dec-2021)
>> Checksum errors in superblock! Retrying...
>>
>> Reason is ext4_orphan_cleanup will reset ‘s_last_orphan’ but not update
>> super block checksum.
>> To solve above issue, defer update super block checksum after ext4_orphan_cleanup.
> I agree with the analysis. However after [1], I think all updates to superblock
> (including checksum computation) should be done within buffer lock.
> (lock_buffer(), unlock_buffer()).
>
> [1]: https://lore.kernel.org/all/20201216101844.22917-4-jack@suse.cz/
>
> With lock changes added, feel free to add -
>
> Reviewed-by: Ritesh Harjani <ritesh.list@gmail.com>
Thanks for your reply.
I think there should be no concurrent modification at this time.
So there's no need to hold buffer lock.
Am I missing something?
>
>>
>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>> ---
>> fs/ext4/super.c | 16 ++++++++--------
>> 1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index f9a3ad683b4a..c47204029429 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -5300,14 +5300,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>> 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);
>> @@ -5365,6 +5357,14 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>> EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
>> ext4_orphan_cleanup(sb, es);
>> EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
>> + /*
>> + * Update the checksum after updating free space/inode counters and
>> + * ext4_orphan_cleanup. 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 (needs_recovery) {
>> ext4_msg(sb, KERN_INFO, "recovery complete");
>> err = ext4_mark_recovery_complete(sb, es);
>> --
>> 2.31.1
>>
> .
>
next prev parent reply other threads:[~2022-05-25 11:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 1:29 [PATCH -next] ext4: fix super block checksum incorrect after mount Ye Bin
2022-05-25 7:51 ` Ritesh Harjani
2022-05-25 11:33 ` yebin [this message]
2022-05-25 11:54 ` Jan Kara
2022-05-25 15:16 ` Ritesh Harjani
2022-05-25 15:57 ` Jan Kara
2022-05-27 9:16 ` yebin
2022-05-27 10:18 ` Jan Kara
2022-06-18 2:12 ` 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=628E1427.8080205@huawei.com \
--to=yebin10@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox