* [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes
@ 2023-07-20 12:50 Li Dongyang
2023-07-20 22:30 ` Andreas Dilger
2024-02-08 15:54 ` Theodore Ts'o
0 siblings, 2 replies; 3+ messages in thread
From: Li Dongyang @ 2023-07-20 12:50 UTC (permalink / raw)
To: linux-ext4; +Cc: adilger
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 <dongyangli@ddn.com>
---
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 edd692bb9..e96f3cabd 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.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes
2023-07-20 12:50 [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes Li Dongyang
@ 2023-07-20 22:30 ` Andreas Dilger
2024-02-08 15:54 ` Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Dilger @ 2023-07-20 22:30 UTC (permalink / raw)
To: Li Dongyang; +Cc: Ext4 Developers List
[-- Attachment #1: Type: text/plain, Size: 660 bytes --]
On Jul 20, 2023, at 6:50 AM, Li Dongyang <dongyangli@ddn.com> wrote:
>
> 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 <dongyangli@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes
2023-07-20 12:50 [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes Li Dongyang
2023-07-20 22:30 ` Andreas Dilger
@ 2024-02-08 15:54 ` Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2024-02-08 15:54 UTC (permalink / raw)
To: linux-ext4, Li Dongyang; +Cc: Theodore Ts'o, adilger
On Thu, 20 Jul 2023 22:50:12 +1000, Li Dongyang wrote:
> 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
>
> [...]
Applied, thanks!
[1/1] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes
commit: 196cd1224ccaf5ca76540fc0a6238695d4476ca9
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-08 15:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-20 12:50 [PATCH] ext2fs: make sure we have at least EXT2_FIRST_INO + 1 inodes Li Dongyang
2023-07-20 22:30 ` Andreas Dilger
2024-02-08 15:54 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox