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 0609B1FF13A for ; Wed, 13 May 2026 15:06:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E3CCD957; Wed, 13 May 2026 15:06:30 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH storage 4/8] fix #6819: lvm plugin: list images: use approximate size for inactive qcow2 volumes Date: Wed, 13 May 2026 15:05:36 +0200 Message-ID: <20260513130548.143270-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260513130548.143270-1-f.ebner@proxmox.com> References: <20260513130548.143270-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778677548022 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: YXKGS4HF4YJBLXBWHW5E6GLT5O367USA X-Message-ID-Hash: YXKGS4HF4YJBLXBWHW5E6GLT5O367USA X-MailFrom: f.ebner@proxmox.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: For qcow2 volumes on LVM, the exact size can only be queried when the LV is active. For a shared LVM, an LV might already be active on another node, so it must not be activated. Also, doing so for each volume would be costly. Instead, return only the approximate size when the LV is inactive. Signed-off-by: Fiona Ebner --- src/PVE/Storage/LVMPlugin.pm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 3a35e38..4564f5b 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -833,19 +833,28 @@ sub list_images { } my $format = ($class->parse_volname($volname))[6]; - my $size = - $format eq 'qcow2' - ? $class->volume_size_info($scfg, $storeid, $volname) - : $info->{lv_size}; + my $entry = { + volid => $volid, + format => $format, + vmid => $owner, + ctime => $info->{ctime}, + }; - push @$res, - { - volid => $volid, - format => $format, - size => $size, - vmid => $owner, - ctime => $info->{ctime}, - }; + if ($format eq 'qcow2') { + my $size; + if ($info->{lv_state} eq 'a') { + $size = $class->volume_size_info($scfg, $storeid, $volname); + } + if (defined($size)) { + $entry->{size} = $size; + } else { + $entry->{'approximate-size'} = $info->{lv_size}; + } + } else { + $entry->{size} = $info->{lv_size}; + } + + push @$res, $entry; } } -- 2.47.3