[Zetaback-devel] [zetaback commit] r181 - branches/sendr

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Thu Mar 31 16:07:44 EDT 2011


Author: mark
Date: 2011-03-31 16:07:44 -0400 (Thu, 31 Mar 2011)
New Revision: 181

Modified:
   branches/sendr/zetaback.in
   branches/sendr/zetaback_agent.in
Log:
Correctly detect whether to use deferred destroy with old zpools on newer systems

Modified: branches/sendr/zetaback.in
===================================================================
--- branches/sendr/zetaback.in	2011-03-11 17:27:30 UTC (rev 180)
+++ branches/sendr/zetaback.in	2011-03-31 20:07:44 UTC (rev 181)
@@ -19,7 +19,8 @@
             $RESTORE $RESTORE_HOST $RESTORE_ZFS $TIMESTAMP
             $LIST $SUMMARY $SUMMARY_EXT $SUMMARY_VIOLATORS
             $FORCE_FULL $FORCE_INC $EXPUNGE $NEUTERED $ZFS
-            $SHOW_FILENAMES $ARCHIVE $VERSION $HELP $DEFER_DESTROY/;
+            $SHOW_FILENAMES $ARCHIVE $VERSION $HELP $DEFER_DESTROY
+            @ZPOOL_VERSION/;
 $version_string = q$URL$;
 $version_string =~ s#/branches/#/b#;
 $version_string =~ s#^.*/([^/]+)/[^/]+$#$1#;
@@ -453,8 +454,9 @@
 sub config_get($$) {
   return $conf{$_[0]}->{$_[1]} || $conf{'default'}->{$_[1]};
 }
-sub defer_destroy_enabled() {
-  # Check for deferred destroy support by looking for the validity of the
+sub defer_destroy_enabled {
+  my $pool = shift;
+  # Check for OS deferred destroy support by looking for the validity of the
   # defer_destroy property.
   if (!defined($DEFER_DESTROY)) {
     # We don't care about the output, just the return code
@@ -466,9 +468,23 @@
       $DEFER_DESTROY = 1;
     }
   }
+  # Check the zpool version if provided to make sure we support deferred
+  # destroy on the pool also
+  if ($DEFER_DESTROY && defined($pool)) {
+    if (!defined($ZPOOL_VERSION[$pool])) {
+      my $out = `zpool get version $pool`;
+      my @lines = split(/\n/, $out);
+      my @fields = split(/ +/, $lines[1]);
+      $ZPOOL_VERSION[$pool] = $fields[2];
+    }
+    if ($ZPOOL_VERSION[$pool] >= 18) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
   return $DEFER_DESTROY;
 }
-
 sub fs_encode($) {
   my $d = shift;
   my @parts = split('@', $d);
@@ -735,7 +751,7 @@
         my ($out, $fslist);
         print STDERR "Destroying any existing clones\n" if $DEBUG;
         my $defer = '';
-        if (defer_destroy_enabled()) {
+        if (defer_destroy_enabled((split(/\//, $storefs))[0])) {
           $defer = '-d';
         }
         $out = `__ZFS__ destroy $defer -r $storefs/cloned/$fsname 2>&1`;
@@ -1008,7 +1024,7 @@
           unlink($filename) || print "ERROR: unlink $filename: $?\n";
         } elsif ($dataset) {
           my $defer = '';
-          if (defer_destroy_enabled()) {
+          if (defer_destroy_enabled((split(/\//, $dataset))[0])) {
             $defer = '-d';
           }
           if (config_get($host, 'dataset_recursive') == 1) {

Modified: branches/sendr/zetaback_agent.in
===================================================================
--- branches/sendr/zetaback_agent.in	2011-03-11 17:27:30 UTC (rev 180)
+++ branches/sendr/zetaback_agent.in	2011-03-31 20:07:44 UTC (rev 181)
@@ -11,7 +11,8 @@
 
 use vars qw/%conf $version_string
             $PREFIX $CONF $LIST $FULL $SNAP $ZFS $BASE $RESTORE $VERSION
-            $BUG_6343779 $NEEDSFD $DSET $DSET_RECURSE $DEFER_DESTROY/;
+            $BUG_6343779 $NEEDSFD $DSET $DSET_RECURSE $DEFER_DESTROY
+            @ZPOOL_VERSION/;
 $version_string = '0.1';
 $PREFIX = q^__PREFIX__^;
 $CONF = qq^$PREFIX/etc/zetaback_agent.conf^;
@@ -218,8 +219,9 @@
 while(<CONF>) { /^\s*([^#](?:\S*)?)\s*=\s*(\S+)/ && ($conf{lc($1)} = $2); }
 close(CONF);
 
-sub defer_destroy_enabled() {
-  # Check for deferred destroy support by looking for the validity of the
+sub defer_destroy_enabled($) {
+  my $pool = shift;
+  # Check for OS deferred destroy support by looking for the validity of the
   # defer_destroy property.
   if (!defined($DEFER_DESTROY)) {
     # We don't care about the output, just the return code
@@ -231,7 +233,20 @@
       $DEFER_DESTROY = 1;
     }
   }
-  return $DEFER_DESTROY;
+  # Check the zpool version to make sure we support deferred destroy in that
+  # also
+  if ($DEFER_DESTROY) {
+    if (!defined($ZPOOL_VERSION[$pool])) {
+      my $out = `zpool get version $pool`;
+      my @lines = split(/\n/, $out);
+      my @fields = split(/ +/, $lines[1]);
+      $ZPOOL_VERSION[$pool] = $fields[2];
+    }
+    if ($ZPOOL_VERSION[$pool] >= 18) {
+        return 1;
+    }
+  }
+  return 0;
 }
 
 sub zfs_agent_remove_snap {
@@ -247,7 +262,7 @@
   }
 
   my $defer = '';
-  if (defer_destroy_enabled()) {
+  if (defer_destroy_enabled((split(/\//, $target))[0])) {
     $defer = '-d';
   }
   if ($DSET_RECURSE) {



More information about the Zetaback-devel mailing list