1 Star 0 Fork 39

Chenxi Mao/e2fsprogs

forked from src-openEuler/e2fsprogs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch 2.16 KB
一键复制 编辑 原始数据 按行查看 历史
hifilove 提交于 2023-07-22 15:02 . update package to v1.47.0
From 4fc46b7930cddffd106dd6a3c8070ae2f9bf32a8 Mon Sep 17 00:00:00 2001
From: Baokun Li <libaokun1@huawei.com>
Date: Fri, 17 Feb 2023 18:09:21 +0800
Subject: [PATCH 1/2] e2fsck: save EXT2_ERROR_FS flag during journal replay
When repairing a file system with s_errno missing from the journal
superblock but the file system superblock contains the ERROR_FS flag,
the ERROR_FS flag on the file system image is overwritten after the
journal replay, followed by a reload of the file system data from disk
and the ERROR_FS flag in memory is overwritten. Also s_errno is not set
and the ERROR_FS flag is not reset. Therefore, when checked later, no
forced check is performed, which makes it possible to have some errors
hidden in the disk image, which may make it read-only when using the
file system. So we save the ERROR_FS flag to the superblock after the
journal replay, instead of just relying on the jsb->s_errno to do this.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: zhanchengbin <zhanchengbin1@huawei.com>
---
e2fsck/journal.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 2e86723..3142a13 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -1666,6 +1666,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
errcode_t retval, recover_retval;
io_stats stats = 0;
unsigned long long kbytes_written = 0;
+ __u16 s_error_state;
printf(_("%s: recovering journal\n"), ctx->device_name);
if (ctx->options & E2F_OPT_READONLY) {
@@ -1688,6 +1689,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
ctx->fs->io->manager->get_stats(ctx->fs->io, &stats);
if (stats && stats->bytes_written)
kbytes_written = stats->bytes_written >> 10;
+ s_error_state = ctx->fs->super->s_state & EXT2_ERROR_FS;
ext2fs_mmp_stop(ctx->fs);
ext2fs_free(ctx->fs);
@@ -1704,6 +1706,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
ctx->fs->now = ctx->now;
ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
ctx->fs->super->s_kbytes_written += kbytes_written;
+ ctx->fs->super->s_state |= s_error_state;
/* Set the superblock flags */
e2fsck_clear_recover(ctx, recover_retval != 0);
--
2.41.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenxi-mao/e2fsprogs.git
git@gitee.com:chenxi-mao/e2fsprogs.git
chenxi-mao
e2fsprogs
e2fsprogs
master

搜索帮助