]> git.baikalelectronics.ru Git - kernel.git/commitdiff
blk-mq: fix missing blk_account_io_done() in error path
authorYu Kuai <yukuai3@huawei.com>
Wed, 26 Jan 2022 01:21:32 +0000 (09:21 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 26 Jan 2022 13:34:41 +0000 (06:34 -0700)
If blk_mq_request_issue_directly() failed from
blk_insert_cloned_request(), the request will be accounted start.
Currently, blk_insert_cloned_request() is only called by dm, and such
request won't be accounted done by dm.

In normal path, io will be accounted start from blk_mq_bio_to_request(),
when the request is allocated, and such io will be accounted done from
__blk_mq_end_request_acct() whether it succeeded or failed. Thus add
blk_account_io_done() to fix the problem.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220126012132.3111551-1-yukuai3@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index f3bf3358a3bb2ebe677c0c3daf7dd739e9687173..1adfe4824ef5e29377874b1b337326ab3b3c498b 100644 (file)
@@ -2922,6 +2922,8 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *
         */
        blk_mq_run_dispatch_ops(rq->q,
                        ret = blk_mq_request_issue_directly(rq, true));
+       if (ret)
+               blk_account_io_done(rq, ktime_get_ns());
        return ret;
 }
 EXPORT_SYMBOL_GPL(blk_insert_cloned_request);