[pve-devel] [PATCH v2 storage 3/6] diskmanage: don't set usage for unused partitions

Fabian Ebner f.ebner at proxmox.com
Wed Oct 6 11:18:43 CEST 2021


The disk type is already 'partition' so there's no additional
information here. And it would need to serve as a code-word for
unused partitions. The cleaner approach is to not set the usage.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

No changes from v1.

Was not a smart decision back then...If this is considered a breaking
change for the disk list API call, I'll go for a different approach of
course, but AFAICS it would be one of:
1. Keep usage 'partition', but also return the unused partitions when
'include-partitions=1,type=unused', and have disk_is_used not complain
about usage 'partition'.
2. Add a new type filter/extend it so it can handle multiple types,
i.e. type=unused,partition.
3. Request all disks in the frontend and filter there.

 PVE/Diskmanage.pm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index 5041fb3..c896c5a 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -661,7 +661,7 @@ sub get_disks {
 	    # for devices, this check is done explicitly later
 	    return 'Device Mapper' if !dir_is_empty("$sysdir/holders");
 
-	    return 'partition';
+	    return; # unused partition
 	};
 
 	my $collect_ceph_info = sub {
@@ -730,7 +730,6 @@ sub get_disks {
 	my $used = $determine_usage->($devpath, $sysdir, 0);
 	if (!$include_partitions) {
 	    foreach my $part (sort keys %{$partitions}) {
-		next if $partitions->{$part}->{used} eq 'partition';
 		$used //= $partitions->{$part}->{used};
 	    }
 	} else {
-- 
2.30.2






More information about the pve-devel mailing list