Signed-off-by: Udo Rader <udo.ra...@bestsolution.at> --- PVE/Storage/LunCmd/LIO.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/PVE/Storage/LunCmd/LIO.pm b/PVE/Storage/LunCmd/LIO.pm index 2d8c2ee..44dd508 100644 --- a/PVE/Storage/LunCmd/LIO.pm +++ b/PVE/Storage/LunCmd/LIO.pm @@ -1,4 +1,4 @@ -package PVE::Storage::LunCmd::LIO; +ackage PVE::Storage::LunCmd::LIO; # lightly based on code from Iet.pm # @@ -35,6 +35,8 @@ my @CONFIG_FILES = ( my $BACKSTORE = '/backstores/block'; my $SETTINGS = undef; +my $SETTINGS_TIMESTAMP = 0; +my $SETTINGS_MAXAGE = 15; # in seconds my @ssh_opts = ('-o', 'BatchMode=yes'); my @ssh_cmd = ('/usr/bin/ssh', @ssh_opts); @@ -348,7 +350,8 @@ my $modify_lun = sub { my ($scfg, $timeout, $method, @params) = @_; my $msg; - if ($delete_lun->($scfg, $timeout, $method, @params)) { + $msg = $delete_lun->($scfg, $timeout, $method, @params); + if ($msg) { $msg = $create_lun->($scfg, $timeout, $method, @params); } @@ -383,7 +386,13 @@ sub run_lun_command { my ($scfg, $timeout, $method, @params) = @_; # fetch configuration from target if we haven't yet - $parser->($scfg) unless $SETTINGS; + # or if our configuration is stale + my $timediff = time - $SETTINGS_TIMESTAMP; + if ( ! $SETTINGS || $timediff > $SETTINGS_MAXAGE ) { + $SETTINGS_TIMESTAMP = time; + $parser->($scfg); + } + my $cmdmap = $get_lun_cmd_map->($method); my $msg = $cmdmap->{cmd}->($scfg, $timeout, $method, @params); -- 2.17.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel