public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Coly Li" <colyli@fnnas.com>
To: <zhangshida2026@163.com>
Cc: <kent.overstreet@linux.dev>, <hch@infradead.org>,
	<axboe@kernel.dk>,  <linux-bcache@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,  <zhangshida@kylinos.cn>,
	<starzhangzsd@gmail.com>
Subject: Re: [PATCH] bcache: fix I/O accounting leak in detached_dev_do_request
Date: Mon, 26 Jan 2026 15:47:59 +0800	[thread overview]
Message-ID: <aXca3r2-VrdcRBo3@studio.local> (raw)
In-Reply-To: <20260126014209.909491-1-zhangshida2026@163.com>

On Mon, Jan 26, 2026 at 09:42:09AM +0800, zhangshida2026@163.com wrote:
> From: Shida Zhang <zhangshida@kylinos.cn>
> 
> When a bcache device is in a detached state, iostat can show 100%
> utilization even after I/O workload completion.
> 
> This happens because the caller, cached_dev_submit_bio(), calls
> bio_start_io_acct() to begin accounting. However, if the bio hits an
> early exit path in detached_dev_do_request()—either due to an
> unsupported discard request or a bio_alloc_clone() failure—the
> corresponding bio_end_io_acct() is never called. This leaves the
> in-flight counter permanently incremented, causing the kernel to
> report the device as 100% busy.
> 
> Add the missing bio_end_io_acct() calls to these error/early-exit
> paths to ensure proper I/O accounting.
> 
> Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>

Can you mention which patch that this one is fixing? It will help a bit
for downstream maintainers for the backport stuffs.

For this patch, you may add,

Acked-by: Coly Li <colyli@fnnas.com>

Thanks for the fixup.

Coly Li

> ---
>  drivers/md/bcache/request.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index a02aecac05c..7d855e66a10 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1107,6 +1107,7 @@ static void detached_dev_do_request(struct bcache_device *d,
>  
>  	if (bio_op(orig_bio) == REQ_OP_DISCARD &&
>  	    !bdev_max_discard_sectors(dc->bdev)) {
> +		bio_end_io_acct(orig_bio, start_time);
>  		bio_endio(orig_bio);
>  		return;
>  	}
> @@ -1114,6 +1115,7 @@ static void detached_dev_do_request(struct bcache_device *d,
>  	clone_bio = bio_alloc_clone(dc->bdev, orig_bio, GFP_NOIO,
>  				    &d->bio_detached);
>  	if (!clone_bio) {
> +		bio_end_io_acct(orig_bio, start_time);
>  		orig_bio->bi_status = BLK_STS_RESOURCE;
>  		bio_endio(orig_bio);
>  		return;
> -- 
> 2.34.1
>

      reply	other threads:[~2026-01-26  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26  1:42 [PATCH] bcache: fix I/O accounting leak in detached_dev_do_request zhangshida2026
2026-01-26  7:47 ` Coly Li [this message]

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=aXca3r2-VrdcRBo3@studio.local \
    --to=colyli@fnnas.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=starzhangzsd@gmail.com \
    --cc=zhangshida2026@163.com \
    --cc=zhangshida@kylinos.cn \
    /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