public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] e2fsck: Avoid changes on recovery flags when jbd2_journal_recover() failed
@ 2020-12-11  8:04 Haotian Li
  2020-12-11 22:07 ` harshad shirwadkar
  0 siblings, 1 reply; 9+ messages in thread
From: Haotian Li @ 2020-12-11  8:04 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, liuzhiqiang (I), linfeilong, tytso

jbd2_journal_revocer() may fail when some error occers
such as ENOMEM. However, jsb->s_start is still cleared
by func e2fsck_journal_release(). This may break
consistency between metadata and data in disk. Sometimes,
failure in jbd2_journal_revocer() is temporary but retry
e2fsck will skip the journal recovery when the temporary
problem is fixed.

To fix this case, we use "fatal_error" instead "goto errout"
when recover journal failed. We think if journal recovery
fails, we need send error message to user and reserve the
recovery flags to recover the journal when try e2fsck again.

Reported-by: Liangyun <liangyun2@huawei.com>
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
 e2fsck/journal.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 7d9f1b40..546beafd 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -952,8 +952,13 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
 		goto errout;

 	retval = -jbd2_journal_recover(journal);
-	if (retval)
-		goto errout;
+	if (retval && retval != EFSBADCRC && retval != EFSCORRUPTED) {
+		ctx->fs->flags &= ~EXT2_FLAG_VALID;
+		com_err(ctx->program_name, 0,
+					_("Journal recovery failed "
+					  "on %s\n"), ctx->device_name);
+		fatal_error(ctx, 0);
+	}

 	if (journal->j_failed_commit) {
 		pctx.ino = journal->j_failed_commit;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-03-05  9:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-11  8:04 [PATCH] e2fsck: Avoid changes on recovery flags when jbd2_journal_recover() failed Haotian Li
2020-12-11 22:07 ` harshad shirwadkar
2020-12-14  1:27   ` Haotian Li
2020-12-14 18:44     ` harshad shirwadkar
2020-12-14 20:27       ` Theodore Y. Ts'o
2020-12-15  7:43         ` Haotian Li
2020-12-25  1:49           ` Zhiqiang Liu
2021-01-05 23:06             ` harshad shirwadkar
2021-03-05  9:48               ` Haotian Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox