From patchwork Wed Dec 11 01:24:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 299723 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 14AC02C009A for ; Wed, 11 Dec 2013 12:24:27 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062Ab3LKBY0 (ORCPT ); Tue, 10 Dec 2013 20:24:26 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:27226 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751342Ab3LKBYY (ORCPT ); Tue, 10 Dec 2013 20:24:24 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBB1OMjd001126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Dec 2013 01:24:23 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 rBB1OMBb000548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Dec 2013 01:24:22 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1OM4B029165; Wed, 11 Dec 2013 01:24:22 GMT Received: from localhost (/10.145.179.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Dec 2013 17:24:22 -0800 Subject: [PATCH 54/74] resize2fs: adjust reserved_gdt_blocks when changing group descriptor size To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org Date: Tue, 10 Dec 2013 17:24:19 -0800 Message-ID: <20131211012419.30655.55145.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 Since we're constructing the fantasy that new_fs has always been a 64bit fs, we need to adjust reserved_gdt_blocks when we start resizing the metadata so that the size of the gdt space in the new fs reflects the fantasy throughout the resize process. Signed-off-by: Darrick J. Wong --- resize/resize2fs.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 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/resize/resize2fs.c b/resize/resize2fs.c index e95179d..f33ec01 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -241,6 +241,24 @@ errout: return retval; } +/* Keep the size of the group descriptor region constant */ +static void adjust_reserved_gdt_blocks(ext2_filsys old_fs, ext2_filsys fs) +{ + if ((fs->super->s_feature_compat & + EXT2_FEATURE_COMPAT_RESIZE_INODE) && + (old_fs->desc_blocks != fs->desc_blocks)) { + int new; + + new = ((int) fs->super->s_reserved_gdt_blocks) + + (old_fs->desc_blocks - fs->desc_blocks); + if (new < 0) + new = 0; + if (new > (int) fs->blocksize/4) + new = fs->blocksize/4; + fs->super->s_reserved_gdt_blocks = new; + } +} + /* Toggle 64bit mode */ static errcode_t resize_group_descriptors(ext2_resize_t rfs, blk64_t new_size) { @@ -300,6 +318,8 @@ static errcode_t resize_group_descriptors(ext2_resize_t rfs, blk64_t new_size) for (i = 0; i < rfs->old_fs->group_desc_count; i++) ext2fs_group_desc_csum_set(rfs->new_fs, i); + adjust_reserved_gdt_blocks(rfs->old_fs, rfs->new_fs); + return 0; } @@ -776,20 +796,11 @@ retry: * number of descriptor blocks, then adjust * s_reserved_gdt_blocks if possible to avoid needing to move * the inode table either now or in the future. + * + * Note: If we're converting to 64bit mode, we did this earlier. */ - if ((fs->super->s_feature_compat & - EXT2_FEATURE_COMPAT_RESIZE_INODE) && - (old_fs->desc_blocks != fs->desc_blocks)) { - int new; - - new = ((int) fs->super->s_reserved_gdt_blocks) + - (old_fs->desc_blocks - fs->desc_blocks); - if (new < 0) - new = 0; - if (new > (int) fs->blocksize/4) - new = fs->blocksize/4; - fs->super->s_reserved_gdt_blocks = new; - } + if (EXT2_DESC_SIZE(old_fs->super) == EXT2_DESC_SIZE(fs->super)) + adjust_reserved_gdt_blocks(old_fs, fs); /* * If we are shrinking the number of block groups, we're done