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