From: "yebin (H)" <yebin10@huawei.com>
To: Jan Kara <jack@suse.cz>, Ye Bin <yebin@huaweicloud.com>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
<linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] ext4: fix mballoc-test.c is not compiled when EXT4_KUNIT_TESTS=M
Date: Fri, 27 Feb 2026 10:44:53 +0800 [thread overview]
Message-ID: <69A10525.4000504@huawei.com> (raw)
In-Reply-To: <o65evw32fb2cg2sclvxc3dkbqlhzzdns3uducvb7mgbkp4i5l3@hsluqhpejick>
On 2026/2/26 21:42, Jan Kara wrote:
> On Thu 26-02-26 19:09:17, Ye Bin wrote:
>> From: Ye Bin <yebin10@huawei.com>
>>
>> Now, only EXT4_KUNIT_TESTS=Y testcase will be compiled in 'mballoc.c'.
>> To solve this issue, the ext4 test code needs to be decoupled. The ext4
>> test module is compiled into a separate module.
>>
>> Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Closes: https://patchwork.kernel.org/project/cifs-client/patch/20260118091313.1988168-2-chenxiaosong.chenxiaosong@linux.dev/
>> Fixes: 7c9fa399a369 ("ext4: add first unit test for ext4_mb_new_blocks_simple in mballoc")
>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>
> I think this is a good idea but:
>
>> -#ifdef CONFIG_EXT4_KUNIT_TESTS
>> -#include "mballoc-test.c"
>> +#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
>> +void mb_clear_bits_test(void *bm, int cur, int len)
>> +{
>> + mb_clear_bits(bm, cur, len);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_clear_bits_test);
>
> Please use EXPORT_SYMBOL_FOR_MODULES() for the exports to make them clearly
> ext4 internal. Thanks!
>
> Honza
>
Thank you for your suggestion.I will send a new version.
>> +
>> +ext4_fsblk_t
>> +ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,
>> + int *errp)
>> +{
>> + return ext4_mb_new_blocks_simple(ar, errp);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_mb_new_blocks_simple_test);
>> +
>> +int mb_find_next_zero_bit_test(void *addr, int max, int start)
>> +{
>> + return mb_find_next_zero_bit(addr, max, start);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_find_next_zero_bit_test);
>> +
>> +int mb_find_next_bit_test(void *addr, int max, int start)
>> +{
>> + return mb_find_next_bit(addr, max, start);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_find_next_bit_test);
>> +
>> +void mb_clear_bit_test(int bit, void *addr)
>> +{
>> + mb_clear_bit(bit, addr);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_clear_bit_test);
>> +
>> +int mb_test_bit_test(int bit, void *addr)
>> +{
>> + return mb_test_bit(bit, addr);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_test_bit_test);
>> +
>> +int ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,
>> + handle_t *handle)
>> +{
>> + return ext4_mb_mark_diskspace_used(ac, handle);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_mb_mark_diskspace_used_test);
>> +
>> +int mb_mark_used_test(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
>> +{
>> + return mb_mark_used(e4b, ex);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_mark_used_test);
>> +
>> +void ext4_mb_generate_buddy_test(struct super_block *sb, void *buddy,
>> + void *bitmap, ext4_group_t group,
>> + struct ext4_group_info *grp)
>> +{
>> + ext4_mb_generate_buddy(sb, buddy, bitmap, group, grp);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_mb_generate_buddy_test);
>> +
>> +int ext4_mb_load_buddy_test(struct super_block *sb, ext4_group_t group,
>> + struct ext4_buddy *e4b)
>> +{
>> + return ext4_mb_load_buddy(sb, group, e4b);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_mb_load_buddy_test);
>> +
>> +void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b)
>> +{
>> + ext4_mb_unload_buddy(e4b);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_mb_unload_buddy_test);
>> +
>> +void mb_free_blocks_test(struct inode *inode, struct ext4_buddy *e4b,
>> + int first, int count)
>> +{
>> + mb_free_blocks(inode, e4b, first, count);
>> +}
>> +EXPORT_SYMBOL_GPL(mb_free_blocks_test);
>> +
>> +void ext4_free_blocks_simple_test(struct inode *inode, ext4_fsblk_t block,
>> + unsigned long count)
>> +{
>> + return ext4_free_blocks_simple(inode, block, count);
>> +}
>> +EXPORT_SYMBOL_GPL(ext4_free_blocks_simple_test);
>> +
>> +EXPORT_SYMBOL_GPL(ext4_wait_block_bitmap);
>> +EXPORT_SYMBOL_GPL(ext4_mb_init);
>> +EXPORT_SYMBOL_GPL(ext4_get_group_desc);
>> +EXPORT_SYMBOL_GPL(ext4_count_free_clusters);
>> +EXPORT_SYMBOL_GPL(ext4_get_group_info);
>> +EXPORT_SYMBOL_GPL(ext4_free_group_clusters_set);
>> +EXPORT_SYMBOL_GPL(ext4_mb_release);
>> +EXPORT_SYMBOL_GPL(ext4_read_block_bitmap_nowait);
>> +EXPORT_SYMBOL_GPL(mb_set_bits);
>> +EXPORT_SYMBOL_GPL(ext4_fc_init_inode);
>> +EXPORT_SYMBOL_GPL(ext4_mb_mark_context);
>> #endif
>> diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h
>> index 15a049f05d04..b32e03e7ae8d 100644
>> --- a/fs/ext4/mballoc.h
>> +++ b/fs/ext4/mballoc.h
>> @@ -270,4 +270,34 @@ ext4_mballoc_query_range(
>> ext4_mballoc_query_range_fn formatter,
>> void *priv);
>>
>> +#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
>> +extern void mb_clear_bits_test(void *bm, int cur, int len);
>> +extern int ext4_mb_mark_context(handle_t *handle,
>> + struct super_block *sb, bool state,
>> + ext4_group_t group, ext4_grpblk_t blkoff,
>> + ext4_grpblk_t len, int flags,
>> + ext4_grpblk_t *ret_changed);
>> +extern ext4_fsblk_t
>> +ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,
>> + int *errp);
>> +extern int mb_find_next_zero_bit_test(void *addr, int max, int start);
>> +extern int mb_find_next_bit_test(void *addr, int max, int start);
>> +extern void mb_clear_bit_test(int bit, void *addr);
>> +extern int mb_test_bit_test(int bit, void *addr);
>> +extern int
>> +ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,
>> + handle_t *handle);
>> +extern int mb_mark_used_test(struct ext4_buddy *e4b,
>> + struct ext4_free_extent *ex);
>> +extern void ext4_mb_generate_buddy_test(struct super_block *sb,
>> + void *buddy, void *bitmap, ext4_group_t group,
>> + struct ext4_group_info *grp);
>> +extern int ext4_mb_load_buddy_test(struct super_block *sb,
>> + ext4_group_t group, struct ext4_buddy *e4b);
>> +extern void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b);
>> +extern void mb_free_blocks_test(struct inode *inode,
>> + struct ext4_buddy *e4b, int first, int count);
>> +extern void ext4_free_blocks_simple_test(struct inode *inode,
>> + ext4_fsblk_t block, unsigned long count);
>> +#endif
>> #endif
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2026-02-27 2:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 11:09 [PATCH] ext4: fix mballoc-test.c is not compiled when EXT4_KUNIT_TESTS=M Ye Bin
2026-02-26 13:42 ` Jan Kara
2026-02-27 2:44 ` yebin (H) [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-01-19 13:12 Ye Bin
2026-01-20 8:45 ` Ojaswin Mujoo
2026-01-21 9:04 ` yebin
2026-01-21 9:51 ` Ojaswin Mujoo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69A10525.4000504@huawei.com \
--to=yebin10@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yebin@huaweicloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox