On 16.02.24 13:55, Fiona Ebner wrote:
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]:
- 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)
why not just require the same: bitmap granularity must be >= target granularity
* 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)
There is another approach: consider and unaligned part of the request, fit in one cluster (we can
always split any request to "aligned" middle part, and at most two small
"unligned" parts, each fit into one cluster).
We have two possibilities:
1. the cluster is dirty (marked dirty in the bitmap used by background process)
We can simply ignore this part and rely on background process. This will not
affect the convergence of the mirror job.
2. the cluster is clear (i.e. background process, or some previous write
already copied it)
In this case, we are safe to do unaligned write, as target cluster must be
allocated.
(for bitmap-mode, I don't consider here clusters that are clear from the start,
which we shouldn't copy in any case)
* document the limitation
[0]:
https://lore.kernel.org/qemu-devel/20200218100740.2228521-1-f.gruenbich...@proxmox.com/
[1]:
https://lore.kernel.org/qemu-devel/d35a76de-78d5-af56-0b34-f7bd2bbd3...@redhat.com/
[2]: https://lore.kernel.org/qemu-devel/1599127031.9uxdp5h9o2.astr...@nora.none/
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
--
Best regards,
Vladimir