From 8ff592b56d2ed74a01da8090637e06cab2cc1c19 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 31 May 2012 17:45:56 -0500 Subject: [PATCH] vol: Avoid getting stuck in ATTACHING in attach2 Since commit 5fc2365f, a VNOVOL error early in attach2 meant that we skipped changing the volume state to anything, and just returned instead. When we do this, the volume is in VOL_STATE_ATTACHING for DAFS, and so if we return, the volume will forever be in VOL_STATE_ATTACHING. The next thing that tries to access the volume will wait forever for the volume to come out of that state. So, revert half of 5fc2365f, and transition to ERROR state instead. This code path should not be hit during normal usage, since a nonexistant volume access for the fileserver will be detected earlier. If the volume does not appear to exist at this stage of attachment, something is wrong with the volume, so this warrants the ERROR state. For the volserver and other volume utilities, we may hit this when a request just plain references a nonexistant volume for whatever reason, but in that case the vp should go away soon. For non-DAFS, this commit does not change much, since the difference between error_notbroken and unlocked_error is very small. The other half of 5fc2365f is not changed, since it is correct. For VOFFLINE errors at this point, the volume has already been transitioned to VOL_STATE_UNATTACHED, so it is okay to return. Add a comment to help make this more explicit. Reviewed-on: http://gerrit.openafs.org/7516 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 4f9c3f2be9abd5548dd52888b49c407d574b6557) Change-Id: I8e2b9d2a114f8aea283145ca44bf8ae52c354908 Reviewed-on: http://gerrit.openafs.org/9482 Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/vol/volume.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index 7e917a817..eb1e5e408 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -3194,8 +3194,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp, if (*ec == VNOVOL) { /* if the volume doesn't exist, skip straight to 'error' so we don't * request a salvage */ - VOL_LOCK; - goto error_notbroken; + goto unlocked_error; } if (!*ec) { @@ -3290,6 +3289,9 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp, } else if (*ec) { /* volume operation in progress */ VOL_LOCK; + /* we have already transitioned the vp away from ATTACHING state, so we + * can go right to the end of attach2, and we do not need to transition + * to ERROR. */ goto error_notbroken; } #else /* AFS_DEMAND_ATTACH_FS */ @@ -3489,10 +3491,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp, return vp; -#ifndef AFS_DEMAND_ATTACH_FS unlocked_error: -#endif - VOL_LOCK; locked_error: #ifdef AFS_DEMAND_ATTACH_FS @@ -3509,8 +3508,8 @@ locked_error: VReleaseVolumeHandles_r(vp); } - error_notbroken: #ifdef AFS_DEMAND_ATTACH_FS + error_notbroken: VCheckSalvage(vp); if (forcefree) { FreeVolume(vp); -- 2.39.5