Skip to content
  • Zhenwei Pi's avatar
    3b2337ef
    block/throttle-groups: Use ThrottleDirection instread of bool is_write · 3b2337ef
    Zhenwei Pi authored
    
    
    '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: default avatarzhenwei pi <pizhenwei@bytedance.com>
    Message-Id: <20230728022006.1098509-10-pizhenwei@bytedance.com>
    Reviewed-by: default avatarHanna Czenczek <hreitz@redhat.com>
    Signed-off-by: default avatarHanna Czenczek <hreitz@redhat.com>
    3b2337ef
    block/throttle-groups: Use ThrottleDirection instread of bool is_write
    Zhenwei Pi authored
    
    
    '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: default avatarzhenwei pi <pizhenwei@bytedance.com>
    Message-Id: <20230728022006.1098509-10-pizhenwei@bytedance.com>
    Reviewed-by: default avatarHanna Czenczek <hreitz@redhat.com>
    Signed-off-by: default avatarHanna Czenczek <hreitz@redhat.com>
Loading