20209d8d73
Excerpt from Fiona's v3 cover-letter [0]: When a backup for a VM is started, QEMU will install a "copy-before-write" filter in its block layer. This filter ensures that upon new guest writes, old data still needed for the backup is sent to the backup target first. The guest write blocks until this operation is finished so guest IO to not-yet-backed-up sectors will be limited by the speed of the backup target. With backup fleecing, such old data is cached in a fleecing image rather than sent directly to the backup target. This can help guest IO performance and even prevent hangs in certain scenarios, at the cost of requiring more storage space. With this series it will be possible to enable backup-fleecing via e.g. `vzdump 123 --fleecing enabled=1,storage=local-lvm` with fleecing images created on the storage `local-lvm`. The fleecing storage should be a fast local storage which supports thin-provisioning and discard. If the storage supports qcow2, that is used as the fleecing image format. If the underlying file system does not support discard, with qcow2 and preallocation=off, at least already allocated parts of the image can be re-used later. Fleecing images are created by qemu-server via pve-storage and attached to QEMU before the backup starts, and cleaned up after the backup finished or failed. The naming schema for fleecing images is 'vm-ID-fleece-N(.FORMAT)'. The allocated images are recorded in the guest configuration, so that even after a hard failure, clean-up can be re-attempted. While not too bad, it's a non-trivial amount of code and I'm not 100% sure about the cost-benefit, so sending those as RFC. The fleecing image needs to be the exact same size as the source, but luckily, an explicit size can be specified when attaching a raw image to QEMU so there are no size issues when using storages that have coarser allocation/round up. For qcow2, it seems that virtual size can be nearly arbitrary (i.e. modulo 512 byte granularity) during allocation. [0]: https://lists.proxmox.com/pipermail/pve-devel/2024-April/062815.html Originally-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
49 lines
1.9 KiB
Diff
49 lines
1.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
|
Date: Thu, 11 Apr 2024 11:29:23 +0200
|
|
Subject: [PATCH] block/copy-before-write: support unligned snapshot-discard
|
|
|
|
First thing that crashes on unligned access here is
|
|
bdrv_reset_dirty_bitmap(). Correct way is to align-down the
|
|
snapshot-discard request.
|
|
|
|
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
|
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
---
|
|
block/copy-before-write.c | 16 +++++++++++++---
|
|
1 file changed, 13 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
|
index a2dddf6f57..0a219c2b75 100644
|
|
--- a/block/copy-before-write.c
|
|
+++ b/block/copy-before-write.c
|
|
@@ -325,14 +325,24 @@ static int coroutine_fn GRAPH_RDLOCK
|
|
cbw_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
|
{
|
|
BDRVCopyBeforeWriteState *s = bs->opaque;
|
|
+ uint32_t cluster_size = block_copy_cluster_size(s->bcs);
|
|
+ int64_t aligned_offset = QEMU_ALIGN_UP(offset, cluster_size);
|
|
+ int64_t aligned_end = QEMU_ALIGN_DOWN(offset + bytes, cluster_size);
|
|
+ int64_t aligned_bytes;
|
|
+
|
|
+ if (aligned_end <= aligned_offset) {
|
|
+ return 0;
|
|
+ }
|
|
+ aligned_bytes = aligned_end - aligned_offset;
|
|
|
|
WITH_QEMU_LOCK_GUARD(&s->lock) {
|
|
- bdrv_reset_dirty_bitmap(s->access_bitmap, offset, bytes);
|
|
+ bdrv_reset_dirty_bitmap(s->access_bitmap, aligned_offset,
|
|
+ aligned_bytes);
|
|
}
|
|
|
|
- block_copy_reset(s->bcs, offset, bytes);
|
|
+ block_copy_reset(s->bcs, aligned_offset, aligned_bytes);
|
|
|
|
- return bdrv_co_pdiscard(s->target, offset, bytes);
|
|
+ return bdrv_co_pdiscard(s->target, aligned_offset, aligned_bytes);
|
|
}
|
|
|
|
static void cbw_refresh_filename(BlockDriverState *bs)
|