From patchwork Mon Jun 11 03:48:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 164055 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E5B90B6FFE for ; Mon, 11 Jun 2012 13:48:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497Ab2FKDsZ (ORCPT ); Sun, 10 Jun 2012 23:48:25 -0400 Received: from li9-11.members.linode.com ([67.18.176.11]:48973 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753427Ab2FKDsY (ORCPT ); Sun, 10 Jun 2012 23:48:24 -0400 Received: from root (helo=tytso-glaptop.cam.corp.google.com) by imap.thunk.org with local-esmtp (Exim 4.72) (envelope-from ) id 1Sdvc6-0000oa-Eb; Mon, 11 Jun 2012 03:48:22 +0000 Received: from tytso by tytso-glaptop.cam.corp.google.com with local (Exim 4.71) (envelope-from ) id 1Sdvc6-0007yC-2K; Sun, 10 Jun 2012 23:48:22 -0400 From: Theodore Ts'o To: Ext4 Developers List Cc: Ken Sumrall , Theodore Ts'o Subject: [PATCH] e2fsck: correctly propagate error from journal to superblock Date: Sun, 10 Jun 2012 23:48:22 -0400 Message-Id: <1339386502-30606-1-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.7.10.2.552.gaa3bb87 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Signed-off-by: "Theodore Ts'o" --- 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; } /*