From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-storage 2/2] common: qemu_img_create: add backing_file support
Date: Tue, 27 May 2025 10:48:59 +0200 [thread overview]
Message-ID: <31ef5e5b-8994-49de-9634-eb59a60b78ff@proxmox.com> (raw)
In-Reply-To: <mailman.560.1747921998.394.pve-devel@lists.proxmox.com>
Am 22.05.25 um 15:53 schrieb Alexandre Derumier via pve-devel:
>
> and use it for plugin linked clone
>
> This also enable extended_l2=on, as it's mandatory for backing file
> preallocation.
>
> Preallocation was missing previously, so it should increase performance
> for linked clone now (around x5 in randwrite 4k)
>
> cluster_size is set to 128k, as it reduce qcow2 overhead (reduce disk,
> but also memory needed to cache metadatas)
>
> l2_extended is not enabled yet on base image, but it could help too
> to reduce overhead without impacting performance
>
> bench on 100G qcow2 file:
>
> fio --filename=/dev/sdb --direct=1 --rw=randwrite --bs=4k --iodepth=32 --ioengine=libaio --name=test
> fio --filename=/dev/sdb --direct=1 --rw=randread --bs=4k --iodepth=32 --ioengine=libaio --name=test
>
> base image:
>
> randwrite 4k: prealloc=metadata, l2_extended=off, cluster_size=64k: 20215
> randread 4k: prealloc=metadata, l2_extended=off, cluster_size=64k: 22219
> randwrite 4k: prealloc=metadata, l2_extended=on, cluster_size=64k: 20217
> randread 4k: prealloc=metadata, l2_extended=on, cluster_size=64k: 21742
> randwrite 4k: prealloc=metadata, l2_extended=on, cluster_size=128k: 21599
> randread 4k: prealloc=metadata, l2_extended=on, cluster_size=128k: 22037
>
> clone image with backing file:
>
> randwrite 4k: prealloc=metadata, l2_extended=off, cluster_size=64k: 3912
> randread 4k: prealloc=metadata, l2_extended=off, cluster_size=64k: 21476
> randwrite 4k: prealloc=metadata, l2_extended=on, cluster_size=64k: 20563
> randread 4k: prealloc=metadata, l2_extended=on, cluster_size=64k: 22265
> randwrite 4k: prealloc=metadata, l2_extended=on, cluster_size=128k: 18016
> randread 4k: prealloc=metadata, l2_extended=on, cluster_size=128k: 21611
>
> Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
In general, the approach is fine by me :)
> ---
> src/PVE/Storage/Common.pm | 17 +++++++++++++----
> src/PVE/Storage/Plugin.pm | 5 +----
> 2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm
> index 0770d70..01a995a 100644
> --- a/src/PVE/Storage/Common.pm
> +++ b/src/PVE/Storage/Common.pm
> @@ -148,14 +148,23 @@ sub preallocation_cmd_option {
> }
>
> sub qemu_img_create {
> - my ($scfg, $fmt, $size, $path) = @_;
> + my ($scfg, $fmt, $size, $path, $backing_path) = @_;
> +
> + die "size can't be specified if backing file is used" if $size && $backing_path;
I'd prefer having a second dedicated function
qemu_img_create_qcow2_with_backing() rather than an interface where some
parameters need to be undef depending on how you want to use it. It also
doesn't require a format parameter, because we only allow it for qcow2.
> my $cmd = ['/usr/bin/qemu-img', 'create'];
>
> - my $prealloc_opt = preallocation_cmd_option($scfg, $fmt);
> - push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
> + my $options = [];
> +
> + if($backing_path) {
> + push @$cmd, '-b', $backing_path, '-F', 'qcow2';
You're now using "-F qcow2" and...(continued below)
> + push @$options, 'extended_l2=on','cluster_size=128k';
> + };
>
> - push @$cmd, '-f', $fmt, $path, "${size}K";
> + push @$options, preallocation_cmd_option($scfg, $fmt);
> + push @$cmd, '-o', join(',', @$options) if @$options > 0;
> + push @$cmd, '-f', $fmt, $path;
..."-f $fmt"...
> + push @$cmd, "${size}K" if $size;
>
> run_command($cmd, errmsg => "unable to create image");
> }
> diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
> index 7030e4e..a3856ca 100644
> --- a/src/PVE/Storage/Plugin.pm
> +++ b/src/PVE/Storage/Plugin.pm
> @@ -847,10 +847,7 @@ sub clone_image {
> eval {
> local $CWD = $imagedir;
>
> - my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
> - '-F', $format, '-f', 'qcow2', $path];
...but the old command was using "-F $format -f qcow2"!
> -
> - run_command($cmd);
> + PVE::Storage::Common::qemu_img_create($scfg, $format, undef, $path, "../$basevmid/$basename");
> };
> my $err = $@;
>
> --
> 2.39.5
>
>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-05-27 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250522135304.2513284-1-alexandre.derumier@groupe-cyllene.com>
2025-05-22 13:53 ` [pve-devel] [PATCH pve-storage 1/2] common: add qemu_img_create an preallocation_cmd_option Alexandre Derumier via pve-devel
2025-05-27 8:49 ` Fiona Ebner
2025-05-22 13:53 ` [pve-devel] [PATCH pve-storage 2/2] common: qemu_img_create: add backing_file support Alexandre Derumier via pve-devel
2025-05-27 8:48 ` Fiona Ebner [this message]
2025-05-27 8:55 ` DERUMIER, Alexandre via pve-devel
[not found] <20250519102310.911326-1-alexandre.derumier@groupe-cyllene.com>
2025-05-19 10:23 ` Alexandre Derumier via pve-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31ef5e5b-8994-49de-9634-eb59a60b78ff@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal