From patchwork Wed Mar 7 00:00:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 145092 X-Patchwork-Delegate: tytso@mit.edu 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 CAF63B6F9D for ; Wed, 7 Mar 2012 11:01:37 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031282Ab2CGABf (ORCPT ); Tue, 6 Mar 2012 19:01:35 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:57558 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031593Ab2CGABf (ORCPT ); Tue, 6 Mar 2012 19:01:35 -0500 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Mar 2012 17:01:34 -0700 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Mar 2012 17:00:46 -0700 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 2A95CC90050 for ; Tue, 6 Mar 2012 19:00:45 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q2700jEh299818 for ; Tue, 6 Mar 2012 19:00:45 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q2700eFv021201 for ; Tue, 6 Mar 2012 21:00:45 -0300 Received: from elm3b70.beaverton.ibm.com (elm3b70.beaverton.ibm.com [9.47.67.70]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q2700ZPJ020657; Tue, 6 Mar 2012 21:00:35 -0300 Subject: [PATCH 29/54] e2fsck: Check extended attribute block checksums To: Andreas Dilger , Theodore Tso , "Darrick J. Wong" From: "Darrick J. Wong" Cc: Sunil Mushran , Amir Goldstein , Andi Kleen , Mingming Cao , Joel Becker , linux-ext4@vger.kernel.org, Coly Li Date: Tue, 06 Mar 2012 16:00:32 -0800 Message-ID: <20120307000032.11945.89164.stgit@elm3b70.beaverton.ibm.com> In-Reply-To: <20120306235720.11945.30629.stgit@elm3b70.beaverton.ibm.com> References: <20120306235720.11945.30629.stgit@elm3b70.beaverton.ibm.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12030700-1780-0000-0000-000003C2F2E3 X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000255; HX=3.00000184; KW=3.00000007; PH=3.00000001; SC=3.00000001; SDB=6.00119783; UDB=6.00028999; UTC=2012-03-07 00:01:26 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Verify the checksums of separate extended attribute blocks and offer to clear it if there is a mismatch. Signed-off-by: Darrick J. Wong --- e2fsck/pass1.c | 18 ++++++++++++++++++ e2fsck/problem.c | 15 +++++++++++++++ e2fsck/problem.h | 6 ++++++ 3 files changed, 39 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index ce03e46..debc365 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1553,6 +1553,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, struct ext2_ext_attr_entry *entry; int count; region_t region = 0; + int failed_csum = 0; blk = ext2fs_file_acl_block(fs, inode); if (blk == 0) @@ -1627,6 +1628,11 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, */ pctx->blk = blk; pctx->errcode = ext2fs_read_ext_attr3(fs, blk, block_buf, pctx->ino); + if (pctx->errcode == EXT2_ET_EXT_ATTR_CSUM_INVALID) { + if (fix_problem(ctx, PR_1_EA_BLOCK_CSUM_INVALID, pctx)) + goto clear_extattr; + failed_csum = 1; + } if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx)) goto clear_extattr; header = (struct ext2_ext_attr_header *) block_buf; @@ -1708,6 +1714,18 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, } region_free(region); + /* + * We only get here if there was no other errors that were fixed. + * If there was a checksum fail, ask to correct it. + */ + if (failed_csum && + fix_problem(ctx, PR_1_EA_BLOCK_ONLY_CSUM_INVALID, pctx)) { + pctx->errcode = ext2fs_write_ext_attr3(fs, blk, block_buf, + pctx->ino); + if (pctx->errcode) + return 0; + } + count = header->h_refcount - 1; if (count) ea_refcount_store(ctx->refcount, blk, count); diff --git a/e2fsck/problem.c b/e2fsck/problem.c index d910629..ad6887e 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -961,6 +961,21 @@ static struct e2fsck_problem problem_table[] = { "extent\n\t(logical @b %c, @n physical @b %b, len %N)\n"), PROMPT_FIX, 0 }, + /* Extended attribute block checksum for inode does not match. */ + { PR_1_EA_BLOCK_CSUM_INVALID, + N_("Extended attribute @a @b %b checksum for @i %i does not " + "match. "), + PROMPT_CLEAR, 0 }, + + /* + * Extended attribute block passes checks, but checksum for inode does + * not match. + */ + { PR_1_EA_BLOCK_CSUM_INVALID, + N_("Extended attribute @a @b %b passes checks, but checksum for " + "@i %i does not match. "), + PROMPT_FIX, 0 }, + /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index eb70d61..b8a7548 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -562,6 +562,12 @@ struct problem_context { /* extent block passes checks, but checksum does not match extent block */ #define PR_1_EXTENT_ONLY_CSUM_INVALID 0x010069 +/* ea block checksum invalid */ +#define PR_1_EA_BLOCK_CSUM_INVALID 0x01006A + +/* ea block passes checks, but checksum invalid */ +#define PR_1_EA_BLOCK_ONLY_CSUM_INVALID 0x01006B + /* * Pass 1b errors */