From: Fiona Ebner <f.ebner@proxmox.com>
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 [thread overview]
Message-ID: <20261109154341.215638-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261109154341.215638-1-f.ebner@proxmox.com>
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 <d.herzig@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
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
next prev parent reply other threads:[~2026-11-09 15:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 15:39 [PATCH-SERIES storage/qemu-server/container 0/4] volume resize improvements, part 1 Fiona Ebner
2026-11-09 15:39 ` [PATCH storage 1/4] lvm: factor out helper for querying LV size Fiona Ebner
2026-11-09 15:39 ` Fiona Ebner [this message]
2026-11-09 15:39 ` [PATCH qemu-server 3/4] qm: disk resize: propagate exit status from worker Fiona Ebner
2026-11-09 15:39 ` [PATCH container 4/4] pct: " Fiona Ebner
2026-11-09 18:18 ` applied: [PATCH-SERIES storage/qemu-server/container 0/4] volume resize improvements, part 1 Thomas Lamprecht
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=20261109154341.215638-3-f.ebner@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