Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afs / AIX / osi_vcache.c
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
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
8 */
9
10 #include <afsconfig.h>
11 #include "afs/param.h"
12
13 #include "afs/sysincludes.h" /*Standard vendor system headers */
14 #include "afsincludes.h" /*AFS-based standard headers */
15
16 extern struct vnodeops *afs_ops;
17
18 int
19 osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
20 int code;
21 if (!VREFCOUNT_GT(avc,0)
22 && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0) {
23 code = afs_FlushVCache(avc, slept);
24 if (code == 0)
25 return 1;
26 }
27 return 0;
28 }
29
30 struct vcache *
31 osi_NewVnode(void) {
32 struct vcache *tvc;
33
34 tvc = afs_osi_Alloc(sizeof(struct vcache));
35 osi_Assert(tvc != NULL);
36
37 #ifdef KERNEL_HAVE_PIN
38 pin((char *)tvc, sizeof(struct vcache)); /* XXX */
39 #endif
40
41 return tvc;
42 }
43
44 void
45 osi_PrePopulateVCache(struct vcache *avc) {
46 memset(avc, 0, sizeof(struct vcache));
47
48 #ifdef AFS_AIX32_ENV
49 LOCK_INIT(&avc->pvmlock, "vcache pvmlock");
50 avc->vmh = avc->segid = NULL;
51 avc->credp = NULL;
52 #endif
53
54 /* Don't forget to free the gnode space */
55 avc->v.v_gnode = osi_AllocSmallSpace(sizeof(struct gnode));
56 memset(avc->v.v_gnode, 0, sizeof(struct gnode));
57 }
58
59 void
60 osi_AttachVnode(struct vcache *avc, int seq) { }
61
62 void
63 osi_PostPopulateVCache(struct vcache *avc) {
64 avc->v.v_op = afs_ops;
65
66 avc->v.v_vfsp = afs_globalVFS;
67 avc->v.v_type = VREG;
68
69 avc->v.v_vfsnext = afs_globalVFS->vfs_vnodes; /* link off vfs */
70 avc->v.v_vfsprev = NULL;
71 afs_globalVFS->vfs_vnodes = &avc->v;
72 if (avc->v.v_vfsnext != NULL)
73 avc->v.v_vfsnext->v_vfsprev = &avc->v;
74 avc->v.v_next = avc->v.v_gnode->gn_vnode; /*Single vnode per gnode for us! */
75 avc->v.v_gnode->gn_vnode = &avc->v;
76 }
77