From e34b390a71fcb15e4efe3d40023b026aef6e37d5 Mon Sep 17 00:00:00 2001 From: Pavel Reichl Date: Fri, 4 Jul 2025 18:56:10 +0200 Subject: [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes Resolves: RHEL-101758 Signed-off-by: Pavel Reichl --- ...-we-have-at-least-EXT2_FIRST_INO-1-i.patch | 63 +++++++++++++++++++ e2fsprogs.spec | 19 +++--- 2 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 e2fsprogs-1.47.1-ext2fs-make-sure-we-have-at-least-EXT2_FIRST_INO-1-i.patch diff --git a/e2fsprogs-1.47.1-ext2fs-make-sure-we-have-at-least-EXT2_FIRST_INO-1-i.patch b/e2fsprogs-1.47.1-ext2fs-make-sure-we-have-at-least-EXT2_FIRST_INO-1-i.patch new file mode 100644 index 0000000..68f8e90 --- /dev/null +++ b/e2fsprogs-1.47.1-ext2fs-make-sure-we-have-at-least-EXT2_FIRST_INO-1-i.patch @@ -0,0 +1,63 @@ +From 196cd1224ccaf5ca76540fc0a6238695d4476ca9 Mon Sep 17 00:00:00 2001 +From: Li Dongyang +Date: Thu, 20 Jul 2023 22:50:12 +1000 +Subject: [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes + +When creating a small fs with 100 1k blocks, mke2fs fails with: + +Creating filesystem with 100 1k blocks and 8 inodes + +Allocating group tables: done +Writing inode tables: done +ext2fs_mkdir: Could not allocate inode in ext2 filesystem while creating /lost+found + +Increase s_inodes_per_group with a step of 8 to make +sure we have at least EXT2_FIRST_INO + 1 inodes. + +Change-Id: Ib885735641dfa0ed9c6f6a4a1f9afec291673126 +Signed-off-by: Li Dongyang +Reviewed-by: Andreas Dilger +Link: https://lore.kernel.org/r/20230720125012.641504-1-dongyangli@ddn.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Pavel Reichl +--- + lib/ext2fs/initialize.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c +index edd692bb..e96f3cab 100644 +--- a/lib/ext2fs/initialize.c ++++ b/lib/ext2fs/initialize.c +@@ -307,13 +307,6 @@ retry: + else + set_field(s_inodes_count, ext2fs_blocks_count(super) / i); + +- /* +- * Make sure we have at least EXT2_FIRST_INO + 1 inodes, so +- * that we have enough inodes for the filesystem(!) +- */ +- if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1) +- super->s_inodes_count = EXT2_FIRST_INODE(super)+1; +- + /* + * There should be at least as many inodes as the user + * requested. Figure out how many inodes per group that +@@ -375,6 +368,15 @@ ipg_retry: + } + super->s_inodes_count = super->s_inodes_per_group * + fs->group_desc_count; ++ /* ++ * Make sure we have at least EXT2_FIRST_INO + 1 inodes, so ++ * that we have enough inodes for the filesystem(!) ++ */ ++ if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1) { ++ ipg += 8; ++ goto ipg_retry; ++ } ++ + super->s_free_inodes_count = super->s_inodes_count; + + /* +-- +2.50.0 + diff --git a/e2fsprogs.spec b/e2fsprogs.spec index b4de8c0..d54f5f1 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,7 +1,7 @@ Summary: Utilities for managing ext2, ext3, and ext4 file systems Name: e2fsprogs Version: 1.46.5 -Release: 7%{?dist} +Release: 8%{?dist} # License tags based on COPYING file distinctions for various components License: GPLv2 @@ -47,6 +47,7 @@ Patch2: 0003-mke2fs.conf-Introduce-rhel6-rhel7-and-rhel8-fs_type.patch Patch3: e2fsprogs-libext2fs-add-sanity-check-to-extent-manipulation.patch Patch4: e2fsprogs-1.46.6-Change-the-xattr-entry-hash-to-use-an-unsighed-char-.patch Patch5: e2fsprogs-1.47.1-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch +Patch6: e2fsprogs-1.47.1-ext2fs-make-sure-we-have-at-least-EXT2_FIRST_INO-1-i.patch %description The e2fsprogs package contains a number of utilities for creating, @@ -176,12 +177,13 @@ managed device with some free space available in respective volume group. xzcat '%{SOURCE0}' | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data=- %setup -q -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 +%patch -p1 0 +%patch -p1 1 +%patch -p1 2 +%patch -p1 3 +%patch -p1 4 +%patch -p1 5 +%patch -p1 6 # Remove flawed tests rm -rf tests/m_rootdir_acl @@ -354,6 +356,9 @@ make PRINT_FAILED=yes fullcheck %{_udevdir}/96-e2scrub.rules %changelog +* Fri Jul 04 2025 Pavel Reichl +- ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes + * Fri Jan 24 2025 Pavel Reichl - 1.46.5-7 - Fix: e2fsprogs: online resize fails - Related: RHEL-76095