From: Hannes Reinecke <hare@suse.de>
To: 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,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH 2/2] block: only return started requests from blk_mq_tag_to_rq()
Date: Fri, 19 Jun 2020 16:01:59 +0200 [thread overview]
Message-ID: <20200619140159.141905-1-hare@suse.de> (raw)
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;
--
2.16.4
next reply other threads:[~2020-06-19 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 14:01 Hannes Reinecke [this message]
2020-06-19 14:09 ` [PATCH 2/2] block: only return started requests from blk_mq_tag_to_rq() Hannes Reinecke
2020-06-19 18:38 ` Jens Axboe
2020-06-19 23:49 ` Ming Lei
2020-06-19 21:59 ` Bart Van Assche
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=20200619140159.141905-1-hare@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--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