aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2016-10-28 20:20:02 -0400
committerJens Axboe <axboe@fb.com>2016-11-02 14:50:19 -0400
commit2253efc850c4cf690516bbc07854eeb1077202ba (patch)
tree8e99571c3ce4bff1ca732820a55d0abea1824b41
parentfd00144301d64f1742541a3c5e64cd1c51f39c55 (diff)
blk-mq: Move more code into blk_mq_direct_issue_request()
Move the "hctx stopped" test and the insert request calls into blk_mq_direct_issue_request(). Rename that function into blk_mq_try_issue_directly() to reflect its new semantics. Pass the hctx pointer to that function instead of looking it up a second time. These changes avoid that code has to be duplicated in the next patch. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/blk-mq.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 28bf667bfe09..447c37f39e32 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1228,11 +1228,11 @@ static struct request *blk_mq_map_request(struct request_queue *q,
1228 return rq; 1228 return rq;
1229} 1229}
1230 1230
1231static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie) 1231static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
1232 struct request *rq, blk_qc_t *cookie)
1232{ 1233{
1233 int ret; 1234 int ret;
1234 struct request_queue *q = rq->q; 1235 struct request_queue *q = rq->q;
1235 struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu);
1236 struct blk_mq_queue_data bd = { 1236 struct blk_mq_queue_data bd = {
1237 .rq = rq, 1237 .rq = rq,
1238 .list = NULL, 1238 .list = NULL,
@@ -1240,6 +1240,9 @@ static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
1240 }; 1240 };
1241 blk_qc_t new_cookie = blk_tag_to_qc_t(rq->tag, hctx->queue_num); 1241 blk_qc_t new_cookie = blk_tag_to_qc_t(rq->tag, hctx->queue_num);
1242 1242
1243 if (blk_mq_hctx_stopped(hctx))
1244 goto insert;
1245
1243 /* 1246 /*
1244 * For OK queue, we are done. For error, kill it. Any other 1247 * For OK queue, we are done. For error, kill it. Any other
1245 * error (busy), just add it to our list as we previously 1248 * error (busy), just add it to our list as we previously
@@ -1248,7 +1251,7 @@ static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
1248 ret = q->mq_ops->queue_rq(hctx, &bd); 1251 ret = q->mq_ops->queue_rq(hctx, &bd);
1249 if (ret == BLK_MQ_RQ_QUEUE_OK) { 1252 if (ret == BLK_MQ_RQ_QUEUE_OK) {
1250 *cookie = new_cookie; 1253 *cookie = new_cookie;
1251 return 0; 1254 return;
1252 } 1255 }
1253 1256
1254 __blk_mq_requeue_request(rq); 1257 __blk_mq_requeue_request(rq);
@@ -1257,10 +1260,11 @@ static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
1257 *cookie = BLK_QC_T_NONE; 1260 *cookie = BLK_QC_T_NONE;
1258 rq->errors = -EIO; 1261 rq->errors = -EIO;
1259 blk_mq_end_request(rq, rq->errors); 1262 blk_mq_end_request(rq, rq->errors);
1260 return 0; 1263 return;
1261 } 1264 }
1262 1265
1263 return -1; 1266insert:
1267 blk_mq_insert_request(rq, false, true, true);
1264} 1268}
1265 1269
1266/* 1270/*
@@ -1337,9 +1341,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
1337 blk_mq_put_ctx(data.ctx); 1341 blk_mq_put_ctx(data.ctx);
1338 if (!old_rq) 1342 if (!old_rq)
1339 goto done; 1343 goto done;
1340 if (blk_mq_hctx_stopped(data.hctx) || 1344 blk_mq_try_issue_directly(data.hctx, old_rq, &cookie);
1341 blk_mq_direct_issue_request(old_rq, &cookie) != 0)
1342 blk_mq_insert_request(old_rq, false, true, true);
1343 goto done; 1345 goto done;
1344 } 1346 }
1345 1347