aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2015-05-08 13:51:33 -0400
committerJens Axboe <axboe@fb.com>2015-05-08 16:17:23 -0400
commit5b3f341f098d60da2970758db6a05bd851eb6b39 (patch)
treefd25ff2f67ac583a02f2cd288b7419609d373d00 /block/blk-mq.c
parentf984df1f0f71ef96254411fc3576a10ae561be71 (diff)
blk-mq: make plug work for mutiple disks and queues
Last patch makes plug work for multiple queue case. However it only works for single disk case, because it assumes only one request in the plug list. If a task is accessing multiple disks, eg MD/DM, the assumption is wrong. Let blk_attempt_plug_merge() record request from the same queue. V2: use NULL parameter in !mq case. Fix a bug. Add comments in blk_attempt_plug_merge to make it less (hopefully) confusion. Cc: Jens Axboe <axboe@fb.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 902c2eb9a0e7..31df47443699 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1269,6 +1269,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
1269 struct request *rq; 1269 struct request *rq;
1270 unsigned int request_count = 0; 1270 unsigned int request_count = 0;
1271 struct blk_plug *plug; 1271 struct blk_plug *plug;
1272 struct request *same_queue_rq = NULL;
1272 1273
1273 blk_queue_bounce(q, &bio); 1274 blk_queue_bounce(q, &bio);
1274 1275
@@ -1278,7 +1279,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
1278 } 1279 }
1279 1280
1280 if (!is_flush_fua && !blk_queue_nomerges(q) && 1281 if (!is_flush_fua && !blk_queue_nomerges(q) &&
1281 blk_attempt_plug_merge(q, bio, &request_count)) 1282 blk_attempt_plug_merge(q, bio, &request_count, &same_queue_rq))
1282 return; 1283 return;
1283 1284
1284 rq = blk_mq_map_request(q, bio, &data); 1285 rq = blk_mq_map_request(q, bio, &data);
@@ -1309,9 +1310,12 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
1309 * issued. So the plug list will have one request at most 1310 * issued. So the plug list will have one request at most
1310 */ 1311 */
1311 if (plug) { 1312 if (plug) {
1312 if (!list_empty(&plug->mq_list)) { 1313 /*
1313 old_rq = list_first_entry(&plug->mq_list, 1314 * The plug list might get flushed before this. If that
1314 struct request, queuelist); 1315 * happens, same_queue_rq is invalid and plug list is empty
1316 **/
1317 if (same_queue_rq && !list_empty(&plug->mq_list)) {
1318 old_rq = same_queue_rq;
1315 list_del_init(&old_rq->queuelist); 1319 list_del_init(&old_rq->queuelist);
1316 } 1320 }
1317 list_add_tail(&rq->queuelist, &plug->mq_list); 1321 list_add_tail(&rq->queuelist, &plug->mq_list);
@@ -1360,7 +1364,7 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)
1360 } 1364 }
1361 1365
1362 if (!is_flush_fua && !blk_queue_nomerges(q) && 1366 if (!is_flush_fua && !blk_queue_nomerges(q) &&
1363 blk_attempt_plug_merge(q, bio, &request_count)) 1367 blk_attempt_plug_merge(q, bio, &request_count, NULL))
1364 return; 1368 return;
1365 1369
1366 rq = blk_mq_map_request(q, bio, &data); 1370 rq = blk_mq_map_request(q, bio, &data);