fs/ext4/orphan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
From: Baokun Li <libaokun1@huawei.com>
Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
limits the maximum supported orphan file size to 8 << 20.
However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
blocks when creating a filesystem.
With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
than the kernel allows, so mount prints an error and fails:
EXT4-fs (vdb): orphan file too big: 8650752
EXT4-fs (vdb): mount failed
To prevent this issue and allow previously created 64KB filesystems to
mount, we updates the maximum allowed orphan file size in the kernel to
512 filesystem blocks.
Fixes: 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
fs/ext4/orphan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index 82d5e7501455..fb57bba0d19d 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -8,6 +8,8 @@
#include "ext4.h"
#include "ext4_jbd2.h"
+#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
+
static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
{
int i, j, start;
@@ -588,7 +590,7 @@ int ext4_init_orphan_info(struct super_block *sb)
* consuming absurd amounts of memory when pinning blocks of orphan
* file in memory.
*/
- if (inode->i_size > 8 << 20) {
+ if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {
ext4_msg(sb, KERN_ERR, "orphan file too big: %llu",
(unsigned long long)inode->i_size);
ret = -EFSCORRUPTED;
--
2.46.1
On Thu, 20 Nov 2025 21:42:33 +0800, libaokun@huaweicloud.com wrote:
> Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
> limits the maximum supported orphan file size to 8 << 20.
>
> However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
> blocks when creating a filesystem.
>
> With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
> than the kernel allows, so mount prints an error and fails:
>
> [...]
Applied, thanks!
[1/1] ext4: align max orphan file size with e2fsprogs limit
commit: 7c11c56eb32eae96893eebafdbe3decadefe88ad
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
On 11/20/2025 9:42 PM, libaokun@huaweicloud.com wrote:
> From: Baokun Li <libaokun1@huawei.com>
>
> Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
> limits the maximum supported orphan file size to 8 << 20.
>
> However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
> blocks when creating a filesystem.
>
> With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
> than the kernel allows, so mount prints an error and fails:
>
> EXT4-fs (vdb): orphan file too big: 8650752
> EXT4-fs (vdb): mount failed
>
> To prevent this issue and allow previously created 64KB filesystems to
> mount, we updates the maximum allowed orphan file size in the kernel to
> 512 filesystem blocks.
>
> Fixes: 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
Looks good to me.
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> fs/ext4/orphan.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
> index 82d5e7501455..fb57bba0d19d 100644
> --- a/fs/ext4/orphan.c
> +++ b/fs/ext4/orphan.c
> @@ -8,6 +8,8 @@
> #include "ext4.h"
> #include "ext4_jbd2.h"
>
> +#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
> +
> static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
> {
> int i, j, start;
> @@ -588,7 +590,7 @@ int ext4_init_orphan_info(struct super_block *sb)
> * consuming absurd amounts of memory when pinning blocks of orphan
> * file in memory.
> */
> - if (inode->i_size > 8 << 20) {
> + if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {
> ext4_msg(sb, KERN_ERR, "orphan file too big: %llu",
> (unsigned long long)inode->i_size);
> ret = -EFSCORRUPTED;
On Thu 20-11-25 21:42:33, libaokun@huaweicloud.com wrote:
> From: Baokun Li <libaokun1@huawei.com>
>
> Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
> limits the maximum supported orphan file size to 8 << 20.
>
> However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
> blocks when creating a filesystem.
>
> With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
> than the kernel allows, so mount prints an error and fails:
>
> EXT4-fs (vdb): orphan file too big: 8650752
> EXT4-fs (vdb): mount failed
>
> To prevent this issue and allow previously created 64KB filesystems to
> mount, we updates the maximum allowed orphan file size in the kernel to
> 512 filesystem blocks.
>
> Fixes: 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
OK, makes sense. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/orphan.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
> index 82d5e7501455..fb57bba0d19d 100644
> --- a/fs/ext4/orphan.c
> +++ b/fs/ext4/orphan.c
> @@ -8,6 +8,8 @@
> #include "ext4.h"
> #include "ext4_jbd2.h"
>
> +#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
> +
> static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
> {
> int i, j, start;
> @@ -588,7 +590,7 @@ int ext4_init_orphan_info(struct super_block *sb)
> * consuming absurd amounts of memory when pinning blocks of orphan
> * file in memory.
> */
> - if (inode->i_size > 8 << 20) {
> + if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {
> ext4_msg(sb, KERN_ERR, "orphan file too big: %llu",
> (unsigned long long)inode->i_size);
> ret = -EFSCORRUPTED;
> --
> 2.46.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
© 2016 - 2025 Red Hat, Inc.