[pve-devel] [PATCH storage 2/5] Diskmanage: allow get_disks to take multiple disks
Dominik Csapak
d.csapak at proxmox.com
Tue Jun 4 09:21:14 CEST 2019
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 at proxmox.com>
---
PVE/Diskmanage.pm | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index a7a7e70..daad6df 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -416,7 +416,7 @@ sub is_iscsi {
}
sub get_disks {
- my ($disk, $nosmart) = @_;
+ my ($disks, $nosmart) = @_;
my $disklist = {};
my $mounted = {};
@@ -440,14 +440,24 @@ 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 $path = ".*";
+ if (defined($disks)) {
+ if (!ref($disks) || ref($disks) ne 'ARRAY') {
+ $disks = [$disks];
+ }
+
+ for my $disk (@$disks) {
+ # we get cciss/c0d0 but need cciss!c0d0
+ if (defined($disk) && $disk =~ m|^cciss/|) {
+ $disk =~ s|cciss/|cciss!|;
+ }
+ }
+
+ $path = "(?:" . join('|', @$disks) . ")";
}
- dir_glob_foreach('/sys/block', '.*', sub {
+ dir_glob_foreach('/sys/block', $path, sub {
my ($dev) = @_;
- return if defined($disk) && $disk ne $dev;
# whitelisting following devices
# hdX: ide block device
# sdX: sd block device
--
2.11.0
More information about the pve-devel
mailing list