From d0907c8cf2962855192829ab453dc1769f7b606c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 24 Aug 2021 10:05:20 -0700 Subject: [PATCH] FROMGIT: block/mq-deadline: Improve request accounting further The scheduler .insert_requests() callback is called when a request is queued for the first time and also when it is requeued. Only count a request the first time it is queued. Additionally, since the mq-deadline scheduler only performs zone locking for requests that have been inserted, skip the zone unlock code for requests that have not been inserted into the mq-deadline scheduler. Fixes: 38ba64d12d4c ("block/mq-deadline: Track I/O statistics") Reviewed-by: Damien Le Moal Reviewed-by: Niklas Cassel Cc: Hannes Reinecke Signed-off-by: Bart Van Assche (cherry picked from commit 73ac1fd7994b0ea2e62c921f413530dc6c1724ac git://git.kernel.dk/linux-block/ for-5.16 block) Change-Id: I418f845a80bb0716400944fbd466ec3016551937 Signed-off-by: Bart Van Assche --- block/mq-deadline.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index faaf169c854e..b9728ab12789 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -674,8 +674,10 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, blk_req_zone_write_unlock(rq); prio = ioprio_class_to_prio[ioprio_class]; - dd_count(dd, inserted, prio); - rq->elv.priv[0] = (void *)(uintptr_t)1; + if (!rq->elv.priv[0]) { + dd_count(dd, inserted, prio); + rq->elv.priv[0] = (void *)(uintptr_t)1; + } if (blk_mq_sched_try_insert_merge(q, rq)) return; @@ -754,12 +756,13 @@ static void dd_finish_request(struct request *rq) /* * The block layer core may call dd_finish_request() without having - * called dd_insert_requests(). Hence only update statistics for - * requests for which dd_insert_requests() has been called. See also - * blk_mq_request_bypass_insert(). + * called dd_insert_requests(). Skip requests that bypassed I/O + * scheduling. See also blk_mq_request_bypass_insert(). */ - if (rq->elv.priv[0]) - dd_count(dd, completed, prio); + if (!rq->elv.priv[0]) + return; + + dd_count(dd, completed, prio); if (blk_queue_is_zoned(q)) { unsigned long flags;