convert-vcache-casts-to-macros-20020325
[openafs.git] / src / afs / HPUX / osi_vm.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 RCSID("$Header$");
14
15 #include "../afs/sysincludes.h" /* Standard vendor system headers */
16 #include "../afs/afsincludes.h" /* Afs-based standard headers */
17 #include "../afs/afs_stats.h"  /* statistics */
18
19 /* Try to discard pages, in order to recycle a vcache entry.
20  *
21  * We also make some sanity checks:  ref count, open count, held locks.
22  *
23  * We also do some non-VM-related chores, such as releasing the cred pointer
24  * (for AIX and Solaris) and releasing the gnode (for AIX).
25  *
26  * Locking:  afs_xvcache lock is held.  If it is dropped and re-acquired,
27  *   *slept should be set to warn the caller.
28  *
29  * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
30  * is not dropped and re-acquired for any platform.  It may be that *slept is
31  * therefore obsolescent.
32  */
33 int
34 osi_VM_FlushVCache(avc, slept)
35     struct vcache *avc;
36     int *slept;
37 {
38     if (avc->vrefCount > 1)
39         return EBUSY;
40
41     if (avc->opens)
42         return EBUSY;
43
44     return 0;
45 }
46
47 /* Try to store pages to cache, in order to store a file back to the server.
48  *
49  * Locking:  the vcache entry's lock is held.  It will usually be dropped and
50  * re-obtained.
51  */
52 void
53 osi_VM_StoreAllSegments(avc)
54     struct vcache *avc;
55 {
56     ;   /* Nothing here yet */
57 }
58
59 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
60  * try to free pages, when deleting a file.
61  *
62  * Locking:  the vcache entry's lock is held.  It may be dropped and 
63  * re-obtained.
64  */
65 void
66 osi_VM_TryToSmush(avc, acred, sync)
67     struct vcache *avc;
68     struct AFS_UCRED *acred;
69     int sync;
70 {
71     struct vnode *vp = AFSTOV(avc);
72
73     /* Flush the delayed write blocks associated with this vnode
74      * from the buffer cache
75      */
76     if ((vp->v_flag & VTEXT) == 0) {
77         mpurge(vp);
78     }
79     /* Mark the cached blocks on the free list as invalid; it invalidates blocks
80      * associated with vp which are on the freelist.
81      */
82     binvalfree(vp);
83     mpurge(vp);
84 }
85
86 /* Purge VM for a file when its callback is revoked.
87  *
88  * Locking:  No lock is held, not even the global lock.
89  */
90 void
91 osi_VM_FlushPages(avc, credp)
92     struct vcache *avc;
93     struct AFS_UCRED *credp;
94 {
95     ;   /* Nothing here yet */
96 }
97
98 /* Purge pages beyond end-of-file, when truncating a file.
99  *
100  * Locking:  no lock is held, not even the global lock.
101  * activeV is raised.  This is supposed to block pageins, but at present
102  * it only works on Solaris.
103  */
104 void
105 osi_VM_Truncate(avc, alen, acred)
106     struct vcache *avc;
107     int alen;
108     struct AFS_UCRED *acred;
109 {
110     ;   /* Nothing here yet */
111 }