History

block: have ->poll_fn() return number of entries polled

We currently only really support sync poll, ie poll with 1 IO in flight. This prepares us for supporting async poll. Note that the returned value isn't necessarily 100% accurate. If poll races with IRQ completion, we assume that the fact that the task is now runnable means we found at least one entry. In reality it could be more than 1, or not even 1. This is fine, the caller will just need to take this into account.

Jens Axboe committed 8 years ago

Commit 85f4d4b1 parent 849a3703 files · +12 −12Browse files

Unified · Split

3 files
  1. block/blk-mq.c +9 −9
  2. drivers/nvme/host/multipath.c +2 −2
  3. include/linux/blkdev.h +1 −1
block/blk-mq.c+9−9
@@ -38,7 +38,7 @@ · 37 unmodified lines
3838 #include "blk-mq-sched.h"
3939 #include "blk-rq-qos.h"
4040
41−static bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie);
41+static int blk_mq_poll(struct request_queue *q, blk_qc_t cookie);
4242 static void blk_mq_poll_stats_start(struct request_queue *q);
4343 static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb);
4444
@@ -3305,7 +3305,7 @@ static bool blk_mq_poll_hybrid_sleep(struct request_queue *q, · 3260 unmodified lines
33053305 return true;
33063306 }
33073307
3308−static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
3308+static int __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
33093309 {
33103310 struct request_queue *q = hctx->queue;
33113311 long state;
@@ -3318,7 +3318,7 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq) · 6 unmodified lines
33183318 * straight to the busy poll loop.
33193319 */
33203320 if (blk_mq_poll_hybrid_sleep(q, hctx, rq))
3321− return true;
3321+ return 1;
33223322
33233323 hctx->poll_considered++;
33243324
@@ -3332,30 +3332,30 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq) · 7 unmodified lines
33323332 if (ret > 0) {
33333333 hctx->poll_success++;
33343334 __set_current_state(TASK_RUNNING);
3335− return true;
3335+ return ret;
33363336 }
33373337
33383338 if (signal_pending_state(state, current))
33393339 __set_current_state(TASK_RUNNING);
33403340
33413341 if (current->state == TASK_RUNNING)
3342− return true;
3342+ return 1;
33433343 if (ret < 0)
33443344 break;
33453345 cpu_relax();
33463346 }
33473347
33483348 __set_current_state(TASK_RUNNING);
3349− return false;
3349+ return 0;
33503350 }
33513351
3352−static bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie)
3352+static int blk_mq_poll(struct request_queue *q, blk_qc_t cookie)
33533353 {
33543354 struct blk_mq_hw_ctx *hctx;
33553355 struct request *rq;
33563356
33573357 if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
3358− return false;
3358+ return 0;
33593359
33603360 hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)];
33613361 if (!blk_qc_t_is_internal(cookie))
@@ -3369,7 +3369,7 @@ static bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie) · 7 unmodified lines
33693369 * so we should be safe with just the NULL check.
33703370 */
33713371 if (!rq)
3372− return false;
3372+ return 0;
33733373 }
33743374
33753375 return __blk_mq_poll(hctx, rq);
drivers/nvme/host/multipath.c+2−2
@@ -220,11 +220,11 @@ static blk_qc_t nvme_ns_head_make_request(struct request_queue *q, · 219 unmodified lines
220220 return ret;
221221 }
222222
223−static bool nvme_ns_head_poll(struct request_queue *q, blk_qc_t qc)
223+static int nvme_ns_head_poll(struct request_queue *q, blk_qc_t qc)
224224 {
225225 struct nvme_ns_head *head = q->queuedata;
226226 struct nvme_ns *ns;
227− bool found = false;
227+ int found = 0;
228228 int srcu_idx;
229229
230230 srcu_idx = srcu_read_lock(&head->srcu);
include/linux/blkdev.h+1−1
@@ -283,7 +283,7 @@ static inline unsigned short req_get_ioprio(struct request *req) · 282 unmodified lines
283283 struct blk_queue_ctx;
284284
285285 typedef blk_qc_t (make_request_fn) (struct request_queue *q, struct bio *bio);
286−typedef bool (poll_q_fn) (struct request_queue *q, blk_qc_t);
286+typedef int (poll_q_fn) (struct request_queue *q, blk_qc_t);
287287
288288 struct bio_vec;
289289 typedef int (dma_drain_needed_fn)(struct request *);