[pve-devel] [PATCH] Bug Fix 602

Wolfgang Link w.link at proxmox.com
Thu Feb 26 11:43: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 |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 5cbd1b2..9609dd1 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -291,7 +291,32 @@ sub zfs_create_zvol {
 sub zfs_delete_zvol {
     my ($class, $scfg, $zvol) = @_;
 
-    $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol");
+    open(STDERR, ">/tmp/zfslog.txt");
+    eval {  $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol")};
+    close STDERR;
+    if ($@) {
+	my $error = $@;
+	open(my $fh,"<" ,"/tmp/zfslog.txt");
+
+	$/ = undef;
+	my $msg = <$fh>;
+	close $fh; 
+
+	unlink "/tmp/zfslog.txt";
+
+	if ($msg =~ m/dataset is busy/) {
+
+	    for(my $i = 0; $error && $i < 5; $i++){
+		sleep(1);
+		eval {  $class->zfs_request($scfg, undef, 'destroy', '-r', "$scfg->{pool}/$zvol")};
+		$error = $@;
+	    }
+	    die print $msg.$error if $error;
+	} else {
+	    die $msg.$error;
+	}
+    }
+    unlink "/tmp/zfslog.txt";
 }
 
 sub zfs_list_zvol {
-- 
1.7.10.4





More information about the pve-devel mailing list