]> git.proxmox.com Git - mirror_qemu.git/commit - block/throttle.c
block/throttle-groups: Use ThrottleDirection instread of bool is_write
authorzhenwei pi <pizhenwei@bytedance.com>
Fri, 28 Jul 2023 02:20:06 +0000 (10:20 +0800)
committerHanna Czenczek <hreitz@redhat.com>
Tue, 29 Aug 2023 08:49:24 +0000 (10:49 +0200)
commit3b2337eff03e23ffcc7d6b0a0f72bd3ab2135ae9
treedd174e4597f96888e93d1adbb8c12c83221caad6
parent00ea69f50345258d1ff6262f24516abea5548d3a
block/throttle-groups: Use ThrottleDirection instread of bool is_write

'bool is_write' style is obsolete from throttle framework, adapt
block throttle groups to the new style:
- use ThrottleDirection instead of 'bool is_write'. Ex,
  schedule_next_request(ThrottleGroupMember *tgm, bool is_write)
  -> schedule_next_request(ThrottleGroupMember *tgm, ThrottleDirection direction)

- use THROTTLE_MAX instead of hard code. Ex, ThrottleGroupMember *tokens[2]
  -> ThrottleGroupMember *tokens[THROTTLE_MAX]

- use ThrottleDirection instead of hard code on iteration. Ex, (i = 0; i < 2; i++)
  -> for (dir = THROTTLE_READ; dir < THROTTLE_MAX; dir++)

Use a simple python script to test the new style:
 #!/usr/bin/python3
import subprocess
import random
import time

commands = ['virsh blkdeviotune jammy vda --write-bytes-sec ', \
            'virsh blkdeviotune jammy vda --write-iops-sec ', \
            'virsh blkdeviotune jammy vda --read-bytes-sec ', \
            'virsh blkdeviotune jammy vda --read-iops-sec ']

for loop in range(1, 1000):
    time.sleep(random.randrange(3, 5))
    command = commands[random.randrange(0, 3)] + str(random.randrange(0, 1000000))
    subprocess.run(command, shell=True, check=True)

This works fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20230728022006.1098509-10-pizhenwei@bytedance.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
block/block-backend.c
block/throttle-groups.c
block/throttle.c
include/block/throttle-groups.h