From 939382c5c1622750665a9f543168bd3b8044583f Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 19 Jul 2010 14:17:21 -0400 Subject: [PATCH] vol AttachByName should mimic other volpkg errors 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 Tested-by: Derrick Brashear --- src/vol/volume.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vol/volume.c b/src/vol/volume.c index 93490e8431..d08fc8034b 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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))