blk-throttle: Avoid calculating bps/iops limitation repeatedly
authorBaolin Wang <baolin.wang@linux.alibaba.com>
Mon, 7 Sep 2020 08:10:16 +0000 (16:10 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Sep 2020 01:36:54 +0000 (19:36 -0600)
commit4599ea49d4b00a6fbaab2977e7f8359cfc7e8916
tree032a33e3a4b59e25808143d21a430c4b12eaf0cc
parente675df2adc2f0b8cbc0c64111d55b69f7253cbed
blk-throttle: Avoid calculating bps/iops limitation repeatedly

The tg_may_dispatch() will call tg_with_in_bps_limit() and
tg_with_in_iops_limit() to check if we can dispatch a bio or
not, which will calculate bps/iops limitation multiple times.
But tg_may_dispatch() is always called under queue lock, which
means the bps/iops limitation will not change in tg_may_dispatch().

So we can calculate the bps/iops limitation only once, and pass
them to tg_with_in_bps_limit() and tg_with_in_iops_limit() to
avoid calculating bps/iops limitation repeatedly.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-throttle.c