[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6970968C.1050507@huaweicloud.com>
Date: Wed, 21 Jan 2026 17:04:12 +0800
From: yebin <yebin@...weicloud.com>
To: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Cc: tytso@....edu, adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org,
jack@...e.cz
Subject: Re: [PATCH] ext4: fix mballoc-test.c is not compiled when
EXT4_KUNIT_TESTS=M
On 2026/1/20 16:45, Ojaswin Mujoo wrote:
> On Mon, Jan 19, 2026 at 09:12:57PM +0800, Ye Bin wrote:
>> From: Ye Bin <yebin10@...wei.com>
>>
>> Now, only EXT4_KUNIT_TESTS=Y testcase will be compiled in 'mballoc.c'.
>>
>> EXT4_FS KUNIT EXT4_KUNIT_TESTS
>> Y Y Y
>> Y Y M
>> Y M M // This case will lead to link error
>> M Y M
>> M M M
>>
>> Fixes: 7c9fa399a369 ("ext4: add first unit test for ext4_mb_new_blocks_simple in mballoc")
>> Signed-off-by: Ye Bin <yebin10@...wei.com>
>> ---
>> fs/ext4/mballoc.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index e817a758801d..0fbd2dfae497 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -7191,6 +7191,10 @@ ext4_mballoc_query_range(
>> return error;
>> }
>>
>> -#ifdef CONFIG_EXT4_KUNIT_TESTS
>> +#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
>> +#if IS_BUILTIN(CONFIG_EXT4_FS) && IS_MODULE(CONFIG_KUNIT)
>> +/* This case will lead to link error. */
>> +#else
>> #include "mballoc-test.c"
>> #endif
>> +#endif
>
> Hi Ye Bin,
>
> Thanks for pointing out this issue but your solution seems to be having
> a side effect of making ext4.ko depend on kunit.ko.
>
> modinfo ext4.ko
> license: GPL
> license: GPL
> description: Fourth Extended Filesystem
> author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
> alias: fs-ext4
> alias: ext3
> alias: fs-ext3
> depends: kunit
> intree: Y
> name: ext4
> retpoline: Y
> vermagic: 6.19.0-rc4-xfstests-g326263653b81-dirty SMP preempt mod_unload
>
> That means we won't be able to insert ext4 module without having kunit.
Thank you for your reply.
In my opinion, if the CONFIG_EXT4_KUNIT_TESTS configuration is enabled
and ext4.ko uses symbols from kunit.ko, then it is normal for ext4.ko to
depend on kunit.ko.
> This is not the behavior we want. I think a more simpler fix here could
> be:
>
> #if IS_BUILTIN(CONFIG_KUNIT) && IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
> #include "mballoc-test.c"
> #endif
>
> So basically, as long as KUNIT=y and EXT4_KUNIT_TESTS=y/m we will run
> these tests, otherwise we won't. This also removes the dependency issue.
>
> What do you think?
>
> Regards,
> ojaswin
>
>> --
>> 2.34.1
>>
>
Powered by blists - more mailing lists