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, int defersleep) {
33 /* we ignore defersleep, as we *always* need to sleep */
34 if (!VREFCOUNT_GT(avc, 0) && avc->opens == 0 &&
35 (avc->f.states & CUnlinkedDel) == 0) {
37 vnode_t tvp = AFSTOV(avc);
38 /* VREFCOUNT_GT only sees usecounts, not iocounts */
39 /* so this may fail to actually recycle the vnode now */
40 /* must call vnode_get to avoid races. */
41 if (vnode_get(tvp) == 0) {
43 /* must release lock, since vnode_put will immediately
44 reclaim if there are no other users */
45 ReleaseWriteLock(&afs_xvcache);
50 ObtainWriteLock(&afs_xvcache, 336);
52 /* we can't use the vnode_recycle return value to figure
53 * this out, since the iocount we have to hold makes it
55 if (AFSTOV(avc) == tvp) {
58 QAdd(&VLRU, &avc->vlruq);
68 osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
69 if (!VREFCOUNT_GT(avc,0)
70 || ((VREFCOUNT(avc) == 1) && (UBCINFOEXISTS(AFSTOV(avc))))
71 && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0)
74 * vgone() reclaims the vnode, which calls afs_FlushVCache(),
75 * then it puts the vnode on the free list.
76 * If we don't do this we end up with a cleaned vnode that's
77 * not on the free list.
86 #endif /* AFS_DARWIN80_ENV */
89 osi_PrePopulateVCache(struct vcache *avc) {
90 memset(avc, 0, sizeof(struct vcache));
92 /* PPC Darwin 80 seems to be a BOZONLOCK environment, so we need this
94 #if defined(AFS_BOZONLOCK_ENV)
95 afs_BozonInit(&avc->pvnLock, avc);
100 osi_AttachVnode(struct vcache *avc, int seq) {
101 ReleaseWriteLock(&afs_xvcache);
103 afs_darwin_getnewvnode(avc, seq ? 0 : 1); /* includes one refcount */
105 ObtainWriteLock(&afs_xvcache,338);
106 #ifdef AFS_DARWIN80_ENV
107 LOCKINIT(avc->rwlock);
109 lockinit(&avc->rwlock, PINOD, "vcache", 0, 0);
114 osi_PostPopulateVCache(struct vcache *avc) {
115 #if !defined(AFS_DARWIN80_ENV)
116 avc->v->v_mount = afs_globalVFS;