Skip to content

Commit c01b5a8

Browse files
keithbuschaxboe
authored andcommitted
block: support polling through blk_execute_rq
Poll for completions if the request's hctx is a polling type. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210610214437.641245-2-kbusch@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent da6269d commit c01b5a8

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

block/blk-exec.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ void blk_execute_rq_nowait(struct gendisk *bd_disk, struct request *rq,
6363
}
6464
EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
6565

66+
static bool blk_rq_is_poll(struct request *rq)
67+
{
68+
return rq->mq_hctx && rq->mq_hctx->type == HCTX_TYPE_POLL;
69+
}
70+
71+
static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
72+
{
73+
do {
74+
blk_poll(rq->q, request_to_qc_t(rq->mq_hctx, rq), true);
75+
cond_resched();
76+
} while (!completion_done(wait));
77+
}
78+
6679
/**
6780
* blk_execute_rq - insert a request into queue for execution
6881
* @bd_disk: matching gendisk
@@ -83,7 +96,10 @@ void blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head)
8396

8497
/* Prevent hang_check timer from firing at us during very long I/O */
8598
hang_check = sysctl_hung_task_timeout_secs;
86-
if (hang_check)
99+
100+
if (blk_rq_is_poll(rq))
101+
blk_rq_poll_completion(rq, &wait);
102+
else if (hang_check)
87103
while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2)));
88104
else
89105
wait_for_completion_io(&wait);

0 commit comments

Comments
 (0)