From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A9F851FF0B3 for ; Thu, 26 Nov 2026 17:57:22 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3E5BD21710; Thu, 26 Nov 2026 17:57:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795712229; x=1796317029; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:mime-version:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=B8y3uY0xu1I8k6X1/7oBWiwO46TIExh1NILU+k2Jn7U=; b=UN8tQMQQ0mekyuQnnEWLuX/W7pO90WTo3KZlRyriF3ztu7Q4YN+9L966dnyBV3Mvhs 4iC5QQmQUWydi3t+YF4lYg09IRnfkUAfBYhQAiXLp5kdEojHnRzb6uxNG90tJtmGzAM/ JurDjXC55is8ATwTYkg2PEqHtFHVfWfNYxT7VcJoAMc+AGlWlOhJPfbyzQBC8m+LBDjR ESq3Y3wO/J0C364P8CfjJkEpQWr4OZZtbesV+qcEXV3emPnrBMATKOG8Wowp2jzs+Myq tV8g4GQTqxvg/4J7xbtvMMZxmcHJ3BNyUCIZD6vMIUosnY4BCU5IxIyvjjC1heeGhgDj /GqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795712229; x=1796317029; h=content-transfer-encoding:content-type:mime-version:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=B8y3uY0xu1I8k6X1/7oBWiwO46TIExh1NILU+k2Jn7U=; b=cksOBUf5LmlfDgxVpyY96pxKoAJ2m9aTB3ey7BTTKEjTikyFCx3w0FrLu8RNs7vdaO j+sHPIu+Fw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ada2fe7eead31-7d72b35f75emr9908881137.4.1795712228534; Thu, 26 Nov 2026 08:57:08 -0800 (PST) Date: Thu, 26 Nov 2026 13:56:55 -0300 From: Ciro Iriarte To: pve-devel@lists.proxmox.com Subject: [RFC PATCH storage/qemu-server/docs v2 0/6] offload full clone to the storage backend Message-ID: <20261126.0.copyoffload-v2@cyruspy.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.100 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EV3XYF2PT3LWVF4PS4PXPWE5DGPBRIBK X-Message-ID-Hash: EV3XYF2PT3LWVF4PS4PXPWE5DGPBRIBK X-MailFrom: cyruspy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This series lets a storage plugin perform a full copy on its backend instead of having the host read and write every byte with qemu-img or drive-mirror. The consumer is full clone (bug #7780). v1 is at https://lore.proxmox.com/pve-devel/20260720.0.copyoffload@cyruspy.gmail.com/ Recap ----- A plugin advertises one of two features, copy-offload-atomic (the copy captures a single point in time) or copy-offload-bulk (it does not), and implements four methods: copy_image_check() can this volume go to that target storage? copy_image_prepare() reserve the target name, under the storage lock copy_image_start() capture the instant; may run in a guest freeze copy_image_status() poll until the copy is independent of its source The split exists because a backend copy can run for hours while the storage lock is a pmxcfs lock with a 60 second limit, and because only a cheap call can run while a guest is frozen. 'complete' means independent, not just readable: an RBD clone reads fine before it is flattened, but deleting the source would destroy it. For a running guest, qemu-server reserves every offloaded target first and starts the copies inside the same freeze that cuts the mirrored disks over, so all disks of the clone are captured at the same instant. copy_images_start() passes a VM's starts to the plugin as one batch per source/target storage pair, for backends that can capture several volumes together. Offload is off by default, enabled per target storage with the copy-offload option, and only works between two storages of the same type. The series implements it for rbd, dir (reflink), btrfs and lvmthin. Changes since v1 ---------------- Mostly fixes from re-reviewing v1 after the rebase onto storage API 17. Each patch lists its own changes; the main ones: * API 17 changed parse_volname() to return 'vm-vol' instead of 'images'. The dir, btrfs and lvmthin code compared against 'images', so after the rebase, dir never advertised offload and btrfs and lvmthin refused every volume in prepare. They now use vtype_matches(), and a new test goes through the real parse_volname(). * New copy_image_check(). In v1, a pair the backend could not copy (a different thin pool, another filesystem, a filesystem without reflink, different Ceph monitors) made prepare die and the clone fail. The core now checks first and falls back to the host-side copy, logging the reason. * qemu-server no longer uses a goto, which master had just removed. Deferred copies record the source size in the config instead of the placeholder's. Cutting over a final cloud-init drive starts them too, whereas v1 froze the guest a second time. A copy from a snapshot is not deferred. A failed guest agent freeze falls back to suspending the guest; if that fails too, the mirrors are still cut over, as on master, but the deferred copies are not started and the clone fails, because their targets are only reservations. A guest that is already paused stays paused, and a failed thaw or resume ends the task with a warning (log_warn) instead of a plain message. * rbd: the 'ceph rbd task' calls use the storage's connection options and namespace, free_image() cancels a running flatten, and values read back from rbd are untainted for pvedaemon's -T. The check falls back when the target is on another Ceph cluster (same monhost, or else same fsid), when the two storages use different Ceph users, and when the user is not allowed to add manager tasks, which the flatten needs. Each command in start has a 30 second timeout, so a hung cluster fails the start within a bounded time instead of holding the guest frozen indefinitely. The flatten status fix sent after v1 is folded in. * A failed copy's target is freed in one place only. v1 freed it in vdisk_copy_wait() and again in the caller's rollback, which could remove a volume another task had allocated under the same name in between. dir now keeps the name reserved after a failed start, and btrfs free_image() removes a parked placeholder. * The docs patch, sent separately, is now 6/6. APIVER goes 17 -> 18 and APIAGE 8 -> 9. The base plugin declares 'copy-offload' and 'copy-offload-timeout', so under the v17 rules they become common properties. That fits the criterion as I read it, since core code reads them from any storage type, but it means a third-party plugin declaring either name would stop loading. I found none. No range-diff: the rebase onto API 17 and the clone_disk() restructuring make it longer than the patches themselves. qemu-server 5/6 needs a libpve-storage-perl that ships APIVER 18 (1/6); I left the debian/control bump to you. The patches apply in order: storage, then qemu-server, then docs. Not covered: the edit dialogs of the in-tree storages in pve-manager are hand-written, so copy-offload can only be set with pvesm or the API for now. The clone bandwidth limit does not apply to an offloaded copy, since the data does not pass through the host; the docs say so. Open questions -------------- 1. move_disk. It already goes through clone_disk(), so moving a disk of a stopped guest, or a detached disk, is offloaded. Moving an attached disk of a running guest would need the bulk path, since the source changes during the copy. Same series or later? 2. prepare() returns a volname, and a failed copy's rollback frees that volname. The caller drops the lock between prepare and start, so each backend has to keep the name reserved itself (btrfs swaps with renameat2(RENAME_EXCHANGE), rbd and lvmthin park under a prefix the lister ignores but the allocator counts). An opaque token that the rollback verifies would move that guarantee into the core. Is that worth an interface change now? 3. copy_offload_class() tries atomic before bulk and stops at the first refusal. copy_image_check() does not get the class, so falling through to bulk would require passing it in. No plugin here advertises both; is that worth doing now? 4. run_with_guest_quiesced() changes what every full clone of a running guest does, offloaded or not, compared with master's monitor(): a failed guest agent freeze falls back to suspending the guest instead of continuing unquiesced; a guest that was already paused is no longer resumed afterwards; and a failed thaw or resume is reported with log_warn(), so the task ends with a warning. I chose a warning over failing the task because failing it deletes a finished clone, and on Windows the agent's freeze is limited to about ten seconds, after which the thaw itself reports an error; in that case the disks may not be captured at the same instant, and the warning is the only sign of it. Are these acceptable for all clones, or should they be limited to clones with deferred copies? 5. copy_image_start() runs while the guest is frozen. The plugin contract asks it to put a timeout on calls that can block on a remote backend; rbd does, per command, while dir, btrfs and lvmthin run local reflink, snapshot and LVM operations without one (a reflink of a heavily fragmented file on XFS can take seconds). The core sets no overall deadline. Given the ten second freeze limit on Windows, should it? 6. Only the target storage's copy-offload option is consulted, as the new volume lands there. Should the source storage be able to refuse as well? rbd requests clone format 2 explicitly. It worked on the test cluster, whose require-min-compat-client is luminous; a cluster older than Mimic was not tested. Testing ------- On a PVE 9.3 node (libpve-storage-perl 9.1.26, qemu-server 9.2.24, matching the bases of this series): * pve-storage 'make check', minus the four targets that create real devices: all 24 targets pass, as on master. run_plugin_tests.pl runs 902 tests, all pass. * copy_offload_functional_test.pl as root, on a loop-backed btrfs and thin pool: 22/22. Without the vtype_matches() change it fails at the first prepare. * qemu-server 'make test' passes, including the new run_guest_quiesce_tests.pl. * Full clones of running VMs onto Ceph RBD (Tentacle, erasure coded pool), with the patched code loaded for the qm process only: an offloaded disk plus a mirrored one plus a final cloud-init drive; a mirrored disk followed by an offloaded one; two offloaded disks; and an offloaded disk of a paused guest, which stayed paused. The guests had no agent, so this used the suspend path. In every case the RBD snapshot was taken while the guest was quiesced, each clone was byte-identical to its source and had no parent, the config recorded the right size, and no snapshot was left on the source. Not repeated from v1: the reflink runs on XFS and ZFS, and the guest agent freeze path. The dir, btrfs and lvmthin paths were exercised by the functional test, not through a live clone. Ciro Iriarte (6): storage: add asynchronous copy-offload hook for full copies rbd: implement copy-offload via snapshot + clone + flatten dir: implement copy-offload via reflink (FICLONE) btrfs, lvmthin: implement copy-offload (atomic class) use storage copy-offload for full clone pvesm: document copy-offload and add it to the storage capability table storage: ApiChangeLog | 38 ++ src/PVE/Storage.pm | 268 ++++++++++- src/PVE/Storage/BTRFSPlugin.pm | 267 +++++++++++ src/PVE/Storage/DirPlugin.pm | 193 ++++++++ src/PVE/Storage/LvmThinPlugin.pm | 202 ++++++++- src/PVE/Storage/Plugin.pm | 180 ++++++++ src/PVE/Storage/RBDPlugin.pm | 551 ++++++++++++++++++++++- src/test/copy_offload_check_test.pm | 208 +++++++++ src/test/copy_offload_feature_test.pm | 99 ++++ src/test/copy_offload_functional_test.pl | 296 ++++++++++++ src/test/copy_offload_naming_test.pm | 82 ++++ src/test/copy_offload_rbd_status_test.pm | 114 +++++ src/test/copy_offload_test.pm | 90 ++++ src/test/plugin_properties_test.pm | 5 +- src/test/run_plugin_tests.pl | 5 + 15 files changed, 2588 insertions(+), 10 deletions(-) qemu-server: src/PVE/API2/Qemu.pm | 17 +++ src/PVE/QemuServer.pm | 225 ++++++++++++++++++++++++++-- src/PVE/QemuServer/BlockJob.pm | 119 +++++++++++---- src/test/Makefile | 5 +- src/test/run_guest_quiesce_tests.pl | 154 +++++++++++++++++++ 5 files changed, 479 insertions(+), 41 deletions(-) docs: pvesm.adoc | 79 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 17 deletions(-) -- Ciro Iriarte