From patchwork Wed Dec 11 01:23:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 299715 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 335202C030E for ; Wed, 11 Dec 2013 12:23:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751600Ab3LKBXf (ORCPT ); Tue, 10 Dec 2013 20:23:35 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:43368 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802Ab3LKBXf (ORCPT ); Tue, 10 Dec 2013 20:23:35 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBB1NUWv010182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Dec 2013 01:23:31 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1NTA6027976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Dec 2013 01:23:30 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1NTUV025436; Wed, 11 Dec 2013 01:23:29 GMT Received: from localhost (/10.145.179.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Dec 2013 17:23:29 -0800 Subject: [PATCH 46/74] e2fsck: try implied cluster allocation when expanding a dir To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org, Zheng Liu Date: Tue, 10 Dec 2013 17:23:27 -0800 Message-ID: <20131211012327.30655.58116.stgit@birch.djwong.org> In-Reply-To: <20131211011813.30655.39624.stgit@birch.djwong.org> References: <20131211011813.30655.39624.stgit@birch.djwong.org> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When we're expanding a directory, check to see if we're doing an implied cluster allocation; if so, we don't need to allocate a new block, and we certainly don't need to update the summary counts. Reported-by: Zheng Liu Signed-off-by: Darrick J. Wong --- e2fsck/pass3.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 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/pass3.c b/e2fsck/pass3.c index dc9d7c1..c57aab8 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -718,12 +718,23 @@ static int expand_dir_proc(ext2_filsys fs, last_blk = *blocknr; return 0; } - retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map, - &new_blk); - if (retval) { - es->err = retval; - return BLOCK_ABORT; + + if (blockcnt && + (EXT2FS_B2C(fs, last_blk) == EXT2FS_B2C(fs, last_blk + 1))) + new_blk = last_blk + 1; + else { + last_blk &= ~EXT2FS_CLUSTER_MASK(fs); + retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map, + &new_blk); + if (retval) { + es->err = retval; + return BLOCK_ABORT; + } + es->newblocks++; + ext2fs_block_alloc_stats2(fs, new_blk, +1); } + last_blk = new_blk; + if (blockcnt > 0) { retval = ext2fs_new_dir_block(fs, 0, 0, &block); if (retval) { @@ -749,8 +760,6 @@ static int expand_dir_proc(ext2_filsys fs, ext2fs_free_mem(&block); *blocknr = new_blk; ext2fs_mark_block_bitmap2(ctx->block_found_map, new_blk); - ext2fs_block_alloc_stats2(fs, new_blk, +1); - es->newblocks++; if (es->num == 0) return (BLOCK_CHANGED | BLOCK_ABORT);