Skip to content

RFC mirror: implement incremental and bitmap modes

Fiona Ebner qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 20 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4drive-mirror: add support for sync=bitmap mode=neverblock/mirror.c blockdev.c include/block/block_int-global-state.h +2 more+139 -282 replies
2/4drive-mirror: add support for conditional and always bitmap sync modesblock/mirror.c blockdev.c+21 -60 replies
3/4mirror: move some checks to qmpblock/mirror.c blockdev.c+34 -230 replies
4/4iotests: add test for bitmap mirrortests/qemu-iotests/tests/bitmap-sync-mirror tests/qemu-iotests/tests/bitmap-sync-mirror.out+3360 -00 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchJohn Snow
1/4
2/4Originally-by
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC 0/4] mirror: implement incremental and bitmap modes

Previous discussion from when this was sent upstream [0] (it's been a while). I rebased the patches and re-ordered and squashed like suggested back then [1].

This implements two new mirror modes:

- bitmap mirror mode with always/on-success/never bitmap sync mode
- incremental mirror mode as sugar for bitmap + on-success

Use cases:
* Possibility to resume a failed mirror later.
* Possibility to only mirror deltas to a previously mirrored volume.
* Possibility to (efficiently) mirror an drive that was previously mirrored via some external mechanism (e.g. ZFS replication).

We are using the last one in production without any issues since about 4 years now. In particular, like mentioned in [2]:

Quoted 4 lines

- create bitmap(s)
- (incrementally) replicate storage volume(s) out of band (using ZFS)
- incrementally drive mirror as part of a live migration of VM
- drop bitmap(s)

Now, the IO test added in patch 4/4 actually contains yet another use case, namely doing incremental mirrors to stand-alone qcow2 "diff" images, that only contain the delta and can be rebased later. I had to adapt the IO test, because its output expected the mirror bitmap to still be dirty, but nowadays the mirror is apparently already done when the bitmaps are queried. So I thought, I'll just use 'write-blocking' mode to avoid any potential timing issues.

But this exposed an issue with the diff image approach. If a write is not aligned to the granularity of the mirror target, then rebasing the diff image onto a backing image will not yield the desired result, because the full cluster is considered to be allocated and will "hide" some part of the base/backing image. The failure can be seen by either using 'write-blocking' mode in the IO test or setting the (bitmap) granularity to 32 KiB rather than the current 64 KiB.

The question is how to deal with these edge cases? Some possibilities that would make sense to me:

For 'background' mode:
* prohibit if target's cluster size is larger than the bitmap granularity
* document the limitation

For 'write-blocking' mode:
* disallow in combination with bitmap mode (would not be happy about it, because I'd like to use this without diff images)
* for writes that are not aligned to the target's cluster size, read the relevant/missing parts from the source image to be able to write whole target clusters (seems rather complex)
* document the limitation

[0]: https://lore.kernel.org/qemu-devel/[email protected]/
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://lore.kernel.org/qemu-devel/[email protected]/

Fabian Grünbichler (2):
mirror: move some checks to qmp
iotests: add test for bitmap mirror

John Snow (2):
drive-mirror: add support for sync=bitmap mode=never
drive-mirror: add support for conditional and always bitmap sync modes

 block/mirror.c                                |   94 +-
 blockdev.c                                    |   70 +-
 include/block/block_int-global-state.h        |    4 +-
 qapi/block-core.json                          |   25 +-
 tests/qemu-iotests/tests/bitmap-sync-mirror   |  550 ++++
 .../qemu-iotests/tests/bitmap-sync-mirror.out | 2810 +++++++++++++++++
 tests/unit/test-block-iothread.c              |    4 +-
 7 files changed, 3527 insertions(+), 30 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/bitmap-sync-mirror
 create mode 100644 tests/qemu-iotests/tests/bitmap-sync-mirror.out
Signature · 1 line
2.39.2