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 */
16 #if defined(AFS_FBSD80_ENV)
17 #define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags))
18 #define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags))
19 #define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags))
21 #define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags, p))
22 #define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags, p))
23 #define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags, p))
27 osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
30 * essentially all we want to do here is check that the
31 * vcache is not in use, then call vgone() (which will call
32 * inactive and reclaim as needed). This requires some
33 * kind of complicated locking, which we already need to implement
34 * for FlushVCache, so just call that routine here and check
35 * its return value for whether the vcache was evict-able.
37 if (osi_VM_FlushVCache(avc, slept) != 0)
47 tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
48 tvc->v = NULL; /* important to clean this, or use memset 0 */
54 osi_PrePopulateVCache(struct vcache *avc) {
55 memset(avc, 0, sizeof(struct vcache));
59 osi_AttachVnode(struct vcache *avc, int seq) {
61 struct thread *p = curthread;
63 ReleaseWriteLock(&afs_xvcache);
65 #if defined(AFS_FBSD60_ENV)
66 if (getnewvnode(MOUNT_AFS, afs_globalVFS, &afs_vnodeops, &vp))
68 if (getnewvnode(MOUNT_AFS, afs_globalVFS, afs_vnodeop_p, &vp))
70 panic("afs getnewvnode"); /* can't happen */
72 /* XXX verified on 80--TODO check on 7x */
74 ma_vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* !glocked */
75 insmntque(vp, afs_globalVFS);
76 MA_VOP_UNLOCK(vp, 0, p);
80 ObtainWriteLock(&afs_xvcache,339);
82 /* I'd like to know if this ever happens...
83 * We don't drop global for the rest of this function,
84 * so if we do lose the race, the other thread should
85 * have found the same vnode and finished initializing
86 * the vcache entry. Is it conceivable that this vcache
87 * entry could be recycled during this interval? If so,
88 * then there probably needs to be some sort of additional
89 * mutual exclusion (an Embryonic flag would suffice).
91 afs_warn("afs_NewVCache: lost the race\n");
96 lockinit(&avc->rwlock, PINOD, "vcache", 0, 0);
100 osi_PostPopulateVCache(struct vcache *avc) {
101 avc->v->v_mount = afs_globalVFS;