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 */
17 osi_TryEvictVCache(struct vcache *avc, int *slept) {
18 struct vnode *vp = AFSTOV(avc);
21 * essentially all we want to do here is check that the
22 * vcache is not in use, then call vgone() (which will call
23 * inactive and reclaim as needed). This requires some
24 * kind of complicated locking, which we already need to implement
25 * for FlushVCache, so just call that routine here and check
26 * its return value for whether the vcache was evict-able.
28 if (osi_VM_FlushVCache(avc, slept) != 0)
38 tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
39 tvc->v = NULL; /* important to clean this, or use memset 0 */
45 osi_PrePopulateVCache(struct vcache *avc) {
46 memset(avc, 0, sizeof(struct vcache));
50 osi_AttachVnode(struct vcache *avc, int seq) {
53 ReleaseWriteLock(&afs_xvcache);
55 #if defined(AFS_FBSD60_ENV)
56 if (getnewvnode(MOUNT_AFS, afs_globalVFS, &afs_vnodeops, &vp))
58 if (getnewvnode(MOUNT_AFS, afs_globalVFS, afs_vnodeop_p, &vp))
60 panic("afs getnewvnode"); /* can't happen */
62 /* XXX verified on 80--TODO check on 7x */
64 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* !glocked */
65 insmntque(vp, afs_globalVFS);
70 ObtainWriteLock(&afs_xvcache,339);
72 /* I'd like to know if this ever happens...
73 * We don't drop global for the rest of this function,
74 * so if we do lose the race, the other thread should
75 * have found the same vnode and finished initializing
76 * the vcache entry. Is it conceivable that this vcache
77 * entry could be recycled during this interval? If so,
78 * then there probably needs to be some sort of additional
79 * mutual exclusion (an Embryonic flag would suffice).
81 afs_warn("afs_NewVCache: lost the race\n");
86 lockinit(&avc->rwlock, PINOD, "vcache", 0, 0);
90 osi_PostPopulateVCache(struct vcache *avc) {
91 avc->v->v_mount = afs_globalVFS;