From: Fiona Ebner <f.ebner@proxmox.com>
To: Lukas Sichert <l.sichert@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH storage v7 2/4] fix #7339: lvm: add discard action for removed volumes
Date: Tue, 30 Jun 2026 14:14:49 +0200 [thread overview]
Message-ID: <777e92d5-3d3e-4daf-8e2b-2061d931ef4e@proxmox.com> (raw)
In-Reply-To: <20260616101323.24981-3-l.sichert@proxmox.com>
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 <l.sichert@proxmox.com>
> 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();
next prev parent reply other threads:[~2026-06-30 12:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 10:13 [PATCH docs/manager/storage v7 0/4] fix #7339: lvmthick: add option to free storage for deleted VMs Lukas Sichert
2026-06-16 10:13 ` [PATCH storage v7 1/4] lvm: saferemove: zero out volumes range by range Lukas Sichert
2026-06-30 11:49 ` Fiona Ebner
2026-06-30 14:16 ` Lukas Sichert
2026-06-30 14:28 ` Fiona Ebner
2026-06-16 10:13 ` [PATCH storage v7 2/4] fix #7339: lvm: add discard action for removed volumes Lukas Sichert
2026-06-30 10:55 ` Michael Köppl
2026-06-30 12:14 ` Fiona Ebner [this message]
2026-06-30 12:20 ` Fiona Ebner
2026-06-30 12:37 ` Fiona Ebner
2026-06-16 10:13 ` [PATCH manager v7 3/4] fix #7339: lvmthick: ui: add UI option to free storage Lukas Sichert
2026-06-30 11:38 ` Michael Köppl
2026-06-16 10:13 ` [PATCH docs v7 4/4] fix #7339: lvm: document discard option Lukas Sichert
2026-06-30 11:48 ` Michael Köppl
2026-06-30 12:50 ` Fiona Ebner
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=777e92d5-3d3e-4daf-8e2b-2061d931ef4e@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=l.sichert@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