* afs_WriteVCacheDiscon
* afs_SimpleVStat
* afs_ProcessFS
- * TellALittleWhiteLie
* afs_RemoteLookup
* afs_GetVCache
* afs_LookupVCache
/* Hash only on volume to speed up volume callbacks. */
int VCHashV(struct VenusFid *fid)
{
- return opr_jhash_int(fid->Fid.Vnode, 0) & opr_jhash_mask(VCSIZEBITS);
+ return opr_jhash_int(fid->Fid.Volume, 0) & opr_jhash_mask(VCSIZEBITS);
}
/*!
/* OK, there are no internal vrefCounts, so there shouldn't
* be any more refs here. */
if (avc->v) {
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
vnode_clearfsnode(AFSTOV(avc));
vnode_removefsref(AFSTOV(avc));
-#else
+# else
avc->v->v_data = NULL; /* remove from vnode */
-#endif
+# endif
AFSTOV(avc) = NULL; /* also drop the ptr to vnode */
}
#endif
-#ifdef AFS_SUN510_ENV
+
+#ifdef AFS_SUN511_ENV
+ if (avc->v) {
+ vn_free(avc->v);
+ avc->v = NULL;
+ }
+#elif defined(AFS_SUN510_ENV)
/* As we use private vnodes, cleanup is up to us */
vn_reinit(AFSTOV(avc));
#endif
/* we can't keep trying to push back dirty data forever. Give up. */
afs_InvalidateAllSegments(avc); /* turns off dirty bit */
}
- avc->f.states &= ~CMAPPED; /* mainly used by SunOS 4.0.x */
+ avc->f.states &= ~CMAPPED;
avc->f.states &= ~CDirty; /* Turn it off */
if (avc->f.states & CUnlinked) {
if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) {
/* printf("Reclaim list flush %lx failed: %d\n", (unsigned long) tvc, code); */
}
if (tvc->f.states & (CVInit
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
| CDeadVnode
-#endif
+# endif
)) {
tvc->f.states &= ~(CVInit
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
| CDeadVnode
-#endif
+# endif
);
afs_osi_Wakeup(&tvc->f.states);
}
ReleaseWriteLock(&avc->lock);
/* fetch the status info */
- tvc = afs_GetVCache(&avc->f.fid, areq, NULL, avc);
+ tvc = afs_GetVCache(&avc->f.fid, areq);
if (!tvc)
return EIO;
/* Put it back; caller has already incremented vrefCount */
if (astatus->Mask & AFS_SETMODE) {
avc->f.m.Mode = astatus->UnixModeBits;
-#if 0 /* XXX: Leaving this out, so it doesn't mess up the file type flag.*/
-
- if (vType(avc) == VREG) {
- avc->f.m.Mode |= S_IFREG;
- } else if (vType(avc) == VDIR) {
- avc->f.m.Mode |= S_IFDIR;
- } else if (vType(avc) == VLNK) {
- avc->f.m.Mode |= S_IFLNK;
- if ((avc->f.m.Mode & 0111) == 0)
- avc->mvstat = AFS_MVSTAT_MTPT;
- }
-#endif
flags |= VDisconSetMode;
} /* if(astatus.Mask & AFS_SETMODE) */
* \param afid File ID.
* \param areq Ptr to associated vrequest structure, specifying the
* user whose authentication tokens will be used.
- * \param avc Caller may already have a vcache for this file, which is
- * already held.
*
* \note Environment:
* The cache entry is returned with an increased vrefCount field.
* locking directories in a constant order.
*
* \note NB. NewVCache -> FlushVCache presently (4/10/95) drops the xvcache lock.
- *
- * \note Might have a vcache structure already, which must
- * already be held by the caller
*/
struct vcache *
-afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
- afs_int32 * cached, struct vcache *avc)
+afs_GetVCache(struct VenusFid *afid, struct vrequest *areq)
{
afs_int32 code, newvcache = 0;
AFS_STATCNT(afs_GetVCache);
- if (cached)
- *cached = 0; /* Init just in case */
-
#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
loop:
#endif
#endif
}
if (tvc) {
- if (cached)
- *cached = 1;
osi_Assert((tvc->f.states & CVInit) == 0);
/* If we are in readdir, return the vnode even if not statd */
if ((tvc->f.states & CStatd) || afs_InReadDir(tvc)) {
/* Darwin 8.0 only has bufs in nfs, so we shouldn't have to worry about them.
What about ubc? */
#else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+# if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
/*
* XXX - I really don't like this. Should try to understand better.
* It seems that sometimes, when we get called, we already hold the
struct vnode *vp = AFSTOV(tvc);
int iheldthelock;
-#if defined(AFS_DARWIN_ENV)
+# if defined(AFS_DARWIN_ENV)
iheldthelock = VOP_ISLOCKED(vp);
if (!iheldthelock)
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, current_proc());
ObtainWriteLock(&tvc->lock, 954);
if (!iheldthelock)
VOP_UNLOCK(vp, LK_EXCLUSIVE, current_proc());
-#elif defined(AFS_FBSD80_ENV)
+# elif defined(AFS_FBSD_ENV)
+ AFS_GUNLOCK();
iheldthelock = VOP_ISLOCKED(vp);
if (!iheldthelock) {
- /* nosleep/sleep lock order reversal */
- int glocked = ISAFS_GLOCK();
- if (glocked)
- AFS_GUNLOCK();
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- if (glocked)
- AFS_GLOCK();
}
vinvalbuf(vp, V_SAVE, PINOD, 0); /* changed late in 8.0-CURRENT */
if (!iheldthelock)
VOP_UNLOCK(vp, 0);
-#elif defined(AFS_FBSD60_ENV)
- iheldthelock = VOP_ISLOCKED(vp, curthread);
- if (!iheldthelock)
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
- AFS_GUNLOCK();
- vinvalbuf(vp, V_SAVE, curthread, PINOD, 0);
AFS_GLOCK();
- if (!iheldthelock)
- VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
-#elif defined(AFS_FBSD_ENV)
- iheldthelock = VOP_ISLOCKED(vp, curthread);
- if (!iheldthelock)
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
- vinvalbuf(vp, V_SAVE, osi_curcred(), curthread, PINOD, 0);
- if (!iheldthelock)
- VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
-#elif defined(AFS_OBSD_ENV)
+# elif defined(AFS_OBSD_ENV)
iheldthelock = VOP_ISLOCKED(vp, curproc);
if (!iheldthelock)
VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY, curproc);
uvm_vnp_uncache(vp);
if (!iheldthelock)
VOP_UNLOCK(vp, 0, curproc);
-#elif defined(AFS_NBSD40_ENV)
+# elif defined(AFS_NBSD40_ENV)
iheldthelock = VOP_ISLOCKED(vp);
if (!iheldthelock) {
VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY);
uvm_vnp_uncache(vp);
if (!iheldthelock)
VOP_UNLOCK(vp, 0);
-#endif
+# endif
}
-#endif
+# endif
#endif
afs_StaleVCacheFlags(tvc, AFS_STALEVC_NODNLC | AFS_STALEVC_CLEARCB,
*
* \param afid
* \param areq
- * \param cached Is element cached? If NULL, don't answer.
* \param adp
* \param aname
*
*/
struct vcache *
afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
- afs_int32 * cached, struct vcache *adp, char *aname)
+ struct vcache *adp, char *aname)
{
afs_int32 code, now, newvcache = 0;
struct VenusFid nfid;
afs_int32 retry;
AFS_STATCNT(afs_GetVCache);
- if (cached)
- *cached = 0; /* Init just in case */
#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
loop1:
ObtainReadLock(&tvc->lock);
if (tvc->f.states & CStatd) {
- if (cached) {
- *cached = 1;
- }
ReleaseReadLock(&tvc->lock);
return tvc;
}
struct vcache *
afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
- afs_int32 * cached, struct volume *tvolp)
+ struct volume *tvolp)
{
afs_int32 code = 0, i, newvcache = 0, haveStatus = 0;
afs_int32 getNewFid = 0;
newvcache = 1;
afs_stats_cmperf.vcacheMisses++;
} else {
- if (cached)
- *cached = 1;
afs_stats_cmperf.vcacheHits++;
#if defined(AFS_DARWIN80_ENV)
/* we already bumped the ref count in the for loop above */
return code;
}
-#if 0
-/*
- * afs_StuffVcache
- *
- * Description:
- * Stuff some information into the vcache for the given file.
- *
- * Parameters:
- * afid : File in question.
- * OutStatus : Fetch status on the file.
- * CallBack : Callback info.
- * tc : RPC connection involved.
- * areq : vrequest involved.
- *
- * Environment:
- * Nothing interesting.
- */
-void
-afs_StuffVcache(struct VenusFid *afid,
- struct AFSFetchStatus *OutStatus,
- struct AFSCallBack *CallBack, struct afs_conn *tc,
- struct vrequest *areq)
-{
- afs_int32 code, i, newvcache = 0;
- struct vcache *tvc;
- struct AFSVolSync tsync;
- struct volume *tvp;
- struct axscache *ac;
- afs_int32 retry;
-
- AFS_STATCNT(afs_StuffVcache);
-#ifdef IFS_VCACHECOUNT
- ifs_gvcachecall++;
-#endif
-
- loop:
- ObtainSharedLock(&afs_xvcache, 8);
-
- 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);
- spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD);
- goto loop;
-#endif
- }
-
- if (!tvc) {
- /* no cache entry, better grab one */
- UpgradeSToWLock(&afs_xvcache, 25);
- tvc = afs_NewVCache(afid, NULL);
- newvcache = 1;
- ConvertWToSLock(&afs_xvcache);
- if (!tvc)
- {
- ReleaseSharedLock(&afs_xvcache);
- return NULL;
- }
- }
-
- ReleaseSharedLock(&afs_xvcache);
- ObtainWriteLock(&tvc->lock, 58);
-
- afs_StaleVCacheFlags(tvc, AFS_STALEVC_NOCB, 0);
-
- /* Is it always appropriate to throw away all the access rights? */
- afs_FreeAllAxs(&(tvc->Access));
-
- /*Copy useful per-volume info */
- tvp = afs_GetVolume(afid, areq, READ_LOCK);
- if (tvp) {
- if (newvcache && (tvp->states & VForeign))
- tvc->f.states |= CForeign;
- if (tvp->states & VRO)
- tvc->f.states |= CRO;
- if (tvp->states & VBackup)
- tvc->f.states |= CBackup;
- /*
- * Now, copy ".." entry back out of volume structure, if
- * necessary
- */
- if (tvc->mvstat == AFS_MVSTAT_ROOT && tvp->dotdot.Fid.Volume != 0) {
- if (!tvc->mvid.parent)
- tvc->mvid.parent = (struct VenusFid *)
- osi_AllocSmallSpace(sizeof(struct VenusFid));
- *tvc->mvid.parent = tvp->dotdot;
- }
- }
- /* store the stat on the file */
- afs_RemoveVCB(afid);
- afs_ProcessFS(tvc, OutStatus, areq);
- tvc->callback = tc->srvr->server;
-
- /* we use osi_Time twice below. Ideally, we would use the time at which
- * the FetchStatus call began, instead, but we don't have it here. So we
- * make do with "now". In the CRO case, it doesn't really matter. In
- * the other case, we hope that the difference between "now" and when the
- * call actually began execution on the server won't be larger than the
- * padding which the server keeps. Subtract 1 second anyway, to be on
- * the safe side. Can't subtract more because we don't know how big
- * ExpirationTime is. Possible consistency problems may arise if the call
- * timeout period becomes longer than the server's expiration padding. */
- ObtainWriteLock(&afs_xcbhash, 470);
- if (CallBack->ExpirationTime != 0) {
- tvc->cbExpires = CallBack->ExpirationTime + osi_Time() - 1;
- tvc->f.states |= CStatd;
- tvc->f.states &= ~CBulkFetching;
- afs_QueueCallback(tvc, CBHash(CallBack->ExpirationTime), tvp);
- } else if (tvc->f.states & CRO) {
- /* old-fashioned AFS 3.2 style */
- tvc->cbExpires = 3600 + osi_Time();
- /*XXX*/ tvc->f.states |= CStatd;
- tvc->f.states &= ~CBulkFetching;
- afs_QueueCallback(tvc, CBHash(3600), tvp);
- } else {
- afs_StaleVCacheFlags(tvc, AFS_STALEVC_CBLOCKED | AFS_STALEVC_CLEARCB,
- CUnique);
- }
- ReleaseWriteLock(&afs_xcbhash);
- if (tvp)
- afs_PutVolume(tvp, READ_LOCK);
-
- /* look in per-pag cache */
- if (tvc->Access && (ac = afs_FindAxs(tvc->Access, areq->uid)))
- ac->axess = OutStatus->CallerAccess; /* substitute pags */
- else /* not found, add a new one if possible */
- afs_AddAxs(tvc->Access, areq->uid, OutStatus->CallerAccess);
-
- ReleaseWriteLock(&tvc->lock);
- afs_Trace4(afs_iclSetp, CM_TRACE_STUFFVCACHE, ICL_TYPE_POINTER, tvc,
- ICL_TYPE_POINTER, tvc->callback, ICL_TYPE_INT32,
- tvc->cbExpires, ICL_TYPE_INT32, tvc->cbExpires - osi_Time());
- /*
- * Release ref count... hope this guy stays around...
- */
- afs_PutVCache(tvc);
-} /*afs_StuffVcache */
-#endif
-
/*!
* Decrements the reference count on a cache entry.
*
/* should I have a read lock on the vnode here? */
if (tvc) {
#ifndef AFS_DARWIN80_ENV
-#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
+# if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
afs_int32 retry = 0;
osi_vnhold(tvc, &retry);
if (retry) {
spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD);
goto loop;
}
-#else
+# else
osi_vnhold(tvc, (int *)0); /* already held, above */
-#endif
+# endif
#endif
/*
* We obtained the xvcache lock above.
tvc->vc_rwlockid = OSI_NO_LOCKID;
initnsema(&tvc->vc_rwlock, 1,
makesname(name, "vrw", tvc->v.v_number));
-#ifndef AFS_SGI53_ENV
+# ifndef AFS_SGI53_ENV
initnsema(&tvc->v.v_sync, 0, makesname(name, "vsy", tvc->v.v_number));
-#endif
-#ifndef AFS_SGI62_ENV
+# endif
+# ifndef AFS_SGI62_ENV
initnlock(&tvc->v.v_lock, makesname(name, "vlk", tvc->v.v_number));
-#endif /* AFS_SGI62_ENV */
+# endif /* AFS_SGI62_ENV */
}
#endif
QInit(&VLRU);
#ifdef AFS_AIX_ENV
if (tvc->v.v_gnode)
afs_osi_Free(tvc->v.v_gnode, sizeof(struct gnode));
-#ifdef AFS_AIX32_ENV
+# ifdef AFS_AIX32_ENV
if (tvc->segid) {
AFS_GUNLOCK();
vms_delete(tvc->segid);
crfree(tvc->credp);
tvc->credp = NULL;
}
-#endif
+# endif
#endif
#if defined(AFS_SUN5_ENV)
if (tvc->credp) {