2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
13 #include "afs/sysincludes.h" /*Standard vendor system headers */
14 #include "afsincludes.h" /*AFS-based standard headers */
20 tvc = afs_osi_Alloc(sizeof(struct vcache));
21 osi_Assert(tvc != NULL);
22 tvc->v = NULL; /* important to clean this, or use memset 0 */
28 #if defined(AFS_DARWIN80_ENV)
30 osi_TryEvictVCache(struct vcache *avc, int *slept) {
33 if (!VREFCOUNT_GT(avc, 0) && avc->opens == 0 &&
34 (avc->f.states & CUnlinkedDel) == 0) {
36 vnode_t tvp = AFSTOV(avc);
37 /* VREFCOUNT_GT only sees usecounts, not iocounts */
38 /* so this may fail to actually recycle the vnode now */
39 /* must call vnode_get to avoid races. */
40 if (vnode_get(tvp) == 0) {
42 /* must release lock, since vnode_put will immediately
43 reclaim if there are no other users */
44 ReleaseWriteLock(&afs_xvcache);
49 ObtainWriteLock(&afs_xvcache, 336);
51 /* we can't use the vnode_recycle return value to figure
52 * this out, since the iocount we have to hold makes it
54 if (AFSTOV(avc) == tvp) {
57 QAdd(&VLRU, &avc->vlruq);
67 osi_TryEvictVCache(struct vcache *avc, int *slept) {
68 if (!VREFCOUNT_GT(avc,0)
69 || ((VREFCOUNT(avc) == 1) && (UBCINFOEXISTS(AFSTOV(avc))))
70 && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0)
73 * vgone() reclaims the vnode, which calls afs_FlushVCache(),
74 * then it puts the vnode on the free list.
75 * If we don't do this we end up with a cleaned vnode that's
76 * not on the free list.
85 #endif /* AFS_DARWIN80_ENV */
88 osi_PrePopulateVCache(struct vcache *avc) {
89 memset(avc, 0, sizeof(struct vcache));
91 /* PPC Darwin 80 seems to be a BOZONLOCK environment, so we need this
93 #if defined(AFS_BOZONLOCK_ENV)
94 afs_BozonInit(&avc->pvnLock, avc);
99 osi_AttachVnode(struct vcache *avc, int seq) {
100 ReleaseWriteLock(&afs_xvcache);
102 afs_darwin_getnewvnode(avc, seq ? 0 : 1); /* includes one refcount */
104 ObtainWriteLock(&afs_xvcache,338);
105 #ifdef AFS_DARWIN80_ENV
106 LOCKINIT(avc->rwlock);
108 lockinit(&avc->rwlock, PINOD, "vcache", 0, 0);
113 osi_PostPopulateVCache(struct vcache *avc) {
114 #if !defined(AFS_DARWIN80_ENV)
115 avc->v->v_mount = afs_globalVFS;