From patchwork Fri Aug 2 09:49:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 264268 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 857342C007E for ; Fri, 2 Aug 2013 19:51:23 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758539Ab3HBJvW (ORCPT ); Fri, 2 Aug 2013 05:51:22 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:58602 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758448Ab3HBJvW (ORCPT ); Fri, 2 Aug 2013 05:51:22 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz10so495999pad.16 for ; Fri, 02 Aug 2013 02:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=r/nnixl4p9CMaOOlTDFlX84m12Fm6wgmFxhM2+tyhzU=; b=RAad0ehPw6mE2kqJ8+LFbyAHi9vdRzVe4wO60e7nhg53EzOOzmV9ISoDP97xkGUCE1 hMcV3FcCp9G+Q7H4mpyNCHsOk7ce+/vogMu/zxAYYhRJPjG+NGzBIOBUtUBeYd04ckO2 G7d4c6jlAfp38vyeH/bOfjDD5YLLJtsS1j2kbURVbvhKcxYTInRMGi2w/N5gGCP1YGUr IVUyx0HYdw+W8ycd/6nIKZSYVEWhLvbUJAytRw/70ChMWquk4Ght4Uj/td/BwEkHZv6f xwA8YrgNKk2I/aguZQIabaCqQmnXG5du8Y2/yl5uXnya5/V9re154dAQz6d8zIwz4K38 W1/A== X-Received: by 10.66.192.132 with SMTP id hg4mr9522301pac.84.1375437081294; Fri, 02 Aug 2013 02:51:21 -0700 (PDT) Received: from lz-devel.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id il4sm5912193pbb.36.2013.08.02.02.51.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:51:20 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Theodore Ts'o , Zheng Liu Subject: [PATCH v1 17/22] e2fsck: check inline_data in pass1 Date: Fri, 2 Aug 2013 17:49:44 +0800 Message-Id: <1375436989-18948-18-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 In-Reply-To: <1375436989-18948-1-git-send-email-wenqing.lz@taobao.com> References: <1375436989-18948-1-git-send-email-wenqing.lz@taobao.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu Signed-off-by: Theodore Ts'o Signed-off-by: Zheng Liu --- e2fsck/pass1.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--- lib/ext2fs/dblist_dir.c | 10 +++++-- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index e6ea460..4301bb9 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -202,6 +202,16 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino, return i; } + if (inode->i_flags & EXT4_INLINE_DATA_FL) { + unsigned int inline_size; + + inline_size = ext2fs_inline_data_get_size(fs, ino); + if (inline_size == inode->i_size) + return 1; + else + return 0; + } + blocks = ext2fs_inode_data_blocks2(fs, inode); if (blocks) { if ((inode->i_size >= fs->blocksize) || @@ -303,6 +313,15 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx) goto fix; } + /* + * Don't do the following checks for inline_data because + * other checks ensure the content of inline data right. + */ + if (strncmp(EXT2_EXT_ATTR_NAME(entry), + EXT4_EXT_ATTR_SYSTEM_DATA, + strlen(EXT4_EXT_ATTR_SYSTEM_DATA)) == 0) + goto next; + /* attribute len eats this space */ remain -= EXT2_EXT_ATTR_SIZE(entry->e_name_len); @@ -330,6 +349,7 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx) goto fix; } +next: remain -= entry->e_value_size; entry = EXT2_EXT_ATTR_NEXT(entry); @@ -407,6 +427,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx, blk64_t blk; unsigned int i, rec_len, not_device = 0; int extent_fs; + int inlinedata_fs; /* * If the mode looks OK, we believe it. If the first block in @@ -434,11 +455,19 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx, * For extent mapped files, we don't do any sanity checking: * just try to get the phys block of logical block 0 and run * with it. + * + * For inline_data files, we just skip it because, in e2fsck + * pass1, we cannot get parent inode of a inode. So we have + * no way to determine the inode is a directory or not. */ extent_fs = (ctx->fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS); - if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) { + inlinedata_fs = (ctx->fs->super->s_feature_incompat & + EXT4_FEATURE_INCOMPAT_INLINE_DATA); + if (inlinedata_fs && (inode->i_flags & EXT4_INLINE_DATA_FL)) + return; + else if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) { /* extent mapped */ if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0, &blk)) @@ -1205,7 +1234,8 @@ void e2fsck_pass1(e2fsck_t ctx) ctx->fs_sockets_count++; } else mark_inode_bad(ctx, ino); - if (!(inode->i_flags & EXT4_EXTENTS_FL)) { + if (!(inode->i_flags & EXT4_EXTENTS_FL) && + !(inode->i_flags & EXT4_INLINE_DATA_FL)) { if (inode->i_block[EXT2_IND_BLOCK]) ctx->fs_ind_count++; if (inode->i_block[EXT2_DIND_BLOCK]) @@ -1214,6 +1244,7 @@ void e2fsck_pass1(e2fsck_t ctx) ctx->fs_tind_count++; } if (!(inode->i_flags & EXT4_EXTENTS_FL) && + !(inode->i_flags & EXT4_INLINE_DATA_FL) && (inode->i_block[EXT2_IND_BLOCK] || inode->i_block[EXT2_DIND_BLOCK] || inode->i_block[EXT2_TIND_BLOCK] || @@ -2129,6 +2160,28 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx, } /* + * In fact we needn't check blocks for a inode that has inline data because + * this inode doesn't have any blocks. In this function, all we need to do + * is add this inode into dblist when it is a directory. + */ +static void check_blocks_inline_data(e2fsck_t ctx, + struct problem_context *pctx, + struct process_block_struct *pb) +{ + if (!pb->is_dir) + return; + + pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, + pb->ino, 0, 0); + if (pctx->errcode) { + pctx->blk = 0; + pctx->num = 0; + fix_problem(ctx, PR_1_ADD_DBLOCK, pctx); + ctx->flags |= E2F_FLAG_ABORT; + } +} + +/* * This subroutine is called on each inode to account for all of the * blocks used by that inode. */ @@ -2142,6 +2195,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, int bad_size = 0; int dirty_inode = 0; int extent_fs; + int inlinedata_fs; __u64 size; pb.ino = ino; @@ -2165,6 +2219,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, extent_fs = (ctx->fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS); + inlinedata_fs = (ctx->fs->super->s_feature_incompat & + EXT4_FEATURE_INCOMPAT_INLINE_DATA); if (inode->i_flags & EXT2_COMPRBLK_FL) { if (fs->super->s_feature_incompat & @@ -2188,6 +2244,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, if (ext2fs_inode_has_valid_blocks2(fs, inode)) { if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) check_blocks_extents(ctx, pctx, &pb); + else if (inlinedata_fs && + (inode->i_flags & EXT4_INLINE_DATA_FL)) + check_blocks_inline_data(ctx, pctx, &pb); else { pctx->errcode = ext2fs_block_iterate3(fs, ino, pb.is_dir ? BLOCK_FLAG_HOLE : 0, @@ -2230,7 +2289,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, } } - if (!pb.num_blocks && pb.is_dir) { + if (!pb.num_blocks && pb.is_dir && + !(inode->i_flags & EXT4_INLINE_DATA_FL)) { if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks"); ctx->fs_directory_count--; @@ -2256,7 +2316,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, #endif if (pb.is_dir) { int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super); - if (inode->i_size & (fs->blocksize - 1)) + if (inode->i_flags & EXT4_INLINE_DATA_FL) + ; + else if (inode->i_size & (fs->blocksize - 1)) bad_size = 5; else if (nblock > (pb.last_block + 1)) bad_size = 1; diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c index d4d5111..6282ab4 100644 --- a/lib/ext2fs/dblist_dir.c +++ b/lib/ext2fs/dblist_dir.c @@ -72,8 +72,14 @@ static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info, ctx->dir = db_info->ino; ctx->errcode = 0; - ret = ext2fs_process_dir_block(fs, &db_info->blk, - db_info->blockcnt, 0, 0, priv_data); + if (ext2fs_inode_has_inline_data(fs, ctx->dir)) + ret = ext2fs_inline_data_iterate(fs, ctx->dir, 0, 0, + ext2fs_process_dir_inline_data, + priv_data); + else + ret = ext2fs_process_dir_block(fs, &db_info->blk, + db_info->blockcnt, + 0, 0, priv_data); if ((ret & BLOCK_ABORT) && !ctx->errcode) return DBLIST_ABORT; return 0;