From patchwork Tue Aug 5 01:06:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 376499 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 8025B140080 for ; Tue, 5 Aug 2014 11:06:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753373AbaHEBGI (ORCPT ); Mon, 4 Aug 2014 21:06:08 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:40293 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752843AbaHEBGH (ORCPT ); Mon, 4 Aug 2014 21:06:07 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s75165FA030560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Aug 2014 01:06:05 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s751648d016311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 5 Aug 2014 01:06:04 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s75163Yr009495; Tue, 5 Aug 2014 01:06:03 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Aug 2014 18:06:03 -0700 Subject: [PATCH 10/21] e2fsck: clear inline_data inode flag if EA missing From: "Darrick J. Wong" To: tytso@mit.edu, darrick.wong@oracle.com Cc: linux-ext4@vger.kernel.org Date: Mon, 04 Aug 2014 18:06:02 -0700 Message-ID: <20140805010602.2611.64599.stgit@birch.djwong.org> In-Reply-To: <20140805010457.2611.89813.stgit@birch.djwong.org> References: <20140805010457.2611.89813.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If i_size indicates that an inode requires a system.data extended attribute to hold overflow from i_blocks but the EA cannot be found, offer to truncate the file. Signed-off-by: Darrick J. Wong --- e2fsck/pass1.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ 3 files changed, 64 insertions(+) -- 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 172d664..74c70ca 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -959,6 +959,62 @@ void e2fsck_pass1(e2fsck_t ctx) } } + /* Test for inline data flag but no attr */ + if ((inode->i_flags & EXT4_INLINE_DATA_FL) && inlinedata_fs && + EXT2_I_SIZE(inode) > EXT4_MIN_INLINE_DATA_SIZE && + (ino >= EXT2_FIRST_INODE(fs->super))) { + size_t size = 0; + errcode_t err; + int flags; + + flags = fs->flags; + if (failed_csum) + fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; + err = ext2fs_inline_data_size(fs, ino, &size); + fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) | + (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS); + + switch (err) { + case 0: + /* Everything is awesome... */ + break; + case EXT2_ET_BAD_EA_BLOCK_NUM: + case EXT2_ET_BAD_EA_HASH: + case EXT2_ET_BAD_EA_HEADER: + case EXT2_ET_EA_BAD_NAME_LEN: + case EXT2_ET_EA_BAD_VALUE_SIZE: + case EXT2_ET_EA_KEY_NOT_FOUND: + case EXT2_ET_EA_NO_SPACE: + case EXT2_ET_MISSING_EA_FEATURE: + case EXT2_ET_INLINE_DATA_CANT_ITERATE: + case EXT2_ET_INLINE_DATA_NO_BLOCK: + case EXT2_ET_INLINE_DATA_NO_SPACE: + case EXT2_ET_NO_INLINE_DATA: + case EXT2_ET_EXT_ATTR_CSUM_INVALID: + case EXT2_ET_EA_BAD_VALUE_OFFSET: + /* no system.data attr, so truncate file */ + if (fix_problem(ctx, PR_1_INLINE_DATA_NO_ATTR, + &pctx)) { + err = ext2fs_inode_size_set(fs, inode, + sizeof(inode->i_block)); + if (err) { + pctx.errcode = err; + ctx->flags |= E2F_FLAG_ABORT; + goto endit; + } + e2fsck_write_inode(ctx, ino, inode, + "pass1"); + failed_csum = 0; + } + break; + default: + /* Some other kind of non-xattr error? */ + pctx.errcode = err; + ctx->flags |= E2F_FLAG_ABORT; + goto endit; + } + } + /* * Test for incorrect extent flag settings. * diff --git a/e2fsck/problem.c b/e2fsck/problem.c index b982a27..9081277 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1045,6 +1045,11 @@ static struct e2fsck_problem problem_table[] = { N_("@i %i logical @b %b (physical @b %c) violates cluster allocation rules.\nWill fix in pass 1B.\n"), PROMPT_NONE, 0 }, + /* Inode has INLINE_DATA_FL flag but extended attribute not found */ + { PR_1_INLINE_DATA_NO_ATTR, + N_("@i %i has INLINE_DATA_FL flag but @a not found. "), + PROMPT_TRUNCATE, 0 }, + /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index f051c11..1f0be2d 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -609,6 +609,9 @@ struct problem_context { /* Inode logical block is misaligned */ #define PR_1_MISALIGNED_CLUSTER 0x010074 +/* Inode has INLINE_DATA_FL flag but extended attribute not found */ +#define PR_1_INLINE_DATA_NO_ATTR 0x010075 + /* * Pass 1b errors */