[pve-devel] [PATVH_V2] Bug Fix 602

Wolfgang Link w.link at proxmox.com
Tue Mar 3 13:17:47 CET 2015


now zfs will wait 5 sec if error msg is "dataset is busy"

Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/Storage/ZFSPoolPlugin.pm |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 5cbd1b2..0f666b0 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -166,7 +166,16 @@ sub zfs_request {
         $msg .= "$line\n";
     };
 
-    run_command($cmd, outfunc => $output, timeout => $timeout);
+    if ($method eq "destroy") {
+
+	eval {run_command($cmd, errmsg => 1, outfunc => $output, timeout => $timeout);};
+	
+	if(my $err = $@) { 
+	    return "ERROR $err"; 
+	}
+    } else {
+	run_command($cmd, outfunc => $output, timeout => $timeout); 
+    }
 
     return $msg;
 }
@@ -291,7 +300,22 @@ sub zfs_create_zvol {
 sub zfs_delete_zvol {
     my ($class, $scfg, $zvol) = @_;
 
-    $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol");
+    my $ret = $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol");
+
+    if ($ret =~ m/^ERROR (.*)/) {
+
+	if ($ret =~ m/.*dataset is busy.*/){
+
+	    for(my $i = 0; $ret && $i < 5; $i++){
+		sleep(1);
+		$ret =  $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol");
+	    }
+
+	    die $ret if $ret;
+	} else {
+	    die "$ret";
+	}
+    }
 }
 
 sub zfs_list_zvol {
-- 
1.7.10.4





More information about the pve-devel mailing list