volser: Restore Vol*ListOneVolume error handling
authorAndrew Deason <adeason@sinenomine.net>
Tue, 26 Mar 2013 22:26:23 +0000 (17:26 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 3 Apr 2013 11:27:56 +0000 (04:27 -0700)
In the 1.4 series, the volserver VolListOneVolume function always
returned success if the specified volume was found in any way, and
ENODEV otherwise. The VolXListOneVolume returned ENODEV if the volume
was not found, or if any error occurred.

DAFS (specifically, commit ed25934c1fe96b143715025b49104e75dce9a361)
changed these so they both behave the same way. That is, they both
return success if the volume was found at all, and ENODEV otherwise.

Commit 53cc2ebaea5e5488d5285f0d13ffa47069ee986f changed both of these
functions so that we always return an error on any attachment error.

These changes mean that a 'vos examine' for a volume with an existing
volume transaction now indicates that a volume is offline/unattached,
but in the 1.4 series, the volume was indicated as "busy".

So, restore the original 1.4 behavior of these functions, so the
volume status is reported as it always was. This effectively reverts
53cc2ebaea5e5488d5285f0d13ffa47069ee986f, and slightly changes the
post-DAFS code to look more like the 1.4 code. This also removes the
'code' variable from VolListOneVolume and adds an explicit comment
about what's going on, to make this a little more clear.

While changing the behavior of VolXListOneVolume to match that of
VolListOneVolume perhaps makes sense, for now just restore the exact
1.4 behavior, and make the function flow look a little more like the
1.4 code did. A future change may make them the same again.

Reported by Andy Malato.

Change-Id: I0e109ad97a1b1bd9b3b25677eb9744a4f7bd5412
Reviewed-on: http://gerrit.openafs.org/9679
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/volser/volprocs.c

index c2c2843..3c7cfbd 100644 (file)
@@ -2338,7 +2338,6 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid,
     DIR *dirp;
     VolumeId volid;
     int found = 0;
-    int code;
     volint_info_handle_t handle;
 
     volumeInfo->volEntries_val = calloc(1, sizeof(volintInfo));
@@ -2369,19 +2368,20 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid,
        handle.volinfo_type = VOLINT_INFO_TYPE_BASE;
        handle.volinfo_ptr.base = volumeInfo->volEntries_val;
 
-       code = GetVolInfo(partid,
-                         volid,
-                         pname,
-                         volname,
-                         &handle,
-                         VOL_INFO_LIST_SINGLE);
+       /* The return code from GetVolInfo is ignored; there is no error from
+        * it that results in the whole call being aborted. Any volume
+        * attachment failures are reported in 'status' field in the
+        * volumeInfo payload. */
+       GetVolInfo(partid,
+                  volid,
+                  pname,
+                  volname,
+                  &handle,
+                  VOL_INFO_LIST_SINGLE);
     }
 
     closedir(dirp);
-    if (found)
-        return code ? ENODEV: 0;
-    else
-        return ENODEV;
+    return (found) ? 0 : ENODEV;
 }
 
 /*------------------------------------------------------------------------
@@ -2477,6 +2477,7 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
     }
 
     if (found) {
+       int error;
 #ifndef AFS_PTHREAD_ENV
        IOMGR_Poll();
 #endif
@@ -2484,13 +2485,15 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
        handle.volinfo_type = VOLINT_INFO_TYPE_EXT;
        handle.volinfo_ptr.ext = a_volumeXInfoP->volXEntries_val;
 
-       code = GetVolInfo(a_partID,
-                         a_volID,
-                         pname,
-                         volname,
-                         &handle,
-                         VOL_INFO_LIST_SINGLE);
-
+       error = GetVolInfo(a_partID,
+                          a_volID,
+                          pname,
+                          volname,
+                          &handle,
+                          VOL_INFO_LIST_SINGLE);
+       if (!error) {
+           code = 0;
+       }
     }
 
     /*
@@ -2498,10 +2501,7 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
      * return the proper value.
      */
     closedir(dirp);
-    if (found)
-        return code ? ENODEV: 0;
-    else
-        return ENODEV;
+    return code;
 }                              /*SAFSVolXListOneVolume */
 
 /*returns all the volumes on partition partid. If flags = 1 then all the