blk-throttle: Fix that bps of child could exceed bps limited in parent
authorKemeng Shi <shikemeng@huawei.com>
Mon, 5 Dec 2022 11:57:02 +0000 (19:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Apr 2023 14:55:37 +0000 (16:55 +0200)
commit414207ff47d12850ce9ed1186de57218b710a312
treeaa4576df575e8f18d5891cd4963d4ed52c97cb86
parent240bb94f3510e0ced4877a786520ee47743c880d
blk-throttle: Fix that bps of child could exceed bps limited in parent

commit 84aca0a7e039c8735abc0f89f3f48e9006c0dfc7 upstream.

Consider situation as following (on the default hierarchy):
 HDD
  |
root (bps limit: 4k)
  |
child (bps limit :8k)
  |
fio bs=8k
Rate of fio is supposed to be 4k, but result is 8k. Reason is as
following:
Size of single IO from fio is larger than bytes allowed in one
throtl_slice in child, so IOs are always queued in child group first.
When queued IOs in child are dispatched to parent group, BIO_BPS_THROTTLED
is set and these IOs will not be limited by tg_within_bps_limit anymore.
Fix this by only set BIO_BPS_THROTTLED when the bio traversed the entire
tree.

There patch has no influence on situation which is not on the default
hierarchy as each group is a single root group without parent.

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
Link: https://lore.kernel.org/r/20221205115709.251489-3-shikemeng@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Cc: Khazhy Kumykov <khazhy@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/blk-throttle.c