]> git.proxmox.com Git - pve-storage.git/commitdiff
vdisk_list: only scan storages with the correct content type(s)
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 18 Jun 2021 10:59:35 +0000 (12:59 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 21 Jun 2021 09:21:45 +0000 (11:21 +0200)
The enabled check in the lower loop is now redundant and can be removed.

If storeid is provided, initialize the result hash accordingly, mainly for
backwards compatibility (needed by a caller in pve-manager's Ceph/Pools.pm and
the migration code in pve-container and qemu-server), but it also is less
surprising in general.

Remaining vdisk_list users that do not specify a content type are:
    1. pve-manager's Pool/Ceph.pm, but the content type for RBD can only be
       rootdir and images, so the storage is scanned (if enabled, same as
       before).
    2. pve-container migration
    3. qemu-server migration
For the latter two, it's planned to enforce content type, so the change is fine
too.

This also means that for iscsi(direct) plugins with content type 'none', i.e.
"use LUNs directly" does not return the list of images anymore, but that was
rather a bug anyways as they're not virtual disks then:
    0.0.0.scsi-36001405b8f2772e13a04b8e9390db13d
All of the remaining callers not using content types (see above) are fine with
that change too.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage.pm

index f2231f2f8c67beb40df19cc9ad907dc2badbbb72..ea887a496ab62d3fbd54fb61dd6641ef3d436e41 100755 (executable)
@@ -934,7 +934,7 @@ sub vdisk_list {
 
     storage_check_enabled($cfg, $storeid) if ($storeid);
 
-    my $res = {};
+    my $res = $storeid ? { $storeid => [] } : {};
 
     # prepare/activate/refresh all storages
 
@@ -961,12 +961,8 @@ sub vdisk_list {
 
     activate_storage_list($cfg, $storage_list, $cache);
 
-    # FIXME PVE 7.0: only scan storages with the correct content types
-    my $scan = defined($ctype) ? $storage_list : [ keys %{$ids} ];
-
-    foreach my $sid (@{$scan}) {
+    for my $sid ($storage_list->@*) {
        next if $storeid && $storeid ne $sid;
-       next if !storage_check_enabled($cfg, $sid, undef, 1);
 
        my $scfg = $ids->{$sid};
        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});