]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Always check VInitVolumePackage2 return code
authorAndrew Deason <adeason@sinenomine.net>
Mon, 11 Jan 2010 19:36:32 +0000 (13:36 -0600)
committerDerrick Brashear <shadow|account-1000005@unknown>
Thu, 14 Jan 2010 15:07:06 +0000 (07:07 -0800)
Some programs were not checking the return code of VInitVolumePackage2.
Although some programs do not care so much if we fail to properly init
the volume package (SYNC debug tools), at the very least log/print an
error, so it doesn't silently fail.

Other programs are changed to exit when VInitVolumePackage2 fail, so
e.g. salvages don't accidentally cause corruption on 'logging'-mounted
UFS partitions.

In any case, ensure the return code is always checked anywhere it is
called.

Change-Id: I164d5920a5ea2dd7e5ed9ad4ccc578e9bdf0db0b
Reviewed-on: http://gerrit.openafs.org/1090
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/tsalvaged/salvsync-debug.c
src/vol/fssync-debug.c
src/vol/salvaged.c
src/vol/salvager.c
src/vol/test/testpart.c
src/volser/vol-dump.c
src/volser/volmain.c

index f3775350e41221b334ebed812984bcbe6a3132e2..b802c587864da9634b48d4cf552a54c5cc28c09e 100644 (file)
@@ -186,7 +186,13 @@ common_prolog(struct cmd_syndesc * as, struct state * state)
 #endif
 
     VOptDefaults(debugUtility, &opts);
-    VInitVolumePackage2(debugUtility, &opts);
+    if (VInitVolumePackage2(debugUtility, &opts)) {
+       /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
+        * but we don't really care, since all we're doing is trying to use
+        * SALVSYNC */
+       fprintf(stderr, "errors encountered initializing volume package, but "
+                       "trying to continue anyway\n");
+    }
     DInit(1);
 
     if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */
index c746ed0c531c86b9d9ae8e62d51fb7132d2c90f1..a5414d549698ef20f4706c355136f1fb72bfcf8b 100644 (file)
@@ -232,7 +232,13 @@ common_prolog(struct cmd_syndesc * as, struct state * state)
 #endif
 
     VOptDefaults(debugUtility, &opts);
-    VInitVolumePackage2(debugUtility, &opts);
+    if (VInitVolumePackage2(debugUtility, &opts)) {
+       /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
+        * but we don't really care, since all we're doing is trying to use
+        * FSSYNC */
+       fprintf(stderr, "errors encountered initializing volume package, but "
+                       "trying to continue anyway\n");
+    }
     DInit(1);
 
     if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */
index 2dbbc18e01aa8585356328112d3d7f1d3a95d2f7..64680fe579aaef4673d4675703882296eb2d68c7 100644 (file)
@@ -423,7 +423,13 @@ SalvageClient(VolumeId vid, char * pname)
     VolumePackageOptions opts;
 
     VOptDefaults(volumeUtility, &opts);
-    VInitVolumePackage2(volumeUtility, &opts);
+    if (VInitVolumePackage2(volumeUtility, &opts)) {
+       /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
+        * but we don't really care, since all we're doing is trying to use
+        * SALVSYNC */
+       fprintf(stderr, "errors encountered initializing volume package, but "
+                       "trying to continue anyway\n");
+    }
     SALVSYNC_clientInit();
     
     code = SALVSYNC_SalvageVolume(vid, pname, SALVSYNC_SALVAGE, SALVSYNC_OPERATOR, 0, NULL);
@@ -511,7 +517,10 @@ SalvageServer(void)
 
     /* initialize things */
     VOptDefaults(salvageServer, &opts);
-    VInitVolumePackage2(salvageServer, &opts);
+    if (VInitVolumePackage2(salvageServer, &opts)) {
+       Log("Shutting down: errors encountered initializing volume package\n");
+       Exit(1);
+    }
     DInit(10);
     queue_Init(&pending_q);
     queue_Init(&log_cleanup_queue);
index 093bbac48c89364b62a2999ccaa2fba7a017bb36..5f305c89027cde821ea488b9b1faa4f452ca7bfe 100644 (file)
@@ -324,7 +324,10 @@ handleit(struct cmd_syndesc *as, void *arock)
     }
 
     VOptDefaults(pt, &opts);
-    VInitVolumePackage2(pt, &opts);
+    if (VInitVolumePackage2(pt, &opts)) {
+       Log("errors encountered initializing volume package; salvage aborted\n");
+       Exit(1);
+    }
     DInit(10);
 #ifdef AFS_NT40_ENV
     if (myjob.cj_number != NOT_CHILD) {
index 9044c6c59817316fea34b8b71fade6d70bfec087..dc29b80847b0a287ad98d0934aee02a65662ed1f 100644 (file)
@@ -41,7 +41,10 @@ main(argc, argv)
     VolumePackageOptions opts;
 
     VOptDefaults(1, &opts);
-    VInitVolumePackage2(1, &opts);
+    if (VInitVolumePackage2(1, &opts)) {
+       printf("errors encountered initializing volume package\n");
+       exit(-1);
+    }
     VPrintDiskStats();
 
 }
index ae743ad2c97623faa7b9e6715788f1ad8a2976d0..c53ad37c96c8c2054f8bd8316626fcbed2ad90bd 100644 (file)
@@ -302,7 +302,10 @@ main(int argc, char **argv)
     VolumePackageOptions opts;
 
     VOptDefaults(volumeUtility, &opts);
-    VInitVolumePackage2(volumeUtility, &opts);
+    if (VInitVolumePackage2(volumeUtility, &opts)) {
+       fprintf(stderr, "errors encountered initializing volume package, but "
+                       "trying to continue anyway\n");
+    }
 
     ts = cmd_CreateSyntax(NULL, handleit, NULL,
                          "Dump a volume to a 'vos dump' format file without using volserver");
index 46e85412968fe157a6651301ea3b2580b7cdeaf0..f9024f68eda00212085696f737d5645699a1da94 100644 (file)
@@ -426,7 +426,10 @@ main(int argc, char **argv)
     OpenLog(AFSDIR_SERVER_VOLSERLOG_FILEPATH);
 
     VOptDefaults(volumeServer, &opts);
-    VInitVolumePackage2(volumeServer, &opts);
+    if (VInitVolumePackage2(volumeServer, &opts)) {
+       Log("Shutting down: errors encountered initializing volume package\n");
+       exit(1);
+    }
     /* For nuke() */
     Lock_Init(&localLock);
     DInit(40);