summaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2015-11-05 12:41:40 -0500
committerJens Axboe <axboe@fb.com>2015-11-07 12:40:47 -0500
commit7b371636fb6d187873d9d2730c2b1febc48a9b47 (patch)
tree28044eb235fb576771b171ade4e40cfd5d9343a8 /block/blk-mq.c
parentdece16353ef47d8d33f5302bc158072a9d65e26f (diff)
blk-mq: return tag/queue combo in the make_request_fn handlers
Return a cookie, blk_qc_t, from the blk-mq make request functions, that allows a later caller to uniquely identify a specific IO. The cookie doesn't mean anything to the caller, but the caller can use it to later pass back to the block layer. The block layer can then identify the hardware queue and request from that cookie. Signed-off-by: Jens Axboe <axboe@fb.com> Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 65f43bd696a0..66f3cf9c436d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1198,7 +1198,7 @@ static struct request *blk_mq_map_request(struct request_queue *q,
1198 return rq; 1198 return rq;
1199} 1199}
1200 1200
1201static int blk_mq_direct_issue_request(struct request *rq) 1201static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
1202{ 1202{
1203 int ret; 1203 int ret;
1204 struct request_queue *q = rq->q; 1204 struct request_queue *q = rq->q;
@@ -1209,6 +1209,7 @@ static int blk_mq_direct_issue_request(struct request *rq)
1209 .list = NULL, 1209 .list = NULL,
1210 .last = 1 1210 .last = 1
1211 }; 1211 };
1212 blk_qc_t new_cookie = blk_tag_to_qc_t(rq->tag, hctx->queue_num);
1212 1213
1213 /* 1214 /*
1214 * For OK queue, we are done. For error, kill it. Any other 1215 * For OK queue, we are done. For error, kill it. Any other
@@ -1216,18 +1217,21 @@ static int blk_mq_direct_issue_request(struct request *rq)
1216 * would have done 1217 * would have done
1217 */ 1218 */
1218 ret = q->mq_ops->queue_rq(hctx, &bd); 1219 ret = q->mq_ops->queue_rq(hctx, &bd);
1219 if (ret == BLK_MQ_RQ_QUEUE_OK) 1220 if (ret == BLK_MQ_RQ_QUEUE_OK) {
1221 *cookie = new_cookie;
1220 return 0; 1222 return 0;
1221 else { 1223 }
1222 __blk_mq_requeue_request(rq);
1223 1224
1224 if (ret == BLK_MQ_RQ_QUEUE_ERROR) { 1225 __blk_mq_requeue_request(rq);
1225 rq->errors = -EIO; 1226
1226 blk_mq_end_request(rq, rq->errors); 1227 if (ret == BLK_MQ_RQ_QUEUE_ERROR) {
1227 return 0; 1228 *cookie = BLK_QC_T_NONE;
1228 } 1229 rq->errors = -EIO;
1229 return -1; 1230 blk_mq_end_request(rq, rq->errors);
1231 return 0;
1230 } 1232 }
1233
1234 return -1;
1231} 1235}
1232 1236
1233/* 1237/*
@@ -1244,6 +1248,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
1244 unsigned int request_count = 0; 1248 unsigned int request_count = 0;
1245 struct blk_plug *plug; 1249 struct blk_plug *plug;
1246 struct request *same_queue_rq = NULL; 1250 struct request *same_queue_rq = NULL;
1251 blk_qc_t cookie;
1247 1252
1248 blk_queue_bounce(q, &bio); 1253 blk_queue_bounce(q, &bio);
1249 1254
@@ -1265,6 +1270,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
1265 if (unlikely(!rq)) 1270 if (unlikely(!rq))
1266 return BLK_QC_T_NONE; 1271 return BLK_QC_T_NONE;
1267 1272
1273 cookie = blk_tag_to_qc_t(rq->tag, data.hctx->queue_num);
1274
1268 if (unlikely(is_flush_fua)) { 1275 if (unlikely(is_flush_fua)) {
1269 blk_mq_bio_to_request(rq, bio); 1276 blk_mq_bio_to_request(rq, bio);
1270 blk_insert_flush(rq); 1277 blk_insert_flush(rq);
@@ -1302,11 +1309,11 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
1302 old_rq = rq; 1309 old_rq = rq;
1303 blk_mq_put_ctx(data.ctx); 1310 blk_mq_put_ctx(data.ctx);
1304 if (!old_rq) 1311 if (!old_rq)
1305 return BLK_QC_T_NONE; 1312 goto done;
1306 if (!blk_mq_direct_issue_request(old_rq)) 1313 if (!blk_mq_direct_issue_request(old_rq, &cookie))
1307 return BLK_QC_T_NONE; 1314 goto done;
1308 blk_mq_insert_request(old_rq, false, true, true); 1315 blk_mq_insert_request(old_rq, false, true, true);
1309 return BLK_QC_T_NONE; 1316 goto done;
1310 } 1317 }
1311 1318
1312 if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) { 1319 if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) {
@@ -1320,7 +1327,8 @@ run_queue:
1320 blk_mq_run_hw_queue(data.hctx, !is_sync || is_flush_fua); 1327 blk_mq_run_hw_queue(data.hctx, !is_sync || is_flush_fua);
1321 } 1328 }
1322 blk_mq_put_ctx(data.ctx); 1329 blk_mq_put_ctx(data.ctx);
1323 return BLK_QC_T_NONE; 1330done:
1331 return cookie;
1324} 1332}
1325 1333
1326/* 1334/*
@@ -1335,6 +1343,7 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
1335 unsigned int request_count = 0; 1343 unsigned int request_count = 0;
1336 struct blk_map_ctx data; 1344 struct blk_map_ctx data;
1337 struct request *rq; 1345 struct request *rq;
1346 blk_qc_t cookie;
1338 1347
1339 blk_queue_bounce(q, &bio); 1348 blk_queue_bounce(q, &bio);
1340 1349
@@ -1353,6 +1362,8 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
1353 if (unlikely(!rq)) 1362 if (unlikely(!rq))
1354 return BLK_QC_T_NONE; 1363 return BLK_QC_T_NONE;
1355 1364
1365 cookie = blk_tag_to_qc_t(rq->tag, data.hctx->queue_num);
1366
1356 if (unlikely(is_flush_fua)) { 1367 if (unlikely(is_flush_fua)) {
1357 blk_mq_bio_to_request(rq, bio); 1368 blk_mq_bio_to_request(rq, bio);
1358 blk_insert_flush(rq); 1369 blk_insert_flush(rq);
@@ -1375,7 +1386,7 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
1375 } 1386 }
1376 list_add_tail(&rq->queuelist, &plug->mq_list); 1387 list_add_tail(&rq->queuelist, &plug->mq_list);
1377 blk_mq_put_ctx(data.ctx); 1388 blk_mq_put_ctx(data.ctx);
1378 return BLK_QC_T_NONE; 1389 return cookie;
1379 } 1390 }
1380 1391
1381 if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) { 1392 if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) {
@@ -1390,7 +1401,7 @@ run_queue:
1390 } 1401 }
1391 1402
1392 blk_mq_put_ctx(data.ctx); 1403 blk_mq_put_ctx(data.ctx);
1393 return BLK_QC_T_NONE; 1404 return cookie;
1394} 1405}
1395 1406
1396/* 1407/*