public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: "Lukas Sichert" <l.sichert@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH storage v6 1/2] fix #7339: lvmthick: add worker to free space of to be deleted VMs
Date: Mon, 08 Jun 2026 16:06:12 +0200	[thread overview]
Message-ID: <DJ3Q4W866087.6HIM5KM2APD1@proxmox.com> (raw)
In-Reply-To: <20260522130419.94386-2-l.sichert@proxmox.com>

Left some comments inline.

On Fri May 22, 2026 at 3:04 PM CEST, Lukas Sichert wrote:

[snip]

> -
> +    my $on_remove_opts;
> +    if ($scfg->{'on-volume-remove'}) {
> +        $on_remove_opts =
> +            PVE::JSONSchema::parse_property_string('on-volume-remove', $scfg->{'on-volume-remove'});
> +    }
>      # we need to zero out LVM data for security reasons
> -    # and to allow thin provisioning
> -    my $zero_out_worker = sub {
> +    # and discard images to free storage space to allow
> +    # thin provisioning
> +    my $cleanup_worker = sub {
> +
>          for my $name (@$volnames) {
>              my $lvmpath = "/dev/$vg/del-$name";
> -            print "zero-out data on image $name ($lvmpath)\n";
> +
> +            my $discard_action;
> +            if ($scfg->{saferemove} && $on_remove_opts->{'discard'}) {

nit: can just be $on_remove_opts->{discard}

> +                $discard_action = 'zero-out data and discard (TRIM)';
> +            } elsif ($scfg->{saferemove}) {
> +                $discard_action = 'zero-out data on';
> +            } elsif ($on_remove_opts->{'discard'}) {

nit: same as above

> +                $discard_action = 'discard (TRIM)';
> +            }
> +            print "$discard_action image $name ($lvmpath)\n";
>  
>              my $cmd_activate = ['/sbin/lvchange', '-aly', $lvmpath];
>              run_command(
> @@ -367,8 +383,18 @@ my sub free_lvm_volumes_locked {
>                  $cmd_activate,
>                  errmsg => "can't refresh LV '$lvmpath' to zero-out its data",

This error message and the one a few lines above it (can't active ...)
should also be updated because they're otherwise a bit misleading. Since
the cleanup worker is now also called when using just `discard` without
`saferemove`, data is not always zeroed-out.

>              );
> +            syslog('info', "starting to $discard_action $name ($lvmpath)")
> +                if defined($discard_action);
>  
> -            $secure_delete_cmd->($lvmpath);
> +            if ($scfg->{saferemove}) {
> +                print "zero-out data on image $name ($lvmpath)\n";

nit: not sure if the prints inside these if-blocks are necessary.
Because there's already the $discard_action being printed above and then
you'd have output like

    zero-out data and discard (TRIM) image vm-100-disk-0 (/dev/.../del-vm-100-disk-0)
    zero-out data on image vm-100-disk-0 (/dev/.../del-vm-100-disk-0)
    discard image vm-100-disk-0 (/dev/.../del-vm-100-disk-0)

> +                $secure_delete_cmd->($lvmpath);
> +            }
> +            if ($on_remove_opts->{'discard'}) {

nit: can also just be $on_remove_opts->{discard}

> +                print "discard image $name ($lvmpath)\n";
> +                eval { run_command(['/sbin/blkdiscard', $lvmpath]); };

If blkdiscard fails for some reason, I think it'd make sense to
explicitly inform the user in the warning message that the disk space
was not reclaimed. Otherwise they'd "just" get a reason why it failed,
while the consequences of this might not be clear.

> +                warn $@ if $@;
> +            }
>  
>              $class->cluster_lock_storage(
>                  $storeid,
> @@ -383,13 +409,13 @@ my sub free_lvm_volumes_locked {
>          }

[snip]




  reply	other threads:[~2026-06-08 14:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 13:04 [PATCH manager/storage v6 0/2] fix #7339: lvmthick: add option to free storage for deleted VMs Lukas Sichert
2026-05-22 13:04 ` [PATCH storage v6 1/2] fix #7339: lvmthick: add worker to free space of to be " Lukas Sichert
2026-06-08 14:06   ` Michael Köppl [this message]
2026-05-22 13:04 ` [PATCH manager v6 2/2] fix #7339: lvmthick: ui: add UI option to free storage Lukas Sichert
2026-06-08 14:06   ` Michael Köppl
2026-06-08 14:43 ` [PATCH manager/storage v6 0/2] fix #7339: lvmthick: add option to free storage for deleted VMs Michael Köppl

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=DJ3Q4W866087.6HIM5KM2APD1@proxmox.com \
    --to=m.koeppl@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal