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() */
41 ReleaseWriteLock(&afs_xvcache
);
45 /* use the interlock while locking, so no one else can DOOM this */
46 vn_lock(vp
, LK_INTERLOCK
|LK_EXCLUSIVE
|LK_RETRY
);
52 ObtainWriteLock(&afs_xvcache
, 340);
60 tvc
= afs_osi_Alloc(sizeof(struct vcache
));
61 tvc
->v
= NULL
; /* important to clean this, or use memset 0 */
67 osi_PrePopulateVCache(struct vcache
*avc
) {
68 memset(avc
, 0, sizeof(struct vcache
));
72 osi_AttachVnode(struct vcache
*avc
, int seq
) {
75 ReleaseWriteLock(&afs_xvcache
);
77 if (getnewvnode(MOUNT_AFS
, afs_globalVFS
, &afs_vnodeops
, &vp
))
78 panic("afs getnewvnode"); /* can't happen */
79 /* XXX verified on 80--TODO check on 7x */
81 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
); /* !glocked */
82 insmntque(vp
, afs_globalVFS
);
86 ObtainWriteLock(&afs_xvcache
,339);
88 /* I'd like to know if this ever happens...
89 * We don't drop global for the rest of this function,
90 * so if we do lose the race, the other thread should
91 * have found the same vnode and finished initializing
92 * the vcache entry. Is it conceivable that this vcache
93 * entry could be recycled during this interval? If so,
94 * then there probably needs to be some sort of additional
95 * mutual exclusion (an Embryonic flag would suffice).
97 afs_warn("afs_NewVCache: lost the race\n");
101 avc
->v
->v_data
= avc
;
102 lockinit(&avc
->rwlock
, PINOD
, "vcache", 0, 0);
106 osi_PostPopulateVCache(struct vcache
*avc
) {
107 avc
->v
->v_mount
= afs_globalVFS
;