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
Thus, orphan file size is capped at 512 filesystem blocks in both e2fsprogs
and the kernel.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Message-ID: <
20251120135514.
3013973-1-libaokun@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
#include "ext2_fs.h"
#include "ext2fsP.h"
+#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
+
errcode_t ext2fs_truncate_orphan_file(ext2_filsys fs)
{
struct ext2_inode inode;
struct ext4_orphan_block_tail *ob_tail;
time_t now;
+ if (num_blocks > EXT4_MAX_ORPHAN_FILE_BLOCKS)
+ num_blocks = EXT4_MAX_ORPHAN_FILE_BLOCKS;
+
if (ino) {
err = ext2fs_read_inode(fs, ino, &inode);
if (err)