mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
vol: attach2 must always return with VOL_LOCK held
attach2() is required to return with the VOL_LOCK held even though it is called without it. This must be true for error conditions as well. Not all error paths are obtaining the VOL_LOCK before returning. Add out paths for lock held and lock unheld error cases. Change-Id: Ib6a05a9bafd9eb3a26a1dd3881d19baa6d59a05e Reviewed-on: http://gerrit.openafs.org/3177 Tested-by: Derrick Brashear <shadow@dementia.org> Reviewed-by: Jeffrey Altman <jaltman@openafs.org> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
c120f5c9b6
commit
58901738ad
@ -3103,7 +3103,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 */
|
||||
goto error;
|
||||
goto unlocked_error;
|
||||
}
|
||||
|
||||
if (!*ec) {
|
||||
@ -3191,17 +3191,15 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
VOL_SALVAGE_NO_OFFLINE);
|
||||
vp->nUsers = 0;
|
||||
|
||||
goto error;
|
||||
goto locked_error;
|
||||
} else if (*ec) {
|
||||
/* volume operation in progress */
|
||||
VOL_LOCK;
|
||||
goto error;
|
||||
goto unlocked_error;
|
||||
}
|
||||
#else /* AFS_DEMAND_ATTACH_FS */
|
||||
if (*ec) {
|
||||
Log("VAttachVolume: Error attaching volume %s; volume needs salvage; error=%u\n", path, *ec);
|
||||
VOL_LOCK;
|
||||
goto error;
|
||||
goto unlocked_error;
|
||||
}
|
||||
#endif /* AFS_DEMAND_ATTACH_FS */
|
||||
|
||||
@ -3221,7 +3219,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
*ec = VSALVAGE;
|
||||
#endif /* AFS_DEMAND_ATTACH_FS */
|
||||
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
|
||||
VOL_LOCK;
|
||||
@ -3245,7 +3243,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
*ec = VSALVAGE;
|
||||
#endif /* AFS_DEMAND_ATTACH_FS */
|
||||
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
|
||||
if (programType == fileServer && V_destroyMe(vp) == DESTROY_ME) {
|
||||
@ -3267,7 +3265,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
#endif /* AFS_DEMAND_ATTACH_FS */
|
||||
Log("VAttachVolume: volume %s is junk; it should be destroyed at next salvage\n", path);
|
||||
*ec = VNOVOL;
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
|
||||
vp->vnodeIndex[vSmall].bitmap = vp->vnodeIndex[vLarge].bitmap = NULL;
|
||||
@ -3284,7 +3282,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
#endif /* AFS_DEMAND_ATTACH_FS */
|
||||
Log("VAttachVolume: error getting bitmap for volume (%s)\n",
|
||||
path);
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3333,7 +3331,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
#else /* !AFS_DEMAND_ATTACH_FS */
|
||||
*ec = VSALVAGE;
|
||||
#endif /* !AFS_DEMAND_ATTACh_FS */
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3373,7 +3371,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
#ifdef AFS_DEMAND_ATTACH_FS
|
||||
vp->nUsers = 0;
|
||||
#endif
|
||||
goto error;
|
||||
goto locked_error;
|
||||
}
|
||||
} else {
|
||||
#ifdef AFS_DEMAND_ATTACH_FS
|
||||
@ -3400,7 +3398,9 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
|
||||
|
||||
return vp;
|
||||
|
||||
error:
|
||||
unlocked_error:
|
||||
VOL_LOCK;
|
||||
locked_error:
|
||||
#ifdef AFS_DEMAND_ATTACH_FS
|
||||
if (!VIsErrorState(V_attachState(vp))) {
|
||||
VChangeState_r(vp, error_state);
|
||||
|
Loading…
Reference in New Issue
Block a user