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, int defersleep)
26 code = osi_fbsd_checkinuse(avc);
32 if ((vp->v_iflag & VI_DOOMED) != 0) {
37 /* must hold the vnode before calling vgone()
38 * This code largely copied from vfs_subr.c:vlrureclaim() */
42 /* use the interlock while locking, so no one else can DOOM this */
43 vn_lock(vp, LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY);
56 tvc = afs_osi_Alloc(sizeof(struct vcache));
57 tvc->v = NULL; /* important to clean this, or use memset 0 */
63 osi_PrePopulateVCache(struct vcache *avc) {
64 memset(avc, 0, sizeof(struct vcache));
68 osi_AttachVnode(struct vcache *avc, int seq) {
71 ReleaseWriteLock(&afs_xvcache);
73 if (getnewvnode(MOUNT_AFS, afs_globalVFS, &afs_vnodeops, &vp))
74 panic("afs getnewvnode"); /* can't happen */
75 /* XXX verified on 80--TODO check on 7x */
77 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* !glocked */
78 insmntque(vp, afs_globalVFS);
82 ObtainWriteLock(&afs_xvcache,339);
84 /* I'd like to know if this ever happens...
85 * We don't drop global for the rest of this function,
86 * so if we do lose the race, the other thread should
87 * have found the same vnode and finished initializing
88 * the vcache entry. Is it conceivable that this vcache
89 * entry could be recycled during this interval? If so,
90 * then there probably needs to be some sort of additional
91 * mutual exclusion (an Embryonic flag would suffice).
93 afs_warn("afs_NewVCache: lost the race\n");
98 lockinit(&avc->rwlock, PINOD, "vcache", 0, 0);
102 osi_PostPopulateVCache(struct vcache *avc) {
103 avc->v->v_mount = afs_globalVFS;