1From dc4c71c6192f9709a2d833f9aa63d3463da6155a Mon Sep 17 00:00:00 2001 2From: lihaotian <lihaotian9@huawei.com> 3Date: Tue, 15 Dec 2020 11:46:07 +0000 4Subject: [PATCH] e2fsck: exit journal recovery when find EIO, ENOMEM 5 errors 6 7jbd2_journal_revocer() may fail when some error occers 8such as ENOMEM. However, jsb->s_start is still cleared 9by func e2fsck_journal_release(). This may break 10consistency between metadata and data in disk. Sometimes, 11failure in jbd2_journal_revocer() is temporary but retry 12e2fsck will skip the journal recovery when the temporary 13problem is fixed. 14 15To fix this case, we use "fatal_error" instead "goto errout" 16when recover journal failed. If journal recovery fails, we 17will send error message to user and reserve the recovery 18flags to recover the journal when try e2fsck again. 19 20Fix issue: https://gitee.com/src-openeuler/e2fsprogs/issues/I4RZUT?from=project-issue 21 22conflict: journal_recover -> jbd2_journal_recover 23 24Reported-by: Liangyun <liangyun2@huawei.com> 25Signed-off-by: Haotian Li <lihaotian9@huawei.com> 26Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> 27--- 28 e2fsck/journal.c | 7 +++++++ 29 1 file changed, 7 insertions(+) 30 31diff --git a/e2fsck/journal.c b/e2fsck/journal.c 32index e83f3a9..a5f7088 100644 33--- a/e2fsck/journal.c 34+++ b/e2fsck/journal.c 35@@ -942,6 +942,13 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx) 36 goto errout; 37 38 retval = -jbd2_journal_recover(journal); 39+ if (retval == EIO || retval == ENOMEM || retval == EXT2_ET_NO_MEMORY) { 40+ ctx->fs->flags &= ~EXT2_FLAG_VALID; 41+ com_err(ctx->program_name, 0, 42+ _("Journal recovery failed " 43+ "on %s, retval=%d \n"), ctx->device_name, retval); 44+ fatal_error(ctx, 0); 45+ } 46 if (retval) 47 goto errout; 48 49-- 502.21.1 (Apple Git-122.3) 51 52