From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
John Garry <john.garry@huawei.com>,
"Blank-Burian, Markus, Dr." <blankburian@uni-muenster.de>,
Yufen Yu <yuyufen@huawei.com>
Subject: Re: [PATCH] blk-mq: fix is_flush_rq
Date: Wed, 18 Aug 2021 11:31:45 +0800 [thread overview]
Message-ID: <YRx/IWsvzq0rVd1H@T590> (raw)
In-Reply-To: <ef0681f8-5862-e340-b9e6-ebce5cfa3c2c@acm.org>
On Tue, Aug 17, 2021 at 08:02:58PM -0700, Bart Van Assche wrote:
> On 8/17/21 6:09 PM, Ming Lei wrote:
> > +bool is_flush_rq(struct request *rq)
> > +{
> > + return rq->end_io == flush_end_io;
> > +}
>
> My understanding is that calling is_flush_rq() is only safe if the
> caller guarantees that the request refcount >= 1. How about adding a
> comment that explains this?
Yeah, we can add the following words, but it isn't something urgent
since is_flush_rq() is one block layer internal helper.
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 4201728bf3a5..babf6262120e 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -262,6 +262,11 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)
spin_unlock_irqrestore(&fq->mq_flush_lock, flags);
}
+/*
+ * Caller has to grab refcount of this request, otherwise the flush request
+ * may be re-cycled, then rq->end_io is cleared and kernel panic is caused,
+ * see blk_mq_put_rq_ref().
+ */
bool is_flush_rq(struct request *rq)
{
return rq->end_io == flush_end_io;
Thanks,
Ming
next prev parent reply other threads:[~2021-08-18 3:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 1:09 [PATCH] blk-mq: fix is_flush_rq Ming Lei
2021-08-18 2:18 ` Jens Axboe
2021-08-18 3:02 ` Bart Van Assche
2021-08-18 3:31 ` Ming Lei [this message]
2021-08-23 12:42 ` Joseph Qi
2021-08-23 12:50 ` Ming Lei
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=YRx/IWsvzq0rVd1H@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=blankburian@uni-muenster.de \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=yuyufen@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