Skip to content

block: cheaper zero handling in backup and commit

Denis V. Lunev qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest12 patches 5 repliesIn review
  2. v39 patches 17 repliesSuperseded
  3. v29 patches 5 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v19 patches9 repliesSuperseded

v3 from the cover letter

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12block/commit: pass BDRV_WANT_PRECISE to block-statusblock/commit.c+2 -20 replies
2/12iotests/040: cover large and fragmented commit runstests/qemu-iotests/040 tests/qemu-iotests/040.out+103 -30 replies
3/12block/commit: batch block-status queriesblock/commit.c+47 -110 replies
4/12iotests/124: cover backup of zero clusters and holestests/qemu-iotests/124 tests/qemu-iotests/124.out+348 -30 replies
5/12block/block-copy: extract block_copy_set_task_method()block/block-copy.c+30 -160 replies
6/12block/block-copy: track known-zero source clustersblock/backup.c block/block-copy.c include/block/block-copy.h+98 -120 replies
7/12block/backup: pre-fill zero_bitmap for full/bitmapblock/backup.c block/block-copy.c include/block/block-copy.h+106 -340 replies
8/12block/block-copy: rename block_copy_is_cluster_allocated()block/block-copy.c+7 -70 replies
9/12block/block-copy: merge the two backup scan steps into block_copy_prescan()block/backup.c block/block-copy.c include/block/block-copy.h+27 -521 reply
10/12block/block-copy: replace zero_bitmap_valid with scan_doneblock/backup.c block/block-copy.c include/block/block-copy.h+14 -131 reply
11/12util/co-shared-resource: skip the mutex for an empty requestutil/qemu-co-shared-resource.c+8 -01 reply
12/12block/block-copy: coalesce write-zeroes tasksblock/block-copy.c qapi/block-core.json+88 -121 reply

Reviews trailers per patch

11 of 12 patches have a Reviewed-by or Acked-by.

PatchAndrey DrobyshevVladimir Sementsov-OgievskiyEric Blake
1/12R-b R-b R-b
2/12R-b R-b
3/12R-b R-b
4/12R-b R-b
5/12R-b R-b
6/12R-b
7/12R-b
8/12
9/12R-b
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v4 thread

Cover letter [PATCH v4 00/12] block: cheaper zero handling in backup and commit

Backup and commit re-query the source block status for every task and size a task by the copy buffer, so a long run of zeroes turns into a crowd of small write-zeroes requests. This series reuses what the up-front scan already learned and lets one write-zeroes task cover a whole run.

Backup of a 16G qcow2 image holding 1G of data, the rest never allocated, sync=full to a raw target on ext4:

               tasks    time
    before     16384    1.6s
    after       1088    1.0s

Such an image is the normal case rather than a corner one: a guest with discard enabled on a disk which is mostly free leaves exactly this shape behind.

Eric, this is the v4 you asked about on 10-28; please take it instead of v3.

v4, all from Vladimir's review of v3:
- v3 5/9 "don't reserve memory for zero tasks" is dropped. On its own it let a write-zeroes task bounce through a buffer that s->mem never charged. Its accounting change moves into 12/12 and applies only to a task asking for BDRV_REQ_NO_FALLBACK, the one sure to need no buffer. Its Reviewed-by tags go with it.
- 7/12: each prescan step moves past the dirty area it searched, so a full backup of a fragmented source no longer searches the same range again and again.
- 8/12, 9/12 and 10/12 are new, the follow-ups asked for on v3 7/9:
block_copy_is_cluster_allocated() becomes block_copy_scan_status(), the two prescan helpers merge into block_copy_prescan(), and zero_bitmap_valid becomes scan_done, published together with clearing skip_unallocated.
- 11/12 is new: co_get_from_shres() and co_put_to_shres() skip the mutex for zero bytes, which 12/12 makes the common case.
- 12/12: the serial fallback loop is gone. A refused task shrinks to one cluster and the rest of its range is dirty again, so it comes back as buffer-sized tasks running in parallel instead of one request holding off guest writes to the whole range. A task asking for NO_FALLBACK is left out of s->mem and of speed=. Widening uses bdrv_dirty_bitmap_next_zero(), drops the MAX() with cluster_size, and is no longer bounded by x-perf max-chunk, whose documentation now says so. Andrey's Reviewed-by on v3 is dropped since the patch changed.
- rebased on master

v3:
https://lore.kernel.org/qemu-devel/[email protected]/

CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC John Snow <[email protected]>
CC Andrey Drobyshev <[email protected]>
CC Eric Blake <[email protected]>

Denis V. Lunev (12):
block/commit: pass BDRV_WANT_PRECISE to block-status iotests/040: cover large and fragmented commit runs block/commit: batch block-status queries iotests/124: cover backup of zero clusters and holes block/block-copy: extract block_copy_set_task_method() block/block-copy: track known-zero source clusters block/backup: pre-fill zero_bitmap for full/bitmap block/block-copy: rename block_copy_is_cluster_allocated() block/block-copy: merge the two backup scan steps into
block_copy_prescan()
block/block-copy: replace zero_bitmap_valid with scan_done util/co-shared-resource: skip the mutex for an empty request block/block-copy: coalesce write-zeroes tasks

 block/backup.c                 |  86 ++++----
 block/block-copy.c             | 326 +++++++++++++++++++++++++------
 block/commit.c                 |  58 ++++--
 include/block/block-copy.h     |   6 +-
 qapi/block-core.json           |   4 +-
 tests/qemu-iotests/040         | 102 +++++++++-
 tests/qemu-iotests/040.out     |   4 +-
 tests/qemu-iotests/124         | 347 ++++++++++++++++++++++++++++++++-
 tests/qemu-iotests/124.out     |   4 +-
 util/qemu-co-shared-resource.c |   8 +
 10 files changed, 829 insertions(+), 116 deletions(-)

base-commit: 73294d096cc591e122fde9e63db4739de6d84f2b

Signature · 1 line
2.53.0