[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <03821d96-78a3-4a49-bf72-7e8bf65a7877@huawei.com>
Date: Thu, 13 Nov 2025 11:02:14 +0800
From: Baokun Li <libaokun1@...wei.com>
To: Jan Kara <jack@...e.cz>, "Darrick J. Wong" <djwong@...nel.org>
CC: <libaokun@...weicloud.com>, <linux-ext4@...r.kernel.org>, <tytso@....edu>,
<adilger.kernel@...ger.ca>, <yangerkun@...wei.com>, Baokun Li
<libaokun1@...wei.com>
Subject: Re: [PATCH e2fsprogs] libext2fs: fix orphan file size > kernel limit
with large blocksize
On 2025-11-13 03:55, Jan Kara wrote:
> On Wed 12-11-25 10:36:09, Darrick J. Wong wrote:
>> On Wed, Nov 12, 2025 at 08:21:57PM +0800, libaokun@...weicloud.com wrote:
>>> From: Baokun Li <libaokun1@...wei.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
>>>
>>> Therefore, synchronize the kernel change to e2fsprogs to avoid creating
>>> orphan files larger than the kernel limit.
>>>
>>> Signed-off-by: Baokun Li <libaokun1@...wei.com>
> ...
>>> /*
>>> * Find reasonable size for orphan file. We choose orphan file size to be
>>> - * between 32 and 512 filesystem blocks and not more than 1/4096 of the
>>> - * filesystem unless it is really small.
>>> + * between 32 filesystem blocks and EXT4_DEFAULT_ORPHAN_FILE_SIZE, and not
>>> + * more than 1/fs->blocksize of the filesystem unless it is really small.
>>> */
>>> e2_blkcnt_t ext2fs_default_orphan_file_blocks(ext2_filsys fs)
>>> {
>>> __u64 num_blocks = ext2fs_blocks_count(fs->super);
>>> - e2_blkcnt_t blks = 512;
>>> + e2_blkcnt_t blks = EXT4_DEFAULT_ORPHAN_FILE_SIZE / fs->blocksize;
>>>
>>> if (num_blocks < 128 * 1024)
>>> blks = 32;
>>> - else if (num_blocks < 2 * 1024 * 1024)
>>> - blks = num_blocks / 4096;
>>> + else if (num_blocks < EXT4_DEFAULT_ORPHAN_FILE_SIZE)
>>> + blks = num_blocks / fs->blocksize;
>> If the number of blocks in the filesystem is less than the default
>> orphan file size in bytes? I don't understand that logic, particularly
>> because EXT4_DEFAULT_ORPHAN_FILE_SIZE == 2<<20 == 2097152 == 2 * 1024 *
>> 1024.
> Yeah, these were just more or less ad hoc constants picked by me to make
> sure orphan file doesn't consume too much space and they are unrelated to
> the constant I've picked in the kernel limiting orphan file size. And I
> agree making sure blks isn't larger than EXT4_DEFAULT_ORPHAN_FILE_SIZE
> makes sense but otherwise I don't think we need to change anything here.
>
> Honza
>
Okay, in the next version I will revert the changes in
ext2fs_default_orphan_file_blocks(), keep only the check
in ext2fs_create_orphan_file(), and add some comments.
Cheers,
Baokun
Powered by blists - more mailing lists