diff mbox series

[5/5] block: ensure cached plug request matches the current queue

Message ID 20211104182201.83906-6-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series Alloc batch fixes | expand

Commit Message

Jens Axboe Nov. 4, 2021, 6:22 p.m. UTC
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")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Nov. 4, 2021, 6:36 p.m. UTC | #1
On Thu, Nov 04, 2021 at 12:22:01PM -0600, Jens Axboe wrote:
> 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")
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 875bd0c04409..6c8d02bd1b06 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2529,7 +2529,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;
 			plug->cached_rq = rq_list_next(rq);