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
) {
56 /* Caller will move this vcache to the head of the VLRU. */
65 osi_TryEvictVCache(struct vcache
*avc
, int *slept
, int defersleep
) {
66 if (!VREFCOUNT_GT(avc
,0)
67 || ((VREFCOUNT(avc
) == 1) && (UBCINFOEXISTS(AFSTOV(avc
))))
68 && avc
->opens
== 0 && (avc
->f
.states
& CUnlinkedDel
) == 0)
71 * vgone() reclaims the vnode, which calls afs_FlushVCache(),
72 * then it puts the vnode on the free list.
73 * If we don't do this we end up with a cleaned vnode that's
74 * not on the free list.
83 #endif /* AFS_DARWIN80_ENV */
86 osi_PrePopulateVCache(struct vcache
*avc
) {
87 memset(avc
, 0, sizeof(struct vcache
));
91 osi_AttachVnode(struct vcache
*avc
, int seq
) {
92 ReleaseWriteLock(&afs_xvcache
);
94 afs_darwin_getnewvnode(avc
); /* includes one refcount */
96 ObtainWriteLock(&afs_xvcache
,338);
97 #ifdef AFS_DARWIN80_ENV
98 LOCKINIT(avc
->rwlock
);
100 lockinit(&avc
->rwlock
, PINOD
, "vcache", 0, 0);
105 osi_PostPopulateVCache(struct vcache
*avc
) {
106 #if !defined(AFS_DARWIN80_ENV)
107 avc
->v
->v_mount
= afs_globalVFS
;