All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] resize2fs: attempt to keep the # of inodes valid by removing the last bg
@ 2021-09-14 19:11 Theodore Ts'o
  2021-09-14 19:11 ` [PATCH 2/3] resize2fs: adjust new size of the file system to allow a successful resize Theodore Ts'o
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Theodore Ts'o @ 2021-09-14 19:11 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

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 <tytso@mit.edu>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-16 18:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 19:11 [PATCH 1/3] resize2fs: attempt to keep the # of inodes valid by removing the last bg Theodore Ts'o
2021-09-14 19:11 ` [PATCH 2/3] resize2fs: adjust new size of the file system to allow a successful resize Theodore Ts'o
2021-09-16 17:59   ` Leah Rumancik
2021-09-14 19:11 ` [PATCH 3/3] resize2fs: optimize resize2fs_calculate_summary_stats() Theodore Ts'o
2021-09-14 20:09   ` Theodore Ts'o
2021-09-16 17:57 ` [PATCH 1/3] resize2fs: attempt to keep the # of inodes valid by removing the last bg Leah Rumancik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.