Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp944942pxb; Tue, 14 Sep 2021 12:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDFYCLNt1G/K1mCXC2pZI6XTmd54xnJ0c5Cqx7LC2GxHAlD4oXxAEfY+bgYBtF6dYCAiSr X-Received: by 2002:a92:2e0d:: with SMTP id v13mr13409959ile.111.1631646722208; Tue, 14 Sep 2021 12:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631646722; cv=none; d=google.com; s=arc-20160816; b=0jpzitiK+fXOgK2uk/ajj3r19lpHW3ICYCd/RQATn/ROZeSxUUK92uU6OqCPT9Nb4n Tds19NXWohVs0BpIgjq40RnyIG+o1PLVDWSrtryET+rR2W4siV/flbQKJ62q38zHgRTl XRvP619LimAjRd9Vqm8FgdRO01jwjGU25/zBrhpKkTamDYKMNccRxOQPmSZuXfPrzCP9 /XNSRWqLso0uJY/Jb1pXe2nPflrTawRDp5/3wQLyeO0h5y75sxS6ldMeWcBSUEEEgU0Y vdtQ5BxFMK1qUyOTuJhPY52c7OR+QX54Buq7W+vcRueipEG/W4HOm8PbqLc6s/o00XYU fzxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=/pJbL5P9K/wWAxjDuTY+pRRX1E/c6HEgscPYvJbcmF8=; b=qxxwHOwXxCHxXqTW1HvsXi9ARX5YA9PHRPpdFbBa2Y17cm5brQyc7p0mMs+a8Qz7Zj /VxT07CV9gFwzmt6zZK++WzUpmLPG2sq90kJYtaOF4GHRl9mUIEgwgudDNbfdsBG4TL0 dYyDjkyR3Iixer9yK909gstbv+FkXvZo4EIMWeufGVrkxBRV1Bqu/33CXT4fyC96wanX MojAEz4X42mh9mgKHTUB7lFmOJacbtxPUOn63TORGzex3lt/+QFPsdNoNwpeg+qJVJZu 1hxoWfofN4RN60cIcz+Ef7h94PxVbwWSlva+rmrxROATwY9+p8D79lwKIG5CIFOED/yw Y5FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 200si10173989iob.24.2021.09.14.12.11.43; Tue, 14 Sep 2021 12:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbhINTMu (ORCPT + 99 others); Tue, 14 Sep 2021 15:12:50 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:51816 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233055AbhINTMf (ORCPT ); Tue, 14 Sep 2021 15:12:35 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 18EJBASQ024779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 15:11:11 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 6A4EB15C3424; Tue, 14 Sep 2021 15:11:10 -0400 (EDT) From: "Theodore Ts'o" To: Ext4 Developers List Cc: "Theodore Ts'o" Subject: [PATCH 1/3] resize2fs: attempt to keep the # of inodes valid by removing the last bg Date: Tue, 14 Sep 2021 15:11:02 -0400 Message-Id: <20210914191104.2283033-1-tytso@mit.edu> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If a the 10GB file system (with the default inode ratio size of 16k) is resized to 64TB, the number of inodes will become 2**32 --- one above the maximum allowed number of inodes of 2**32-1. In adjust_fs_info(), we already try drop the last block group if there isn't sufficient space in the last block group to support the metadata for that block group. So if dropping the last block group allows the number of inodes to valid, we should try that as well. In some cases this will mean resizing a file system to 64TB will result in it be resized to a size of 64TB - 128MB, which is close enough for government work. Addresses-Google-Bug: 199105099 Signed-off-by: Theodore Ts'o --- resize/resize2fs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resize/resize2fs.c b/resize/resize2fs.c index daaa3d49..770d2d06 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -757,6 +757,15 @@ retry: */ new_inodes =(unsigned long long) fs->super->s_inodes_per_group * fs->group_desc_count; if (new_inodes > ~0U) { + new_inodes = (unsigned long long) fs->super->s_inodes_per_group * (fs->group_desc_count - 1); + if (new_inodes <= ~0U) { + unsigned long long new_blocks = + ((unsigned long long) fs->super->s_blocks_per_group * + (fs->group_desc_count - 1)) + fs->super->s_first_data_block; + + ext2fs_blocks_count_set(fs->super, new_blocks); + goto retry; + } fprintf(stderr, _("inodes (%llu) must be less than %u\n"), (unsigned long long) new_inodes, ~0U); return EXT2_ET_TOO_MANY_INODES; -- 2.31.0