]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced: Correct unblessed attach2 errors
authorAndrew Deason <adeason@sinenomine.net>
Wed, 28 Jul 2010 22:10:10 +0000 (17:10 -0500)
committerDerrick Brashear <shadow@dementia.org>
Thu, 29 Jul 2010 15:50:02 +0000 (08:50 -0700)
Don't set the vp to NULL; instead just go to the general error
handling code. When a volume is not blessed, we just want it to go
offline, not go into an error state. Furthermore, we must free the
volume header when nUsers is set to 0, so manually do so when we do
not call VRequestSalvage_r.

Change-Id: I3ccd61ac219e092a5c9ee52cd563d007bc20a1a1
Reviewed-on: http://gerrit.openafs.org/2476
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/vol/volume.c

index d08fc8034be949e856934537255dad5a31d4c254..2fc88ab2e201488a928463f29084210e04002d60 100644 (file)
@@ -3072,6 +3072,12 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
      * cleanup? */
     int forcefree = 0;
 
+#ifdef AFS_DEMAND_ATTACH_FS
+    /* in the case of an error, to what state should the volume be
+     * transitioned? */
+    VolState error_state = VOL_STATE_ERROR;
+#endif /* AFS_DEMAND_ATTACH_FS */
+
     *ec = 0;
 
     vp->vnodeIndex[vLarge].handle = NULL;
@@ -3328,24 +3334,34 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
        }
        if (!V_inUse(vp)) {
            *ec = VNOVOL;
+#ifdef AFS_DEMAND_ATTACH_FS
+           /* Put the vol into PREATTACHED state, so if someone tries to
+            * access it again, we try to attach, see that we're not blessed,
+            * and give a VNOVOL error again. Putting it into UNATTACHED state
+            * would result in a VOFFLINE error instead. */
+           error_state = VOL_STATE_PREATTACHED;
+#endif /* AFS_DEMAND_ATTACH_FS */
+
            /* mimic e.g. GetVolume errors */
-           if (!V_blessed(vp))
+           if (!V_blessed(vp)) {
                Log("Volume %lu offline: not blessed\n", afs_printable_uint32_lu(V_id(vp)));
-           else if (!V_inService(vp))
+               FreeVolumeHeader(vp);
+           } else if (!V_inService(vp)) {
                Log("Volume %lu offline: not in service\n", afs_printable_uint32_lu(V_id(vp)));
-           else {
+               FreeVolumeHeader(vp);
+           } else {
                Log("Volume %lu offline: needs salvage\n", afs_printable_uint32_lu(V_id(vp)));
-               *ec = VOFFLINE;
+               *ec = VSALVAGE;
 #ifdef AFS_DEMAND_ATTACH_FS
+               error_state = VOL_STATE_ERROR;
                /* see if we can recover */
                VRequestSalvage_r(ec, vp, SALVSYNC_NEEDED, VOL_SALVAGE_INVALIDATE_HEADER);
-               vp->nUsers = 0;
-
-               goto error;
 #endif
            }
-           VPutVolume_r(vp);
-           vp = NULL;
+#ifdef AFS_DEMAND_ATTACH_FS
+           vp->nUsers = 0;
+#endif
+           goto error;
        }
     } else {
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -3375,7 +3391,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
  error:
 #ifdef AFS_DEMAND_ATTACH_FS
     if (!VIsErrorState(V_attachState(vp))) {
-       VChangeState_r(vp, VOL_STATE_ERROR);
+       VChangeState_r(vp, error_state);
     }
 #endif /* AFS_DEMAND_ATTACH_FS */