From: Andrew Deason Date: Wed, 28 Jul 2010 22:10:10 +0000 (-0500) Subject: viced: Correct unblessed attach2 errors X-Git-Tag: openafs-devel-1_5_76~68 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=3a0efeebf63a721068165b3f55600c8eef9faab2;p=packages%2Fo%2Fopenafs.git viced: Correct unblessed attach2 errors 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 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/vol/volume.c b/src/vol/volume.c index d08fc8034..2fc88ab2e 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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 */