Re: [PATCH v2] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default()
From: Yu Kuai
Date: Mon Mar 23 2026 - 00:33:32 EST
在 2026/3/16 15:03, Yuto Ohnuki 写道:
> wbt_init_enable_default() uses WARN_ON_ONCE to check for failures from
> wbt_alloc() and wbt_init(). However, both are expected failure paths:
>
> - wbt_alloc() can return NULL under memory pressure (-ENOMEM)
> - wbt_init() can fail with -EBUSY if wbt is already registered
>
> syzbot triggers this by injecting memory allocation failures during MTD
> partition creation via ioctl(BLKPG), causing a spurious warning.
>
> wbt_init_enable_default() is a best-effort initialization called from
> blk_register_queue() with a void return type. Failure simply means the
> disk operates without writeback throttling, which is harmless.
>
> Replace WARN_ON_ONCE with plain if-checks, consistent with how
> wbt_set_lat() in the same file already handles these failures. Add a
> pr_warn() for the wbt_init() failure to retain diagnostic information
> without triggering a full stack trace.
>
> Reported-by:syzbot+71fcf20f7c1e5043d78c@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes:https://syzkaller.appspot.com/bug?extid=71fcf20f7c1e5043d78c
> Fixes: 41afaeeda509 ("blk-wbt: fix possible deadlock to nest pcpu_alloc_mutex under q_usage_counter")
> Signed-off-by: Yuto Ohnuki<ytohnuki@xxxxxxxxxx>
> ---
> Changes in v2:
> - Add pr_warn() for wbt_init() failure as suggested by Yu Kuai
> - Link to v1:https://lore.kernel.org/all/20260315143137.13547-2-ytohnuki@xxxxxxxxxx/
> ---
> block/blk-wbt.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Yu Kuai <yukuai@xxxxxxxxx>
--
Thansk,
Kuai