Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH 2/2] block: only return started requests from blk_mq_tag_to_rq()
@ 2020-06-19 14:01 Hannes Reinecke
  2020-06-19 14:09 ` Hannes Reinecke
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Reinecke @ 2020-06-19 14:01 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Martin K. Petersen, Keith Busch, Sagi Grimberg,
	James Bottomley, linux-block, linux-scsi, Hannes Reinecke

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-22 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-06-22 14:13     ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox