From: Bart Van Assche <bvanassche@acm.org>
To: Hannes Reinecke <hare@suse.de>, Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Keith Busch <keith.busch@wdc.com>,
Sagi Grimberg <sagi@grimberg.me>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 2/2] block: only return started requests from blk_mq_tag_to_rq()
Date: Fri, 19 Jun 2020 14:59:29 -0700 [thread overview]
Message-ID: <3d073c18-50da-a4c8-2f1e-332a1e717efc@acm.org> (raw)
In-Reply-To: <60e34dce-aea4-311f-22da-4cb130c5ba88@suse.de>
On 2020-06-19 07:09, Hannes Reinecke wrote:
> On 6/19/20 4:01 PM, Hannes Reinecke wrote:
>> blk_mq_tag_to_rq() is used from within the driver to map a tag
>> to a request. As such it should only return requests which are
>> already started (ie passed to the driver); otherwise the driver
>> might trip over requests which it has never seen and random
>> crashes will occur.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>> block/blk-mq.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index 4f57d27bfa73..f02d18113f9e 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -815,9 +815,13 @@ EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
>> struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags,
>> unsigned int tag)
>> {
>> + struct request *rq;
>> +
>> if (tag < tags->nr_tags) {
>> prefetch(tags->rqs[tag]);
>> - return tags->rqs[tag];
>> + rq = tags->rqs[tag];
>> + if (blk_mq_request_started(rq))
>> + return rq;
>> }
>> return NULL;
>>
> This becomes particularly obnoxious for SCSI drivers using
> scsi_host_find_tag() for cleaning up stale commands (ie drivers like
> qla4xxx, fnic, and snic).
> All other drivers use it from the completion routine, so one can expect
> a valid (and started) tag here. So for those it shouldn't matter.
>
> But still, if there are objections I could look at fixing it within the
> SCSI stack; although that would most likely mean I'll have to implement
> the above patch as an additional function.
Hi Hannes,
Will the above patch make the fast path of every block driver slightly
slower?
Shouldn't SCSI drivers (and other block drivers) use
blk_mq_tagset_busy_iter() to clean up stale commands instead of
iterating over all tags and calling blk_mq_tag_to_rq() directly?
Thanks,
Bart.
next prev parent reply other threads:[~2020-06-19 21:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 14:01 [PATCH 2/2] block: only return started requests from blk_mq_tag_to_rq() Hannes Reinecke
2020-06-19 14:09 ` Hannes Reinecke
2020-06-19 18:38 ` Jens Axboe
2020-06-19 23:49 ` Ming Lei
2020-06-19 21:59 ` Bart Van Assche [this message]
2020-06-22 14:13 ` Hannes Reinecke
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=3d073c18-50da-a4c8-2f1e-332a1e717efc@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=keith.busch@wdc.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sagi@grimberg.me \
/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