mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -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
|
@ -270,6 +270,7 @@ static bool throttle_group_schedule_timer(ThrottleGroupMember *tgm,
|
|||
ThrottleState *ts = tgm->throttle_state;
|
||||
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
|
||||
ThrottleTimers *tt = &tgm->throttle_timers;
|
||||
ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ;
|
||||
bool must_wait;
|
||||
|
||||
if (qatomic_read(&tgm->io_limits_disabled)) {
|
||||
|
@ -281,7 +282,7 @@ static bool throttle_group_schedule_timer(ThrottleGroupMember *tgm,
|
|||
return true;
|
||||
}
|
||||
|
||||
must_wait = throttle_schedule_timer(ts, tt, is_write);
|
||||
must_wait = throttle_schedule_timer(ts, tt, direction);
|
||||
|
||||
/* If a timer just got armed, set tgm as the current token */
|
||||
if (must_wait) {
|
||||
|
@ -364,6 +365,7 @@ void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm
|
|||
bool must_wait;
|
||||
ThrottleGroupMember *token;
|
||||
ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts);
|
||||
ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ;
|
||||
|
||||
assert(bytes >= 0);
|
||||
|
||||
|
@ -386,7 +388,7 @@ void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm
|
|||
}
|
||||
|
||||
/* The I/O will be executed, so do the accounting */
|
||||
throttle_account(tgm->throttle_state, is_write, bytes);
|
||||
throttle_account(tgm->throttle_state, direction, bytes);
|
||||
|
||||
/* Schedule the next request */
|
||||
schedule_next_request(tgm, is_write);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue