AIX: declare code in osi_TryEvictVCache
[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) {
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 = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
35
36 #ifdef  KERNEL_HAVE_PIN
37     pin((char *)tvc, sizeof(struct vcache));    /* XXX */
38 #endif
39
40     return tvc;
41 }
42
43 void
44 osi_PrePopulateVCache(struct vcache *avc) {
45     memset(avc, 0, sizeof(struct vcache));
46
47 #ifdef  AFS_AIX32_ENV
48     LOCK_INIT(&avc->pvmlock, "vcache pvmlock");
49     avc->vmh = avc->segid = NULL;
50     avc->credp = NULL;
51 #endif
52
53     /* Don't forget to free the gnode space */
54     avc->v.v_gnode = osi_AllocSmallSpace(sizeof(struct gnode));
55     memset(avc->v.v_gnode, 0, sizeof(struct gnode));
56 }
57
58 void
59 osi_AttachVnode(struct vcache *avc, int seq) { }
60
61 void
62 osi_PostPopulateVCache(struct vcache *avc) {
63     avc->v.v_op = afs_ops;
64
65     avc->v.v_vfsp = afs_globalVFS;
66     avc->v.v_type = VREG;
67
68     avc->v.v_vfsnext = afs_globalVFS->vfs_vnodes;       /* link off vfs */
69     avc->v.v_vfsprev = NULL;
70     afs_globalVFS->vfs_vnodes = &avc->v;
71     if (avc->v.v_vfsnext != NULL)
72         avc->v.v_vfsnext->v_vfsprev = &avc->v;
73     avc->v.v_next = avc->v.v_gnode->gn_vnode;   /*Single vnode per gnode for us! */
74     avc->v.v_gnode->gn_vnode = &avc->v;
75 }
76