From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 89ADA1FF15C for ; Fri, 17 Oct 2025 13:35:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D328D139; Fri, 17 Oct 2025 13:35:09 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Fri, 17 Oct 2025 12:25:28 +0100 In-Reply-To: <20251017112539.26471-1-joao.sousa@eurotux.com> References: <20251017112539.26471-1-joao.sousa@eurotux.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Tiago Sousa via pve-devel Precedence: list Cc: Tiago Sousa X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH pve-storage 3/4] lvmplugin: add thin volume support for LVM external snapshots Content-Type: multipart/mixed; boundary="===============8887595823650398211==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============8887595823650398211== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A1418D0F2E for ; Fri, 17 Oct 2025 13:35:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 96C1527D1D for ; Fri, 17 Oct 2025 13:35:06 +0200 (CEST) Received: from eurotux.com (mail.eurotux.com [185.98.249.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 17 Oct 2025 13:35:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by eurotux.com (Postfix) with ESMTP id 67A2F30CFB0E; Fri, 17 Oct 2025 12:26:02 +0100 (WEST) Authentication-Results: mail.prd.eurotux.pt (amavisd-new); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=eurotux.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eurotux.com; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from; s= default; t=1760700361; x=1762514762; bh=9hSauw1R5uA6j2AF6RWOFEqg tCm931VqIyBRbNtD0u0=; b=wg5IUjCHDO9z6L+CmVmz5YaTpQgBNfXFo88S0jwy 9sUcNpVXD086Hp6FKLvABzEzEyMpQb3pIXSP5R83LEGcA7LwLRMdwkaURljk6fGw OL3HE1LDd71ykHJZPLHg9lQh/IAnD8ih2QtZhGHjvXpgEAtW0+xfa9TETj+2WCfy PDQZRYKAASZECsJolJBwtkG1bArFNprSqIif5sNvJsZJSioEjgJancZJROAA99IA 67MSX1dHVsTYdzbrbwTClkvKLVm6cUhivUnUK3G3bq4LKCRdnP8kvcgn/qAuHKzq Z52Y1oWJSDCOhgqwz2uTMQlN+yEUYfeAsMTo6PuMeAICkA== X-Virus-Scanned: amavisd-new at mail.prd.eurotux.pt Received: from eurotux.com ([127.0.0.1]) by localhost (mail.prd.eurotux.pt [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1zQuSN8D7mqq; Fri, 17 Oct 2025 12:26:01 +0100 (WEST) Received: from proxmox.example (184.137.90.149.rev.vodafone.pt [149.90.137.184]) (Authenticated sender: joao.sousa@eurotux.com) by eurotux.com (Postfix) with ESMTPSA id 85A0730CFB15; Fri, 17 Oct 2025 12:26:01 +0100 (WEST) From: Tiago Sousa To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage 3/4] lvmplugin: add thin volume support for LVM external snapshots Date: Fri, 17 Oct 2025 12:25:28 +0100 Message-ID: <20251017112539.26471-4-joao.sousa@eurotux.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251017112539.26471-1-joao.sousa@eurotux.com> References: <20251017112539.26471-1-joao.sousa@eurotux.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record Signed-off-by: Tiago Sousa --- src/PVE/Storage/Common.pm | 4 ++-- src/PVE/Storage/LVMPlugin.pm | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm index 222dc76..1e5d4c6 100644 --- a/src/PVE/Storage/Common.pm +++ b/src/PVE/Storage/Common.pm @@ -170,7 +170,7 @@ C<$options> currently allows setting the C value. =3Dcut =20 sub qemu_img_create_qcow2_backed { - my ($path, $backing_path, $backing_format, $options) =3D @_; + my ($path, $backing_path, $backing_format, $options, $thin) =3D @_; =20 my $cmd =3D [ '/usr/bin/qemu-img', @@ -188,7 +188,7 @@ sub qemu_img_create_qcow2_backed { my $opts =3D ['extended_l2=3Don', 'cluster_size=3D128k']; =20 push @$opts, "preallocation=3D$options->{preallocation}" - if defined($options->{preallocation}); + if defined($options->{preallocation}) && !$thin; push @$cmd, '-o', join(',', @$opts) if @$opts > 0; =20 run_command($cmd, errmsg =3D> "unable to create image"); diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 0416c9e..dc5e648 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -575,7 +575,7 @@ sub lvrename { } =20 my sub lvm_qcow2_format { - my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size) =3D = @_; + my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size, $thi= n) =3D @_; =20 $class->activate_volume($storeid, $scfg, $name); my $path =3D $class->path($scfg, $name, $storeid); @@ -585,7 +585,9 @@ my sub lvm_qcow2_format { }; if ($backing_snap) { my $backing_volname =3D get_snap_name($class, $name, $backing_sn= ap); - PVE::Storage::Common::qemu_img_create_qcow2_backed($path, $backi= ng_volname, $fmt, $options); + PVE::Storage::Common::qemu_img_create_qcow2_backed( + $path, $backing_volname, $fmt, $options, $thin, + ); } else { PVE::Storage::Common::qemu_img_create($fmt, $size, $path, $optio= ns); } @@ -629,7 +631,16 @@ my sub alloc_lvm_image { die "no such volume group '$vg'\n" if !defined($vgs->{$vg}); =20 my $free =3D int($vgs->{$vg}->{free}); - my $lvmsize =3D calculate_lvm_size($size, $fmt, $backing_snap); + my $lvmsize; + + # FIX: make this variable a check box when taking a snapshot + # right now all snapshots are created thin for testing purposes + my $thin =3D $backing_snap ? 1 : 0; + if ($thin) { + $lvmsize =3D 2 * 1024 * 1024; + } else { + $lvmsize =3D calculate_lvm_size($size, $fmt, $backing_snap); + } =20 die "not enough free space ($free < $size)\n" if $free < $size; =20 @@ -641,7 +652,7 @@ my sub alloc_lvm_image { return if $fmt ne 'qcow2'; =20 #format the lvm volume with qcow2 format - eval { lvm_qcow2_format($class, $storeid, $scfg, $name, $fmt, $backi= ng_snap, $size) }; + eval { lvm_qcow2_format($class, $storeid, $scfg, $name, $fmt, $backi= ng_snap, $size, $thin) }; if ($@) { my $err =3D $@; #no need to safe cleanup as the volume is still empty --=20 2.47.3 --===============8887595823650398211== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============8887595823650398211==--