]> git.proxmox.com Git - pve-storage.git/commitdiff
Diskmanage: allow get_disks to take multiple disks
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 4 Jun 2019 10:35:22 +0000 (12:35 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 4 Jun 2019 10:51:44 +0000 (12:51 +0200)
we now expect the first parameter to be either a string with a single
disk, or an array ref with a list of disks

this way we can get the info of multiple disks simultaneously while
not iterating over all disks

this will be used to get the info for osd/db/wal disk

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/Diskmanage.pm

index a7a7e7018f040f938cf13555fd0a4120b1d09f02..281b378e5fdac79d6a24f41f5446ad7ec7bf5092 100644 (file)
@@ -416,7 +416,7 @@ sub is_iscsi {
 }
 
 sub get_disks {
-    my ($disk, $nosmart) = @_;
+    my ($disks, $nosmart) = @_;
     my $disklist = {};
 
     my $mounted = {};
@@ -440,14 +440,21 @@ sub get_disks {
 
     my $lvmlist = get_lvm_devices();
 
-    # we get cciss/c0d0 but need cciss!c0d0
-    if (defined($disk) && $disk =~ m|^cciss/|) {
-       $disk =~ s|cciss/|cciss!|;
+    my $disk_regex = ".*";
+    if (defined($disks)) {
+       if (!ref($disks)) {
+           $disks = [ $disks ];
+       } elsif (ref($disks) ne 'ARRAY') {
+           die "disks is not a string or array reference\n";
+       }
+       # we get cciss/c0d0 but need cciss!c0d0
+       map { s|cciss/|cciss!| } @$disks;
+
+       $disk_regex = "(?:" . join('|', @$disks) . ")";
     }
 
-    dir_glob_foreach('/sys/block', '.*', sub {
+    dir_glob_foreach('/sys/block', $disk_regex, sub {
        my ($dev) = @_;
-       return if defined($disk) && $disk ne $dev;
        # whitelisting following devices
        # hdX: ide block device
        # sdX: sd block device