From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 8E8691FF09B for ; Mon, 09 Nov 2026 16:44:01 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4CD7B2162C; Mon, 09 Nov 2026 16:43:50 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH storage 2/4] lvm: qcow2 resize: do not abort if LV size is already large enough Date: Mon, 9 Nov 2026 16:39:35 +0100 Message-ID: <20261109154341.215638-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261109154341.215638-1-f.ebner@proxmox.com> References: <20261109154341.215638-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: 1794239025013 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.287 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium 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: YUBNLP3JX7IWNFG23ETTQWTVGH534PZH X-Message-ID-Hash: YUBNLP3JX7IWNFG23ETTQWTVGH534PZH 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: The qcow2 size is used as the basis of allocation and resize operations, and the LV size is calculated based on it. So having a larger LV for some reason, for example after a manual resize, is not fundamentally an issue, but the lvextend command can fail with either of the following during a subsequent resize operation: 1. > No size change. 2. > New size given (769 extents) not larger than existing size (1025 extents) Warn about having a larger LV size, because it is not expected, but do not abort the operation. Reported-by: Daniel Herzig Signed-off-by: Fiona Ebner --- We could also just use a normal print/warn rather than a task warning. For small resizes, the situation might happen because of extent rounding. src/PVE/Storage/LVMPlugin.pm | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 53120e47..1b0c8020 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -1692,20 +1692,33 @@ sub volume_resize { $class->parse_volname($volname); my $lvmsize = calculate_lvm_size($size / 1024, $format); - $lvmsize = "${lvmsize}k"; my $path = $class->path($scfg, $volname, $storeid, $snapname); - my $cmd = ['/sbin/lvextend', '-L', $lvmsize, $path]; + # For qcow2, the expected size of the LV might get out of sync, so check. + my ($skip_lvextend, $old_lvmsize); + if ($format eq 'qcow2') { + $old_lvmsize = lvm_lv_size_info($path, 60); + $skip_lvextend = 1 if $old_lvmsize >= $lvmsize * 1024; + } - $class->cluster_lock_storage( - $storeid, - $scfg->{shared}, - undef, - sub { - run_command($cmd, errmsg => "error resizing volume '$path'"); - }, - ); + if ($skip_lvextend) { + my $oldsize_h = render_bytes($old_lvmsize); + my $size_h = render_bytes($lvmsize * 1024); + log_warn("LV '$path' already large enough: $oldsize_h >= $size_h"); + } else { + $lvmsize = "${lvmsize}k"; + my $cmd = ['/sbin/lvextend', '-L', $lvmsize, $path]; + + $class->cluster_lock_storage( + $storeid, + $scfg->{shared}, + undef, + sub { + run_command($cmd, errmsg => "error resizing volume '$path'"); + }, + ); + } if (!$running && $format eq 'qcow2') { my $preallocation = PVE::Storage::Plugin::preallocation_cmd_opt($scfg, $format); -- 2.47.3