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
) {
19 /* we can't control whether we sleep */
20 if (!VREFCOUNT_GT(avc
,0)
21 && avc
->opens
== 0 && (avc
->f
.states
& CUnlinkedDel
) == 0) {
22 code
= afs_FlushVCache(avc
, slept
);
29 extern char *makesname();
34 char name
[METER_NAMSZ
];
36 avc
= afs_osi_Alloc(sizeof(struct vcache
));
38 memset(avc
, 0, sizeof(struct vcache
));
39 avc
->v
.v_number
= ++afsvnumbers
;
40 avc
->vc_rwlockid
= OSI_NO_LOCKID
;
41 initnsema(&avc
->vc_rwlock
, 1,
42 makesname(name
, "vrw", avc
->v
.v_number
));
44 initnsema(&avc
->v
.v_sync
, 0,
45 makesname(name
, "vsy", avc
->v
.v_number
));
48 initnlock(&avc
->v
.v_lock
,
49 makesname(name
, "vlk", avc
->v
.v_number
));
55 osi_PrePopulateVCache(struct vcache
*avc
) {
57 memset(&(avc
->f
), 0, sizeof(struct fvcache
));
61 osi_AttachVnode(struct vcache
*avc
, int seq
) { }
64 osi_PostPopulateVCache(struct vcache
*avc
) {
65 memset(&(avc
->vc_bhv_desc
), 0, sizeof(avc
->vc_bhv_desc
));
66 bhv_desc_init(&(avc
->vc_bhv_desc
), avc
, avc
, &Afs_vnodeops
);
68 #if defined(AFS_SGI65_ENV)
69 vn_bhv_head_init(&(avc
->v
.v_bh
), "afsvp");
70 vn_bhv_insert_initial(&(avc
->v
.v_bh
), &(avc
->vc_bhv_desc
));
71 avc
->v
.v_mreg
= avc
->v
.v_mregb
= (struct pregion
*)avc
;
72 # if defined(VNODE_TRACING)
73 avc
->v
.v_trace
= ktrace_alloc(VNODE_TRACE_SIZE
, 0);
75 init_bitlock(&avc
->v
.v_pcacheflag
, VNODE_PCACHE_LOCKBIT
, "afs_pcache",
77 init_mutex(&avc
->v
.v_filocksem
, MUTEX_DEFAULT
, "afsvfl", (long)avc
);
78 init_mutex(&avc
->v
.v_buf_lock
, MUTEX_DEFAULT
, "afsvnbuf", (long)avc
);
80 bhv_head_init(&(avc
->v
.v_bh
));
81 bhv_insert_initial(&(avc
->v
.v_bh
), &(avc
->vc_bhv_desc
));
84 vnode_pcache_init(&avc
->v
);
86 #if defined(DEBUG) && defined(VNODE_INIT_BITLOCK)
87 /* Above define is never true execpt in SGI test kernels. */
88 init_bitlock(&avc
->v
.v_flag
, VLOCK
, "vnode", avc
->v
.v_number
);
92 AFS_VN_INIT_BUF_LOCK(&(avc
->v
));
95 vSetVfsp(avc
, afs_globalVFS
);
98 VN_SET_DPAGES(&(avc
->v
), NULL
);
99 osi_Assert((avc
->v
.v_flag
& VINACT
) == 0);
101 osi_Assert(VN_GET_PGCNT(&(avc
->v
)) == 0);
102 osi_Assert(avc
->mapcnt
== 0 && avc
->vc_locktrips
== 0);
103 osi_Assert(avc
->vc_rwlockid
== OSI_NO_LOCKID
);
104 osi_Assert(avc
->v
.v_filocks
== NULL
);
105 # if !defined(AFS_SGI65_ENV)
106 osi_Assert(avc
->v
.v_filocksem
== NULL
);
108 osi_Assert(avc
->cred
== NULL
);
109 # if defined(AFS_SGI64_ENV)
110 vnode_pcache_reinit(&avc
->v
);
111 avc
->v
.v_rdev
= NODEV
;
113 vn_initlist((struct vnlist
*)&avc
->v
);