@@ -1093,18 +1093,21 @@ bool blk_attempt_plug_merge(struct reque
if (!plug || rq_list_empty(plug->mq_list))
return false;
- /* check the previously added entry for a quick merge attempt */
- rq = rq_list_peek(&plug->mq_list);
- if (rq->q == q) {
+ rq_list_for_each(&plug->mq_list, rq) {
+ if (rq->q == q) {
+ *same_queue_rq = true;
+ if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
+ BIO_MERGE_OK)
+ return true;
+ break;
+ }
+
/*
- * Only blk-mq multiple hardware queues case checks the rq in
- * the same queue, there should be only one such rq in a queue
+ * Only keep iterating plug list for merges if we have multiple
+ * queues
*/
- *same_queue_rq = true;
-
- if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
- BIO_MERGE_OK)
- return true;
+ if (!plug->multiple_queues)
+ break;
}
return false;
}