]> git.hungrycats.org Git - linux/commit
block: make rq sector size accessible for block stats
authorHou Tao <houtao1@huawei.com>
Tue, 21 May 2019 07:59:03 +0000 (15:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Oct 2019 11:13:55 +0000 (13:13 +0200)
commitd54de8cfa4a1343419b21b463fd6aa8492226f80
treedfc899a7e5752e4634b49567d054110e3d4cb5ef
parent6c7b70e220d5d9236b943c026ba4492d7a488c47
block: make rq sector size accessible for block stats

[ Upstream commit 3d24430694077313c75c6b89f618db09943621e4 ]

Currently rq->data_len will be decreased by partial completion or
zeroed by completion, so when blk_stat_add() is invoked, data_len
will be zero and there will never be samples in poll_cb because
blk_mq_poll_stats_bkt() will return -1 if data_len is zero.

We could move blk_stat_add() back to __blk_mq_complete_request(),
but that would make the effort of trying to call ktime_get_ns()
once in vain. Instead we can reuse throtl_size field, and use
it for both block stats and block throttle, and adjust the
logic in blk_mq_poll_stats_bkt() accordingly.

Fixes: 4bc6339a583c ("block: move blk_stat_add() to __blk_mq_end_request()")
Tested-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-mq.c
block/blk-throttle.c
include/linux/blkdev.h