volser-directoryless-incremental-dumps-20070719
authorDerrick Brashear <shadow@dementia.org>
Thu, 19 Jul 2007 19:51:55 +0000 (19:51 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 19 Jul 2007 19:51:55 +0000 (19:51 +0000)
add an rpc, give vos a switch, allow incrementals which do not include directory objects

src/volser/volint.xg
src/volser/volprocs.c
src/volser/volser_prototypes.h
src/volser/vos.c
src/volser/vsprocs.c

index 99d0180..46bd974 100644 (file)
@@ -49,6 +49,10 @@ statindex 16
 #define            VOLFORWARDMULTIPLE  128
 #define     VOLCONVERTRO        65536
 #define     VOLGETSIZE          65537
+#define     VOLDUMPV2           65538
+
+/* Bits for flags for DumpV2 */
+%#define     VOLDUMPV2_OMITDIRS 1
 
 const SIZE = 1024;
 
@@ -408,3 +412,10 @@ proc GetSize(
   IN afs_int32 fromDate,
   OUT struct volintSize *size
 ) = VOLGETSIZE;
+
+proc DumpV2(
+  IN afs_int32 fromTrans,
+  IN afs_int32 fromDate,
+  IN afs_int32 flags
+) split = VOLDUMPV2;
+
index 9b5f158..1b772b8 100644 (file)
@@ -1279,13 +1279,23 @@ SAFSVolDump(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate)
 {
     afs_int32 code;
 
-    code = VolDump(acid, fromTrans, fromDate);
+    code = VolDump(acid, fromTrans, fromDate, 0);
     osi_auditU(acid, VS_DumpEvent, code, AUD_LONG, fromTrans, AUD_END);
     return code;
 }
 
 afs_int32
-VolDump(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate)
+SAFSVolDumpV2(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate, afs_int32 flags)
+{
+    afs_int32 code;
+
+    code = VolDump(acid, fromTrans, fromDate, flags);
+    osi_auditU(acid, VS_DumpEvent, code, AUD_LONG, fromTrans, AUD_END);
+    return code;
+}
+
+afs_int32
+VolDump(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate, afs_int32 flags)
 {
     int code = 0;
     register struct volser_trans *tt;
@@ -1303,7 +1313,8 @@ VolDump(struct rx_call *acid, afs_int32 fromTrans, afs_int32 fromDate)
     }
     strcpy(tt->lastProcName, "Dump");
     tt->rxCallPtr = acid;
-    code = DumpVolume(acid, tt->volume, fromDate, 1);  /* squirt out the volume's data, too */
+    code = DumpVolume(acid, tt->volume, fromDate, (flags & VOLDUMPV2_OMITDIRS)
+                     ? 0 : 1); /* squirt out the volume's data, too */
     if (code) {
        tt->rxCallPtr = (struct rx_call *)0;
        TRELE(tt);
index 07c49c8..832f1da 100644 (file)
@@ -47,7 +47,7 @@ extern int UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
 extern void dump_sig_handler(int x);
 extern int UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver,
                         afs_int32 afrompart, afs_int32 fromdate,
-                        afs_int32(*DumpFunction) (), char *rock);
+                        afs_int32(*DumpFunction) (), char *rock, afs_int32 flags);
 extern int UV_RestoreVolume(afs_int32 toserver, afs_int32 topart,
                            afs_int32 tovolid, char tovolname[], int flags,
                            afs_int32(*WriteData) (), char *rock);
index d02e512..b3a3991 100644 (file)
@@ -2806,7 +2806,7 @@ DumpVolume(as)
      register struct cmd_syndesc *as;
 
 {
-    afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
+    afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
     char filename[MAXPATHLEN];
     struct nvldbentry entry;
 
@@ -2866,14 +2866,20 @@ DumpVolume(as)
        strcpy(filename, "");
     }
 
+    flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
+retry_dump:
     if (as->parms[5].items) {
        code =
            UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
-                               DumpFunction, filename);
+                               DumpFunction, filename, flags);
     } else {
        code =
            UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
-                         filename);
+                         filename, flags);
+    }
+    if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
+       flags &= ~VOLDUMPV2_OMITDIRS;
+       goto retry_dump;
     }
     if (code) {
        PrintDiagnostics("dump", code);
@@ -5822,6 +5828,8 @@ main(argc, argv)
     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
     cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
                "dump a clone of the volume");
+    cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
+               "omit unchanged directories from an incremental dump");
     COMMONPARMS;
 
     ts = cmd_CreateSyntax("restore", RestoreVolume, 0, "restore a volume");
index f2521ee..e6f5089 100644 (file)
@@ -3835,12 +3835,13 @@ dump_sig_handler(int x)
  */
 int
 UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
-             afs_int32 fromdate, afs_int32(*DumpFunction) (), char *rock)
+             afs_int32 fromdate, afs_int32(*DumpFunction) (), char *rock,
+             afs_int32 flags)
 {
     struct rx_connection *fromconn = (struct rx_connection *)0;
     struct rx_call *fromcall = (struct rx_call *)0;
     afs_int32 fromtid = 0, rxError = 0, rcode = 0;
-    afs_int32 code, error = 0;
+    afs_int32 code, error = 0, retry = 0;
     time_t tmv = fromdate;
 
     if (setjmp(env))
@@ -3870,23 +3871,28 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     fromcall = rx_NewCall(fromconn);
 
     VPRINT1("Starting volume dump on volume %u...", afromvol);
-    code = StartAFSVolDump(fromcall, fromtid, fromdate);
+    if (flags & VOLDUMPV2_OMITDIRS) 
+       code = StartAFSVolDumpV2(fromcall, fromtid, fromdate, flags);
+    else
+      retryold:
+       code = StartAFSVolDump(fromcall, fromtid, fromdate);
     EGOTO(error_exit, code, "Could not start the dump process \n");
     VDONE;
 
     VPRINT1("Dumping volume %u...", afromvol);
     code = DumpFunction(fromcall, rock);
+    if (code == RXGEN_OPCODE) 
+       goto error_exit;
     EGOTO(error_exit, code, "Error while dumping volume \n");
     VDONE;
 
   error_exit:
     if (fromcall) {
        code = rx_EndCall(fromcall, rxError);
-       if (code) {
+       if (code && code != RXGEN_OPCODE) 
            fprintf(STDERR, "Error in rx_EndCall\n");
-           if (!error)
-               error = code;
-       }
+       if (code && !error)
+           error = code;
     }
     if (fromtid) {
        VPRINT1("Ending transaction on volume %u...", afromvol);
@@ -3902,7 +3908,10 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
     if (fromconn)
        rx_DestroyConnection(fromconn);
 
-    PrintError("", error);
+    if (retry)
+       goto retryold;
+    if (error != RXGEN_OPCODE)
+       PrintError("", error);
     return (error);
 }
 
@@ -3915,7 +3924,7 @@ UV_DumpVolume(afs_int32 afromvol, afs_int32 afromserver, afs_int32 afrompart,
 int
 UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
                    afs_int32 afrompart, afs_int32 fromdate,
-                   afs_int32(*DumpFunction) (), char *rock)
+                   afs_int32(*DumpFunction) (), char *rock, afs_int32 flags)
 {
     struct rx_connection *fromconn = (struct rx_connection *)0;
     struct rx_call *fromcall = (struct rx_call *)0;
@@ -3998,7 +4007,10 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
     fromcall = rx_NewCall(fromconn);
 
     VPRINT1("Starting volume dump from cloned volume %u...", clonevol);
-    code = StartAFSVolDump(fromcall, clonetid, fromdate);
+    if (flags & VOLDUMPV2_OMITDIRS) 
+       code = StartAFSVolDumpV2(fromcall, clonetid, fromdate, flags);
+    else
+       code = StartAFSVolDump(fromcall, clonetid, fromdate);
     EGOTO(error_exit, code, "Could not start the dump process \n");
     VDONE;