From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Ken Sumrall <ksumrall@google.com>, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] e2fsck: correctly propagate error from journal to superblock
Date: Sun, 10 Jun 2012 23:48:22 -0400 [thread overview]
Message-ID: <1339386502-30606-1-git-send-email-tytso@mit.edu> (raw)
If the file system is mounted read-only after a file system error has
been detected, the fact that an error occurred is written to the
journal. This is important because while the journal is getting
replayed, the error indication in the superblock may very well get
overwritten.
Unfortunately, the code to propagate the error indication from the
journal to superblock was broken because this was being done before
the old file system handle is thrown away and the file system is
re-opened to ensure that no stale data is in the file system handle.
As a result, the error indication in the superblock was never written
out.
To fix this, we need to move the check if the journal's error
indicator has been set after the file system has been freed and
re-open.
Reported-by: Ken Sumrall <ksumrall@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
e2fsck/journal.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 74b506b..767ea10 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -848,15 +848,7 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
if (journal->j_failed_commit) {
pctx.ino = journal->j_failed_commit;
fix_problem(ctx, PR_0_JNL_TXN_CORRUPT, &pctx);
- ctx->fs->super->s_state |= EXT2_ERROR_FS;
- ext2fs_mark_super_dirty(ctx->fs);
- }
-
-
- if (journal->j_superblock->s_errno) {
- ctx->fs->super->s_state |= EXT2_ERROR_FS;
- ext2fs_mark_super_dirty(ctx->fs);
- journal->j_superblock->s_errno = 0;
+ journal->j_superblock->s_errno = -EINVAL;
mark_buffer_dirty(journal->j_sb_buffer);
}
@@ -915,7 +907,13 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx)
/* Set the superblock flags */
e2fsck_clear_recover(ctx, recover_retval);
- return recover_retval;
+
+ /*
+ * Do one last sanity check, and propagate journal->s_errno to
+ * the EXT2_ERROR_FS flag in the fs superblock if needed.
+ */
+ retval = e2fsck_check_ext3_journal(ctx);
+ return retval ? retval : recover_retval;
}
/*
--
1.7.10.2.552.gaa3bb87
reply other threads:[~2012-06-11 3:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339386502-30606-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=ksumrall@google.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).