[pve-devel] [PATCH_V3] Bug Fix 602
now zfs will wait 5 sec if error msg is dataset is busy Signed-off-by: Wolfgang Link w.l...@proxmox.com --- PVE/Storage/ZFSPoolPlugin.pm | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 5cbd1b2..999e43e 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -166,7 +166,7 @@ sub zfs_request { $msg .= $line\n; }; -run_command($cmd, outfunc = $output, timeout = $timeout); +run_command($cmd, errmsg = ERROR, outfunc = $output, timeout = $timeout); return $msg; } @@ -291,7 +291,26 @@ sub zfs_create_zvol { sub zfs_delete_zvol { my ($class, $scfg, $zvol) = @_; -$class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol); +my $ret; +eval {$ret = $class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol);}; +$ret = $@ if $@; + +if ($ret =~ m/^ERROR:(.*)/) { + + if ($ret =~ m/.*: dataset is busy.*/){ + + for(my $i = 0; $ret $i 5; $i++){ + sleep(1); + + eval {$ret = $class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol);}; + $ret = $@ if $@; + } + + die $ret if $ret; + } else { + die $ret; + } +} } sub zfs_list_zvol { -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH_V3] Bug Fix 602
On 03/06/2015 05:57 AM, Dietmar Maurer wrote: So this regex will never match! oh, just saw that the colon is added inside run_command - so just ignore this. + + if ($ret =~ m/.*: dataset is busy.*/){ + + for(my $i = 0; $ret $i 5; $i++){ + sleep(1); + + eval {$ret = $class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol);}; Also, this is a code duplication, and can be avoided easily. + $ret = $@ if $@; + } + + die $ret if $ret; + } else { + die $ret; + } +} } sub zfs_list_zvol { -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH_V3] Bug Fix 602
-run_command($cmd, outfunc = $output, timeout = $timeout); +run_command($cmd, errmsg = ERROR, outfunc = $output, timeout = $timeout); Note: you use ERROR here - without collon. return $msg; } @@ -291,7 +291,26 @@ sub zfs_create_zvol { sub zfs_delete_zvol { my ($class, $scfg, $zvol) = @_; -$class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol); +my $ret; +eval {$ret = $class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol);}; +$ret = $@ if $@; + +if ($ret =~ m/^ERROR:(.*)/) { So this regex will never match! + + if ($ret =~ m/.*: dataset is busy.*/){ + + for(my $i = 0; $ret $i 5; $i++){ + sleep(1); + + eval {$ret = $class-zfs_request($scfg, undef, 'destroy', '-r', $scfg-{pool}/$zvol);}; Also, this is a code duplication, and can be avoided easily. + $ret = $@ if $@; + } + + die $ret if $ret; + } else { + die $ret; + } +} } sub zfs_list_zvol { -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel