block: avoid double io accounting for flush request
authorMing Lei <ming.lei@redhat.com>
Tue, 11 May 2021 15:22:33 +0000 (23:22 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 24 May 2021 12:47:21 +0000 (06:47 -0600)
commit84da7acc3ba53af26f15c4b0ada446127b7a7836
treeb9b3f6491319d187f8a66f5fcaff30d6941c818a
parent8c390ff910c5500fc16cca6f90ac2a60c7c84979
block: avoid double io accounting for flush request

For flush request, rq->end_io() may be called two times, one is from
timeout handling(blk_mq_check_expired()), another is from normal
completion(__blk_mq_end_request()).

Move blk_account_io_flush() after flush_rq->ref drops to zero, so
io accounting can be done just once for flush request.

Fixes: b68663186577 ("block: add iostat counters for flush requests")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210511152236.763464-2-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-flush.c