Blob Blame History Raw
From: Jens Axboe <axboe@kernel.dk>
Date: Thu, 4 Nov 2021 11:54:47 -0600
Subject: [PATCH] block: ensure cached plug request matches the current queue
Git-commit: 10c47870155b5d9a8597eff3345d244e2fe1847f
Patch-mainline: v5.16-rc1
References: jsc#PED-1183

If we're driving multiple devices, we could have pre-populated the cache
for a different device. Ensure that the empty request matches the current
queue.

Fixes: 47c122e35d7e ("block: pre-allocate requests if plug is started and is a batch")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Acked-by: Hannes Reinecke <hare@suse.com>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5fe40c85a308..bbe1fb2dd58d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2540,7 +2540,7 @@ static inline struct request *blk_mq_get_request(struct request_queue *q,
 		struct request *rq;
 
 		rq = rq_list_peek(&plug->cached_rq);
-		if (rq) {
+		if (rq && rq->q == q) {
 			if (unlikely(!submit_bio_checks(bio)))
 				return NULL;
 			if (blk_attempt_bio_merge(q, bio, nsegs, same_queue_rq))
-- 
2.35.3