Whamcloud - gitweb
all: significant overhaul by Peter to avoid problems with OBD metadata
[fs/lustre-release.git] / lustre / obdclass / obdcontrol
index 51f63df..6c5510e 100755 (executable)
@@ -66,8 +66,11 @@ eval 'sub OBD_SNAP_SETTABLE () { &_IOC(3, ord(\'f\'), 40, 4);}' unless
 eval 'sub OBD_SNAP_PRINTTABLE () { &_IOC(3, ord(\'f\'), 41, 4);}' unless
   defined(&OBD_SNAP_PRINTTABLE);
 
-eval 'sub OBD_SNAP_RUNIT () { &_IOC(3, ord(\'f\'), 42, 4);}' unless
-  defined(&OBD_SNAP_RUNIT);
+eval 'sub OBD_SNAP_DELETE() { &_IOC(3, ord(\'f\'), 42, 4);}' unless
+  defined(&OBD_SNAP_DELETE);
+eval 'sub OBD_SNAP_RESTORE() { &_IOC(3, ord(\'f\'), 43, 4);}' unless
+  defined(&OBD_SNAP_RESTORE);
+
 eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless
   defined(&OBD_EXT2_RUNIT);
 
@@ -109,7 +112,8 @@ my %commands =
      'snapprint' => {func => "SnapPrint", doc => "snapprint tableno"},
 
      'testext2iterator' => {func => "TestExt2Iterator", doc => ""},
-     'testsnapiterator' => {func => "TestSnapIterator", doc => ""},
+     'snapdelete' => {func => "SnapDelete", doc => "snapdelete: delete connected snap obd"},
+     'snaprestore' => {func => "SnapRestore", doc => "snaprestore: restore connected old snap to current"},
 
      'snaptable' => {func => "SnapShotTable", doc => "snaptable: build a snapshot table (interactive)"},
      'copy' => {func => "Copy", doc => "copy srcid tgtid"},
@@ -328,7 +332,7 @@ sub TestExt2Iterator {
 }
 
 
-sub TestSnapIterator { 
+sub SnapDelete { 
     my $err = 0;
     my $type = "snap_obd";
  
@@ -341,7 +345,33 @@ sub TestSnapIterator {
     print "type $type (len $len), datalen $datalen ($cl)\n";
     my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data);
 
-    my $rc = ioctl(DEV_OBD, &OBD_SNAP_RUNIT, $packed);
+    my $rc = ioctl(DEV_OBD, &OBD_SNAP_DELETE, $packed);
+
+    if (!defined $rc) {
+       print STDERR "ioctl failed: $!\n";
+    } elsif ($rc eq "0 but true") {
+       print "Finished (success)\n";
+    } else {
+       print "ioctl returned error code $rc.\n";
+    }
+}
+
+
+sub SnapRestore { 
+    my $err = 0;
+    my $type = "snap_obd";
+    my $prevcurrent = shift;
+    $data = pack("i", $prevcurrent); # where the previous current snapshot now lives
+    $datalen = 4;
+
+    my $len = length($type);
+    my $cl = length($data);
+    my $add = pack("p", $data);
+    print "type $type (len $len), datalen $datalen ($cl)\n";
+    my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data);
+
+    my $rc = ioctl(DEV_OBD, &OBD_SNAP_RESTORE, $packed);
 
     if (!defined $rc) {
        print STDERR "ioctl failed: $!\n";
@@ -353,6 +383,7 @@ sub TestSnapIterator {
 }
 
 
+
 sub SnapPrint { 
     my $err = 0;
     my $type = "snap_obd";