From: Derrick Brashear Date: Mon, 19 Jul 2010 18:17:21 +0000 (-0400) Subject: vol AttachByName should mimic other volpkg errors X-Git-Tag: openafs-devel-1_5_76~86 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=939382c5;p=packages%2Fo%2Fopenafs.git 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 --- diff --git a/src/vol/volume.c b/src/vol/volume.c index 93490e843..d08fc8034 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))