blk-iocost: fix divide-by-zero in transfer_surpluses()
authorTejun Heo <tj@kernel.org>
Fri, 11 Sep 2020 22:40:49 +0000 (18:40 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Sep 2020 22:41:47 +0000 (16:41 -0600)
commit769b628de0b9a7ab0b81e6eecca5ee7bf66e978d
tree39ebaa9dc4a2a062fe38ea3aebfdce8d1c642cc9
parent0806e60f31ec10822cd230d12603169d1bb7840e
blk-iocost: fix divide-by-zero in transfer_surpluses()

Conceptually, root_iocg->hweight_donating must be less than WEIGHT_ONE but
all hweight calculations round up and thus it may end up >= WEIGHT_ONE
triggering divide-by-zero and other issues. Bound the value to avoid
surprises.

Fixes: e08d02aa5fc9 ("blk-iocost: implement Andy's method for donation weight updates")
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c