]> git.proxmox.com Git - mirror_qemu.git/commit - block/block-copy.c
block/block-copy: add ratelimit to block-copy
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Sat, 16 Jan 2021 21:46:48 +0000 (00:46 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 26 Jan 2021 13:36:37 +0000 (14:36 +0100)
commit7e032df0ea7a4a2272c9b14b97d3f620397dba6f
treee8f33df9d9974e2f7e12ee3bee93dec8df734a56
parent2e099a9d29b2f8791ceaa4a54479e613f45180bd
block/block-copy: add ratelimit to block-copy

We are going to directly use one async block-copy operation for backup
job, so we need rate limiter.

We want to maintain current backup behavior: only background copying is
limited and copy-before-write operations only participate in limit
calculation. Therefore we need one rate limiter for block-copy state
and boolean flag for block-copy call state for actual limitation.

Note, that we can't just calculate each chunk in limiter after
successful copying: it will not save us from starting a lot of async
sub-requests which will exceed limit too much. Instead let's use the
following scheme on sub-request creation:
1. If at the moment limit is not exceeded, create the request and
account it immediately.
2. If at the moment limit is already exceeded, drop create sub-request
and handle limit instead (by sleep).
With this approach we'll never exceed the limit more than by one
sub-request (which pretty much matches current backup behavior).

Note also, that if there is in-flight block-copy async call,
block_copy_kick() should be used after set-speed to apply new setup
faster. For that block_copy_kick() published in this patch.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210116214705.822267-7-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/backup-top.c
block/backup.c
block/block-copy.c
include/block/block-copy.h