vol AttachByName should mimic other volpkg errors
authorDerrick Brashear <shadow@dementia.org>
Mon, 19 Jul 2010 18:17:21 +0000 (14:17 -0400)
committerDerrick Brashear <shadow@dementia.org>
Tue, 20 Jul 2010 05:13:40 +0000 (22:13 -0700)
if later callers will deem a volume offline, note it at attach time.
additionally, log the cause.

Change-Id: I4870e8f3bfd8d7e69e448d3a445be81435407f0f
Reviewed-on: http://gerrit.openafs.org/2448
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/vol/volume.c

index 93490e8..d08fc80 100644 (file)
@@ -3326,6 +3326,27 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
            V_inUse(vp) = fileServer;
            V_offlineMessage(vp)[0] = '\0';
        }
+       if (!V_inUse(vp)) {
+           *ec = VNOVOL;
+           /* mimic e.g. GetVolume errors */
+           if (!V_blessed(vp))
+               Log("Volume %lu offline: not blessed\n", afs_printable_uint32_lu(V_id(vp)));
+           else if (!V_inService(vp))
+               Log("Volume %lu offline: not in service\n", afs_printable_uint32_lu(V_id(vp)));
+           else {
+               Log("Volume %lu offline: needs salvage\n", afs_printable_uint32_lu(V_id(vp)));
+               *ec = VOFFLINE;
+#ifdef AFS_DEMAND_ATTACH_FS
+               /* 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;
+       }
     } else {
 #ifdef AFS_DEMAND_ATTACH_FS
        if ((mode != V_PEEK) && (mode != V_SECRETLY))