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 DCC0A1FF141 for ; Tue, 30 Jun 2026 14:15:25 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id BC2ED2141D; Tue, 30 Jun 2026 14:15:24 +0200 (CEST) Message-ID: <777e92d5-3d3e-4daf-8e2b-2061d931ef4e@proxmox.com> Date: Tue, 30 Jun 2026 14:14:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH storage v7 2/4] fix #7339: lvm: add discard action for removed volumes To: Lukas Sichert , pve-devel@lists.proxmox.com References: <20260616101323.24981-1-l.sichert@proxmox.com> <20260616101323.24981-3-l.sichert@proxmox.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: <20260616101323.24981-3-l.sichert@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782821677231 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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: S5LZ7O6ALA6T2WNDIGQXXIXQYPF3BDQ6 X-Message-ID-Hash: S5LZ7O6ALA6T2WNDIGQXXIXQYPF3BDQ6 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: Am 16.06.26 um 12:13 PM schrieb Lukas Sichert: > On LVM storages backed by thin-provisioned SAN LUNs, removing an LV does > not release the allocated space on the backing storage. Using LVM's > `issue_discards` can avoid that, but makes `lvremove` issue the discards > while holding the cluster-wide storage lock, which can hit the lock > timeout for large volumes. > > Add an `on-volume-remove` property with an initial `discard` action. The > cleanup worker issues the discard for the renamed LV before the final > remove, so the long-running operation happens outside the storage lock. > When combined with `saferemove`, the worker zeroes and discards the LV > range by range, avoiding allocation of the whole LV with zeroes on > thin-provisioned backing storage. If a storage has on-volume-remove discard=1 saferemove 0 then zero-out is still done. I would expect only discard to be done then. > > Signed-off-by: Lukas Sichert > Link: bugzilla.proxmox.com/show_bug.cgi?id=7339 > --- > src/PVE/Storage/LVMPlugin.pm | 95 ++++++++++++++++++++++++++++++++---- > 1 file changed, 85 insertions(+), 10 deletions(-) > > diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm > index f0a7a80..ee07543 100644 > --- a/src/PVE/Storage/LVMPlugin.pm > +++ b/src/PVE/Storage/LVMPlugin.pm > @@ -13,6 +13,7 @@ use PVE::Tools qw(run_command file_read_firstline trim); > > use PVE::Storage::Common; > use PVE::Storage::Plugin; > +use PVE::SafeSyslog; Same nit as in patch 1 > use PVE::RESTEnvironment qw(log_warn); > > use base qw(PVE::Storage::Plugin); > @@ -20,6 +21,7 @@ use base qw(PVE::Storage::Plugin); > # lvm helper functions > > use constant { > + BLKDISCARD => 0x1277, > BLKZEROOUT => 0x127f, > }; > > @@ -296,6 +298,12 @@ my sub free_lvm_volumes_locked { > > my $vg = $scfg->{vgname}; > > + my $on_remove_opts; > + if ($scfg->{'on-volume-remove'}) { > + $on_remove_opts = > + PVE::JSONSchema::parse_property_string('on-volume-remove', $scfg->{'on-volume-remove'}); > + } > + > my $secure_delete_cmd = sub { > my ($lvmpath) = @_; > > @@ -373,6 +381,14 @@ my sub free_lvm_volumes_locked { > die "short syswrite: wrote $written of $stepsize bytes\n"; > } > } > + if ($on_remove_opts->{discard}) { > + eval { > + blockdev_ioctl_range($fh, 'BLKDISCARD', BLKDISCARD, $offset, $stepsize); > + }; > + if ($@) { > + log_warn("blkdiscard failed: $@"); Similar to the last patch, I would log the offset and length for completeness. I also wonder if we should > + } > + } > $written_total += $stepsize; > > my $curr_time = time();