public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Yu Kuai <yukuai3@huawei.com>,
	tj@kernel.org
Subject: Re: [PATCH] block: don't call rq_qos_ops->done_bio if the bio isn't tracked
Date: Fri, 24 Sep 2021 16:56:48 +0100	[thread overview]
Message-ID: <YU31QB/l8HEeUalz@infradead.org> (raw)
In-Reply-To: <20210924110704.1541818-1-ming.lei@redhat.com>

On Fri, Sep 24, 2021 at 07:07:04PM +0800, Ming Lei wrote:
> rq_qos framework is only applied on request based driver, so:
> 
> 1) rq_qos_done_bio() needn't to be called for bio based driver
> 
> 2) rq_qos_done_bio() needn't to be called for bio which isn't tracked,
> such as bios ended from error handling code.
> 
> Especially in bio_endio():
> 
> 1) request queue is referred via bio->bi_bdev->bd_disk->queue, which
> may be gone since request queue refcount may not be held in above two
> cases
> 
> 2) q->rq_qos may be freed in blk_cleanup_queue() when calling into
> __rq_qos_done_bio()
> 
> Fix the potential kernel panic by not calling rq_qos_ops->done_bio if
> the bio isn't tracked. This way is safe because both ioc_rqos_done_bio()
> and blkcg_iolatency_done_bio() are nop if the bio isn't tracked.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

> @@ -1466,7 +1466,7 @@ void bio_endio(struct bio *bio)
>  	if (!bio_integrity_endio(bio))
>  		return;
>  
> -	if (bio->bi_bdev)
> +	if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED))
>  		rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio);

We should probbly also drop the request_queue argument to
rq_qos_done_bio in a separate cleanup.

  reply	other threads:[~2021-09-24 15:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 11:07 [PATCH] block: don't call rq_qos_ops->done_bio if the bio isn't tracked Ming Lei
2021-09-24 15:56 ` Christoph Hellwig [this message]
2021-09-24 16:57 ` Tejun Heo
2021-09-24 17:04 ` Jens Axboe

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=YU31QB/l8HEeUalz@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=tj@kernel.org \
    --cc=yukuai3@huawei.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