Skip to content

Commit 1b0cab3

Browse files
Christoph Hellwigaxboe
authored andcommitted
mq-deadline: don't call req_get_ioprio from the I/O completion handler
req_get_ioprio looks at req->bio to find the I/O priority, which is not set when completing bios that the driver fully iterated through. Stash away the dd_per_prio in the elevator private data instead of looking it up again to optimize the code a bit while fixing the regression from removing the per-request ioprio value. Fixes: 6975c1a ("block: remove the ioprio field from struct request") Reported-by: Chris Bainbridge <chris.bainbridge@gmail.com> Reported-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Chris Bainbridge <chris.bainbridge@gmail.com> Tested-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20241126102136.619067-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0b83c86 commit 1b0cab3

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

block/mq-deadline.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,9 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
685685

686686
prio = ioprio_class_to_prio[ioprio_class];
687687
per_prio = &dd->per_prio[prio];
688-
if (!rq->elv.priv[0]) {
688+
if (!rq->elv.priv[0])
689689
per_prio->stats.inserted++;
690-
rq->elv.priv[0] = (void *)(uintptr_t)1;
691-
}
690+
rq->elv.priv[0] = per_prio;
692691

693692
if (blk_mq_sched_try_insert_merge(q, rq, free))
694693
return;
@@ -753,18 +752,14 @@ static void dd_prepare_request(struct request *rq)
753752
*/
754753
static void dd_finish_request(struct request *rq)
755754
{
756-
struct request_queue *q = rq->q;
757-
struct deadline_data *dd = q->elevator->elevator_data;
758-
const u8 ioprio_class = dd_rq_ioclass(rq);
759-
const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
760-
struct dd_per_prio *per_prio = &dd->per_prio[prio];
755+
struct dd_per_prio *per_prio = rq->elv.priv[0];
761756

762757
/*
763758
* The block layer core may call dd_finish_request() without having
764759
* called dd_insert_requests(). Skip requests that bypassed I/O
765760
* scheduling. See also blk_mq_request_bypass_insert().
766761
*/
767-
if (rq->elv.priv[0])
762+
if (per_prio)
768763
atomic_inc(&per_prio->stats.completed);
769764
}
770765

0 commit comments

Comments
 (0)