100 Star 60 Fork 242

src-openEuler / kernel

 / 详情

mount之后super block checksum不对

已完成
任务
创建于  
2022-10-31 11:23

现象

    [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...

期望的现象

checksum正常

评论 (3)

LiBaokun 创建了任务

Hi cool-water, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @Xie XiuQi , @YangYingliang , @成坚 (CHENG Jian) , @jiaoff , @AlexGuo , @hanjun-guo , @woqidaideshi , @zhengzengkai , @Jackie Liu , @Zhang Yi , @colyli , @ThunderTown , @htforge , @Chiqijun , @冷嘲啊 , @zhujianwei001 , @kylin-mayukun , @wangxiongfeng , @Kefeng , @SuperSix173 , @WangShaoBo , @Zheng Zucheng , @lujialin , @陈结松 , @刘恺 , @whoisxxx , @wuxu_buque , @koulihong , @柳歆 , @朱科潜 , @Xu Kuohai , @Lingmingqiang , @juntian , @OSSIM , @郑振鹏 , @刘勇强 , @yuzenghui , @Qiuuuuu , @xiehaocheng , @chen wei , @CTC-Xibo.Wang , @Jason Zeng , @Yuehaibing , @guzitao , @zhanghongchen

openeuler-ci-bot 添加了
 
sig/Kernel
标签

ext4_orphan_cleanup:

2721         if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
2722                 /* don't clear list on RO mount w/ errors */
2723                 if (es->s_last_orphan && !(s_flags & SB_RDONLY)) {
2724                         ext4_msg(sb, KERN_INFO, "Errors on filesystem, "
2725                                   "clearing orphan list.\n");
2726                         es->s_last_orphan = 0;  
--> 这里会修改超级块的数据但是不会更新checksum最终可能挂载之后也不会有机会更新checksum 
这就导致内存中一直残留着的超级块checksum是错误的
2727                 }
2728                 jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
2729                 return;
2730         }

复现方式:
一、构造一个有孤儿链表并且有错的镜像

/sdat@localhost home]# mkfs.ext4 -F -E lazy_itable_init=0  -O metadata_csum /dev/sda 
mke2fs 1.46.5 (30-Dec-2021)
/dev/sda contains a ext4 file system
        last mounted on /home/test on Thu Jun  9 14:21:22 2022
Discarding device blocks: done
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 8ad7fb1e-4c44-4959-93b0-3653c75f3cdd
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

[root@localhost home]# mount  /dev/sda  test
[root@localhost home]# mkdir  test/orphan
[root@localhost home]# cd test/orphan/
[root@localhost orphan]# rmdir ../orphan/
[root@localhost orphan]#  echo 1 > /sys/fs/ext4/sda/trigger_fs_error
[  383.550331] EXT4-fs error (device sda): trigger_test_error:125: comm bash: 1
[root@localhost orphan]# sync
[root@localhost orphan]# QEMU: Terminated

构造好之后可以把这个镜像备份一份,后面复现和回归可以一直使用该镜像

二、复现问题

[root@localhost home]# mount /dev/sda test
[  209.355600] EXT4-fs (sda): warning: mounting fs with errors, running e2fsck is recommended
[root@localhost home]# tune2fs -l /dev/sda
tune2fs 1.46.5 (30-Dec-2021)
tune2fs: Superblock checksum does not match superblock while trying to open /dev/sda
Couldn't find valid filesystem superblock.

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
1
https://gitee.com/src-openeuler/kernel.git
git@gitee.com:src-openeuler/kernel.git
src-openeuler
kernel
kernel

搜索帮助

344bd9b3 5694891 D2dac590 5694891