From: "Michael Köppl" <m.koeppl@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 12:55:57 +0200 [thread overview]
Message-ID: <DJMBV7RMN1VI.1IWTHQAGI0CRW@proxmox.com> (raw)
In-Reply-To: <20260616101323.24981-3-l.sichert@proxmox.com>
On Tue Jun 16, 2026 at 12:13 PM CEST, Lukas Sichert wrote:
[snip]
> + # also don't remove the volume if blkdiscard fails, because otherwise the
> + # storage on a thinly-backed storage can't be reclaimed without removing the
> + # complete pool
> + if ($on_remove_opts->{discard} && !$scfg->{saferemove}) {
> + eval { run_command(['/sbin/blkdiscard', $lvmpath]); };
> + $err = $@ if $@;
I'm not quite sure regarding this one. I understand why it's there, but
I think the case where discard is simply not supported should maybe be
covered separately. Consider the following scenario:
- Block device that does not support discard
(/sys/block/<device>/queue/discard_max_bytes is 0)
- Create LVM storage on it (discard on, saferemove off)
- pvcreate /dev/<device>
- vgcreate vgtest <device>
- pvesm add lvm test --vgname vgtest --content images
- pvesm set test --on-volume-remove discard=1
- Allocate a disk image (pvesm alloc test 9999 vm-disk-0 1G)
If you now call `pvesm free test:vm-disk-0`, the task will show an
"Operation not supported" warning for blkdiscard. dev-vm-disk-0
remains, the space is not cleared, which is expected. But if I now try
to `alloc` again and `pvesm free` again, this will always fail due to
a naming collision with the leftover `del-vm-disk-0`.
One could argue that enabling discard for a device that does not support
it is a user error, but on the other hand the "fallout" from this
mistake is IMO at least annoying and it's relatively easy to prevent by
e.g. explicitly checking /sys/block/<dev>/queue/discard_max_bytes and
warning the user that the operation is not supported, but carrying on
with the regular removal of the volume? Because if the block device does
not support discard, there's nothing to be done anyway to reclaim the
space later, no? If the device does not support discard today, it won't
support it tomorrow. Although the best UX would probably be to perform
this check when the storage is created to prevent the discard option
from being set if it's not supported?
> + }
>
> if (!$err) {
> $class->cluster_lock_storage(
> @@ -449,13 +486,13 @@ my sub free_lvm_volumes_locked {
> }
> };
[snip]
next prev parent reply other threads:[~2026-06-30 10:56 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 [this message]
2026-06-30 12:14 ` Fiona Ebner
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=DJMBV7RMN1VI.1IWTHQAGI0CRW@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