提交 66c23043 编写于 作者: Y Ye Bin 提交者: Yongqiang Liu

ext4: fix super block checksum incorrect after mount

hulk inclusion
category: bugfix
bugzilla: 186927, https://gitee.com/openeuler/kernel/issues/I5BMSA
CVE: NA

---------------------------

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.
Signed-off-by: NYe Bin <yebin10@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 8551c354
...@@ -4731,14 +4731,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4731,14 +4731,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
err = percpu_counter_init(&sbi->s_freeinodes_counter, freei, err = percpu_counter_init(&sbi->s_freeinodes_counter, freei,
GFP_KERNEL); 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) if (!err)
err = percpu_counter_init(&sbi->s_dirs_counter, err = percpu_counter_init(&sbi->s_dirs_counter,
ext4_count_dirs(sb), GFP_KERNEL); ext4_count_dirs(sb), GFP_KERNEL);
...@@ -4790,6 +4782,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4790,6 +4782,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
ext4_orphan_cleanup(sb, es); ext4_orphan_cleanup(sb, es);
EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; 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) { if (needs_recovery) {
ext4_msg(sb, KERN_INFO, "recovery complete"); ext4_msg(sb, KERN_INFO, "recovery complete");
err = ext4_mark_recovery_complete(sb, es); err = ext4_mark_recovery_complete(sb, es);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册