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) {
20 if (!VREFCOUNT_GT(avc,0)
21 && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0) {
22 code = afs_FlushVCache(avc, slept);
33 avc = afs_osi_Alloc(sizeof(struct vcache));
34 osi_Assert(avc != NULL);
39 osi_PrePopulateVCache(struct vcache *avc) {
40 memset(avc, 0, sizeof(struct vcache));
42 AFS_RWLOCK_INIT(&avc->vlock, "vcache vlock");
44 rw_init(&avc->rwlock, "vcache rwlock", RW_DEFAULT, NULL);
46 #if defined(AFS_SUN55_ENV)
47 /* This is required if the kaio (kernel aynchronous io)
48 ** module is installed. Inside the kernel, the function
49 ** check_vp( common/os/aio.c) checks to see if the kernel has
50 ** to provide asynchronous io for this vnode. This
51 ** function extracts the device number by following the
52 ** v_data field of the vnode. If we do not set this field
53 ** then the system panics. The value of the v_data field
54 ** is not really important for AFS vnodes because the kernel
55 ** does not do asynchronous io for regular files. Hence,
56 ** for the time being, we fill up the v_data field with the
57 ** vnode pointer itself. */
58 avc->v.v_data = (char *)avc;
59 #endif /* AFS_SUN55_ENV */
61 #if defined(AFS_BOZONLOCK_ENV)
62 afs_BozonInit(&avc->pvnLock, avc);
67 osi_AttachVnode(struct vcache *avc, int seq) { }
70 osi_PostPopulateVCache(struct vcache *avc) {
71 AFSTOV(avc)->v_op = afs_ops;
72 AFSTOV(avc)->v_vfsp = afs_globalVFS;
76 /* Normally we do this in osi_vnhold when we notice the ref count went from
77 * 0 -> 1. But if we just setup or reused a vcache, we set the refcount to
78 * 1 directly. So, we must explicitly VFS_HOLD here. */
79 VFS_HOLD(afs_globalVFS);