STABLE14-deadvnode-locking-update-20051118

FIXES 22870

change how we do vnode locking to avoid locking on ourselves


(cherry picked from commit 73e126c4c4f44f20e67d8ced8a89558746e87a90)
This commit is contained in:
Chaskiel M Grundman 2005-11-19 04:35:39 +00:00 committed by Derrick Brashear
parent 1b55df7d51
commit b2ab9e472c
5 changed files with 38 additions and 30 deletions

View File

@ -134,5 +134,5 @@ afs_modunload(struct kmod_info * ki, void *data)
return KERN_SUCCESS;
}
KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, "1.3.82", afs_modload,
KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload,
afs_modunload)

View File

@ -291,7 +291,7 @@ afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
do {
retry = 0;
ObtainWriteLock(&afs_xvcache, 597);
root_vp = afs_FindVCache(tvc->mvid, &retry, 0);
root_vp = afs_FindVCache(tvc->mvid, &retry, IS_WLOCK);
if (root_vp && retry) {
ReleaseWriteLock(&afs_xvcache);
afs_PutVCache(root_vp);
@ -701,7 +701,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
do {
retry = 0;
ObtainWriteLock(&afs_xvcache, 130);
tvcp = afs_FindVCache(&tfid, &retry, 0 /* no stats | LRU */ );
tvcp = afs_FindVCache(&tfid, &retry, IS_WLOCK /* no stats | LRU */ );
if (tvcp && retry) {
ReleaseWriteLock(&afs_xvcache);
afs_PutVCache(tvcp);

View File

@ -247,7 +247,10 @@ afs_readdir_type(avc, ade)
tfid.Fid.Unique = ntohl(ade->fid.vunique);
if ((avc->states & CForeign) == 0 && (ntohl(ade->fid.vnode) & 1)) {
return DT_DIR;
} else if ((tvc = afs_FindVCache(&tfid, 0, 0))) {
}
ObtainReadLock(&afs_xvcache);
if ((tvc = afs_FindVCache(&tfid, 0, 0))) {
ReleaseReadLock(&afs_xvcache);
if (tvc->mvstat) {
afs_PutVCache(tvc);
return DT_DIR;
@ -266,7 +269,8 @@ afs_readdir_type(avc, ade)
/* what other types does AFS support? */
} else
afs_PutVCache(tvc);
}
} else
ReleaseReadLock(&afs_xvcache);
return DT_UNKNOWN;
}
#endif

View File

@ -1096,6 +1096,8 @@ extern struct brequest afs_brs[NBRS]; /* request structures */
#define DO_STATS 1 /* bits used by FindVCache */
#define DO_VLRU 2
#define IS_SLOCK 4
#define IS_WLOCK 8
/* values for flag param of afs_CheckVolumeNames */
#define AFS_VOLCHECK_EXPIRED 0x1 /* volumes whose callbacks have expired */

View File

@ -1671,7 +1671,7 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
ObtainSharedLock(&afs_xvcache, 5);
tvc = afs_FindVCache(afid, &retry, DO_STATS | DO_VLRU);
tvc = afs_FindVCache(afid, &retry, DO_STATS | DO_VLRU | IS_SLOCK);
if (tvc && retry) {
#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
ReleaseSharedLock(&afs_xvcache);
@ -1911,7 +1911,7 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
#endif
ObtainSharedLock(&afs_xvcache, 6);
tvc = afs_FindVCache(&nfid, &retry, DO_VLRU /* no xstats now */ );
tvc = afs_FindVCache(&nfid, &retry, DO_VLRU | IS_SLOCK/* no xstats now */ );
if (tvc && retry) {
#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
ReleaseSharedLock(&afs_xvcache);
@ -2374,7 +2374,7 @@ afs_StuffVcache(register struct VenusFid *afid,
loop:
ObtainSharedLock(&afs_xvcache, 8);
tvc = afs_FindVCache(afid, &retry, DO_VLRU /* no stats */ );
tvc = afs_FindVCache(afid, &retry, DO_VLRU| IS_SLOCK /* no stats */ );
if (tvc && retry) {
#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
ReleaseSharedLock(&afs_xvcache);
@ -2509,6 +2509,28 @@ afs_PutVCache(register struct vcache *avc)
#endif
} /*afs_PutVCache */
static void findvc_sleep(struct vcache *avc, int flag) {
if (flag & IS_SLOCK) {
ReleaseSharedLock(&afs_xvcache);
} else {
if (flag & IS_WLOCK) {
ReleaseWriteLock(&afs_xvcache);
} else {
ReleaseReadLock(&afs_xvcache);
}
}
afs_osi_Sleep(&avc->states);
if (flag & IS_SLOCK) {
ObtainSharedLock(&afs_xvcache, 341);
} else {
if (flag & IS_WLOCK) {
ObtainWriteLock(&afs_xvcache, 343);
} else {
ObtainReadLock(&afs_xvcache);
}
}
}
/*
* afs_FindVCache
*
@ -2542,17 +2564,7 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
if (FidMatches(afid, tvc)) {
if (tvc->states & CVInit) {
int lock;
lock = CheckLock(&afs_xvcache);
if (lock > 0)
ReleaseReadLock(&afs_xvcache);
else
ReleaseSharedLock(&afs_xvcache);
afs_osi_Sleep(&tvc->states);
if (lock > 0)
ObtainReadLock(&afs_xvcache);
else
ObtainSharedLock(&afs_xvcache, 341);
findvc_sleep(tvc, flag);
goto findloop;
}
#ifdef AFS_OSF_ENV
@ -2567,17 +2579,7 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
#ifdef AFS_DARWIN80_ENV
int vg;
if (tvc->states & CDeadVnode) {
int lock;
lock = CheckLock(&afs_xvcache);
if (lock > 0)
ReleaseReadLock(&afs_xvcache);
else
ReleaseSharedLock(&afs_xvcache);
afs_osi_Sleep(&tvc->states);
if (lock > 0)
ObtainReadLock(&afs_xvcache);
else
ObtainSharedLock(&afs_xvcache, 341);
findvc_sleep(tvc, flag);
goto findloop;
}
AFS_GUNLOCK();