From patchwork Fri Oct 18 04:50: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: 284421 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 41EC82C00CB for ; Fri, 18 Oct 2013 15:50:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751217Ab3JREuc (ORCPT ); Fri, 18 Oct 2013 00:50:32 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:30681 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750963Ab3JREuc (ORCPT ); Fri, 18 Oct 2013 00:50:32 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r9I4oUca006393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Oct 2013 04:50:31 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9I4oU8k029987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Oct 2013 04:50:30 GMT Received: from abhmt102.oracle.com (abhmt102.oracle.com [141.146.116.54]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9I4oUsI006140; Fri, 18 Oct 2013 04:50:30 GMT Received: from localhost (/67.160.151.179) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Oct 2013 21:50:29 -0700 Subject: [PATCH 14/25] e2fsck: only release clusters when shortening a directory during a rehash To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org Date: Thu, 17 Oct 2013 21:50:27 -0700 Message-ID: <20131018045027.7339.9686.stgit@birch.djwong.org> In-Reply-To: <20131018044854.7339.48457.stgit@birch.djwong.org> References: <20131018044854.7339.48457.stgit@birch.djwong.org> User-Agent: StGit/0.15 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 When the rehash process is running on a bigalloc filesystem, it compresses all the directory entries and hash structures into the beginning of the directory file and then uses block_iterate3() to free the blocks off the end of the file. It seems to call ext2fs_block_alloc_stats2() for every block in a cluster, which is unfortunate because this function allocates and frees entire clusters (and updates the summary counts accordingly). In this case e2fsck writes out incorrect summary counts. Signed-off-by: Darrick J. Wong Reviewed-by: Zheng Liu --- e2fsck/rehash.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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/rehash.c b/e2fsck/rehash.c index 6ef3568..29da9a1 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -719,10 +719,18 @@ static int write_dir_block(ext2_filsys fs, /* We don't need this block, so release it */ e2fsck_read_bitmaps(wd->ctx); blk = *block_nr; - ext2fs_unmark_block_bitmap2(wd->ctx->block_found_map, blk); - ext2fs_block_alloc_stats2(fs, blk, -1); + /* + * In theory, we only release blocks from the end of the + * directory file, so it's fine to clobber a whole cluster at + * once. + */ + if (blk % EXT2FS_CLUSTER_RATIO(fs) == 0) { + ext2fs_unmark_block_bitmap2(wd->ctx->block_found_map, + blk); + ext2fs_block_alloc_stats2(fs, blk, -1); + wd->cleared++; + } *block_nr = 0; - wd->cleared++; return BLOCK_CHANGED; }