[pve-devel] r5129 - pve-storage/pve2
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Sep 14 08:58:47 CEST 2010
Author: dietmar
Date: 2010-09-14 06:58:47 +0000 (Tue, 14 Sep 2010)
New Revision: 5129
Modified:
pve-storage/pve2/ChangeLog
pve-storage/pve2/Storage.pm
Log:
* Storage.pm (storage_info): better caching - avoid timeout bug
with large number of VGs.
Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog 2010-09-13 12:19:14 UTC (rev 5128)
+++ pve-storage/pve2/ChangeLog 2010-09-14 06:58:47 UTC (rev 5129)
@@ -1,3 +1,8 @@
+2010-09-14 Proxmox Support Team <support at proxmox.com>
+
+ * Storage.pm (storage_info): better caching - avoid timeout bug
+ with large number of VGs.
+
2010-09-07 Proxmox Support Team <support at proxmox.com>
* Storage.pm (parse_options): renamed from parse_options_new
Modified: pve-storage/pve2/Storage.pm
===================================================================
--- pve-storage/pve2/Storage.pm 2010-09-13 12:19:14 UTC (rev 5128)
+++ pve-storage/pve2/Storage.pm 2010-09-14 06:58:47 UTC (rev 5129)
@@ -60,29 +60,6 @@
return $hostname;
}
-PVE::JSONSchema::register_format('pve-vmid', \&verify_vmid);
-sub verify_vmid {
- my ($vmid, $noerr) = @_;
-
- if ($vmid !~ m/^[1-9][0-9]+$/) {
- return undef if $noerr;
- die "value does not look like a valid VM ID\n";
- }
- return $vmid;
-}
-
-PVE::JSONSchema::register_format('pve-node', \&verify_node_name);
-sub verify_node_name {
- my ($node, $noerr) = @_;
-
- # fixme: use better regex ?
- if ($node !~ m/^[[:alnum:]\-]+$/) {
- return undef if $noerr;
- die "value does not look like a valid node name\n";
- }
- return $node;
-}
-
sub read_cluster_config {
my ($filename, $fh) = @_;
@@ -2071,10 +2048,15 @@
__activate_storage_full ($cfg, $baseid, $session);
}
+ if (!$session->{vgs}) {
+ $session->{vgs} = lvm_vgs();
+ }
+
# In LVM2, vgscans take place automatically;
# this is just to be sure
- my $res = lvm_vgs ();
- if (!$res->{$scfg->{vgname}}) {
+ if ($session->{vgs} && !$session->{vgscaned} &&
+ !$session->{vgs}->{$scfg->{vgname}}) {
+ $session->{vgscaned} = 1;
my $cmd = ['/sbin/vgscan', '--ignorelockingfailure', '--mknodes'];
eval { run_command ($cmd, outfunc => sub {}); };
warn $@ if $@;
@@ -2116,9 +2098,9 @@
}
sub activate_storage_list {
- my ($cfg, $storeid_list) = @_;
+ my ($cfg, $storeid_list, $session) = @_;
- my $session = {};
+ $session = {} if !$session;
foreach my $storeid (@$storeid_list) {
__activate_storage_full ($cfg, $storeid, $session);
@@ -2255,11 +2237,25 @@
push @$slist, $storeid;
}
- eval { activate_storage_list ($cfg, $slist); };
+ my $session = {};
+ my $mountdata = '';
+ my $iscsi_sessions = {};
+ my $vgs = {};
+ if ($stypes->{lvm}) {
+ $session->{vgs} = lvm_vgs();
+ $vgs = $session->{vgs};
+ }
+ if ($stypes->{nfs}) {
+ $mountdata = read_proc_mounts();
+ $session->{mountdata} = $mountdata;
+ }
+ if ($stypes->{iscsi}) {
+ $iscsi_sessions = iscsi_session_list();
+ $session->{iscsi_sessions} = $iscsi_sessions;
+ }
+
+ eval { activate_storage_list ($cfg, $slist, $session); };
- my $mountdata = $stypes->{nfs} ? read_proc_mounts() : '';
- my $iscsi_sessions = $stypes->{iscsi} ? iscsi_session_list() : {};
-
foreach my $storeid (keys %$ids) {
my $scfg = $ids->{$storeid};
@@ -2296,12 +2292,10 @@
my $total = 0;
my $free = 0;
- my $res = lvm_vgs ();
+ if (defined ($vgs->{$vgname})) {
+ $total = $vgs->{$vgname}->{size};
+ $free = $vgs->{$vgname}->{free};
- if (defined ($res->{$vgname})) {
- $total = $res->{$vgname}->{size};
- $free = $res->{$vgname}->{free};
-
$info->{$storeid}->{total} = $total;
$info->{$storeid}->{avail} = $total;
$info->{$storeid}->{used} = $total - $free;
More information about the pve-devel
mailing list