mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
throttle: use enum ThrottleDirection instead of bool is_write
enum ThrottleDirection is already there, use ThrottleDirection instead of 'bool is_write' for throttle API, also modify related codes from block, fsdev, cryptodev and tests. Reviewed-by: Hanna Czenczek <hreitz@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20230728022006.1098509-7-pizhenwei@bytedance.com> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
This commit is contained in:
parent
27cf12298a
commit
e76f201f69
6 changed files with 36 additions and 27 deletions
|
@ -97,16 +97,18 @@ void fsdev_throttle_init(FsThrottle *fst)
|
|||
void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst, bool is_write,
|
||||
struct iovec *iov, int iovcnt)
|
||||
{
|
||||
ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ;
|
||||
|
||||
if (throttle_enabled(&fst->cfg)) {
|
||||
if (throttle_schedule_timer(&fst->ts, &fst->tt, is_write) ||
|
||||
if (throttle_schedule_timer(&fst->ts, &fst->tt, direction) ||
|
||||
!qemu_co_queue_empty(&fst->throttled_reqs[is_write])) {
|
||||
qemu_co_queue_wait(&fst->throttled_reqs[is_write], NULL);
|
||||
}
|
||||
|
||||
throttle_account(&fst->ts, is_write, iov_size(iov, iovcnt));
|
||||
throttle_account(&fst->ts, direction, iov_size(iov, iovcnt));
|
||||
|
||||
if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write]) &&
|
||||
!throttle_schedule_timer(&fst->ts, &fst->tt, is_write)) {
|
||||
!throttle_schedule_timer(&fst->ts, &fst->tt, direction)) {
|
||||
qemu_co_queue_next(&fst->throttled_reqs[is_write]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue