public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default()
@ 2026-03-15 14:31 Yuto Ohnuki
  2026-03-15 17:03 ` Yu Kuai
  0 siblings, 1 reply; 3+ messages in thread
From: Yuto Ohnuki @ 2026-03-15 14:31 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Yu Kuai, Nilay Shroff, Ming Lei, linux-block, linux-kernel,
	Yuto Ohnuki, syzbot+71fcf20f7c1e5043d78c

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.

Reported-by: syzbot+71fcf20f7c1e5043d78c@syzkaller.appspotmail.com
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@amazon.com>
---
 block/blk-wbt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 33006edfccd4..4337cbb7380c 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -782,10 +782,10 @@ void wbt_init_enable_default(struct gendisk *disk)
 		return;
 
 	rwb = wbt_alloc();
-	if (WARN_ON_ONCE(!rwb))
+	if (!rwb)
 		return;
 
-	if (WARN_ON_ONCE(wbt_init(disk, rwb))) {
+	if (wbt_init(disk, rwb)) {
 		wbt_free(rwb);
 		return;
 	}
-- 
2.50.1




Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284

Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default()
  2026-03-15 14:31 [PATCH] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default() Yuto Ohnuki
@ 2026-03-15 17:03 ` Yu Kuai
  2026-03-16  6:53   ` Yuto Ohnuki
  0 siblings, 1 reply; 3+ messages in thread
From: Yu Kuai @ 2026-03-15 17:03 UTC (permalink / raw)
  To: Yuto Ohnuki, Jens Axboe, yukuai
  Cc: Nilay Shroff, Ming Lei, linux-block, linux-kernel,
	syzbot+71fcf20f7c1e5043d78c

Hi,

在 2026/3/15 22:31, 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.
>
> Reported-by: syzbot+71fcf20f7c1e5043d78c@syzkaller.appspotmail.com
> 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@amazon.com>
> ---
>   block/blk-wbt.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> index 33006edfccd4..4337cbb7380c 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -782,10 +782,10 @@ void wbt_init_enable_default(struct gendisk *disk)
>   		return;
>   
>   	rwb = wbt_alloc();
> -	if (WARN_ON_ONCE(!rwb))
> +	if (!rwb)
>   		return;
>   
> -	if (WARN_ON_ONCE(wbt_init(disk, rwb))) {
> +	if (wbt_init(disk, rwb)) {

Can you also add a warning message that disk failed to enable wbt?

Otherwise this patch looks good to me.

>   		wbt_free(rwb);
>   		return;
>   	}

-- 
Thansk,
Kuai

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default()
  2026-03-15 17:03 ` Yu Kuai
@ 2026-03-16  6:53   ` Yuto Ohnuki
  0 siblings, 0 replies; 3+ messages in thread
From: Yuto Ohnuki @ 2026-03-16  6:53 UTC (permalink / raw)
  To: yukuai
  Cc: axboe, linux-block, linux-kernel, ming.lei, nilay,
	syzbot+71fcf20f7c1e5043d78c, ytohnuki

On Mon, Mar 16, 2026 at 01:03:17AM +0800, Yu Kuai wrote:
> Can you also add a warning message that disk failed to enable wbt?
> 
> Otherwise this patch looks good to me.

Hi Kuai,

Thanks for the review. That makes sense, and I'll add a pr_warn()
for the wbt_init() failure path.

For wbt_alloc(), I kept it silent since its failure can be caused
by e.g. memory pressure, which doesn't require diagnostic
information.

If I'm missing your point, please let me know.

I'll send a v2. Thanks again.

Yuto



Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284

Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-16  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 14:31 [PATCH] blk-wbt: remove WARN_ON_ONCE from wbt_init_enable_default() Yuto Ohnuki
2026-03-15 17:03 ` Yu Kuai
2026-03-16  6:53   ` Yuto Ohnuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox