Remove the RCSID macro
[openafs.git] / src / afs / OBSD / 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
11 /* osi_vm.c implements:
12  *
13  * osi_VM_FlushVCache(avc, slept)
14  * osi_ubc_flush_dirty_and_wait(vp, flags)
15  * osi_VM_StoreAllSegments(avc)
16  * osi_VM_TryToSmush(avc, acred, sync)
17  * osi_VM_FlushPages(avc, credp)
18  * osi_VM_Truncate(avc, alen, acred)
19  */
20
21 #include <afsconfig.h>
22 #include "afs/param.h"
23
24
25 #include "afs/sysincludes.h"    /* Standard vendor system headers */
26 #include "afs/afsincludes.h"    /* Afs-based standard headers */
27 #include "afs/afs_stats.h"      /* statistics */
28 #include <sys/namei.h>
29 #include <limits.h>
30 #include <float.h>
31
32 /* Try to discard pages, in order to recycle a vcache entry.
33  *
34  * We also make some sanity checks:  ref count, open count, held locks.
35  *
36  * We also do some non-VM-related chores, such as releasing the cred pointer
37  * (for AIX and Solaris) and releasing the gnode (for AIX).
38  *
39  * Locking:  afs_xvcache lock is held.  If it is dropped and re-acquired,
40  *   *slept should be set to warn the caller.
41  *
42  * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
43  * is not dropped and re-acquired for any platform.  It may be that *slept is
44  * therefore obsolescent.
45  *
46  * OSF/1 Locking:  VN_LOCK has been called.
47  */
48 int
49 osi_VM_FlushVCache(struct vcache *avc, int *slept)
50 {
51     struct vnode *vp = AFSTOV(avc);
52
53     if (!vp)
54         return 0;
55     AFS_GUNLOCK();
56
57     cache_purge(vp);
58     uvm_vnp_uncache(vp);
59
60     AFS_GLOCK();
61     return 0;
62 }
63
64 /* Try to store pages to cache, in order to store a file back to the server.
65  *
66  * Locking:  the vcache entry's lock is held.  It will usually be dropped and
67  * re-obtained.
68  *
69  */
70 void
71 osi_VM_StoreAllSegments(struct vcache *avc)
72 {
73 }
74
75 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
76  * try to free pages, when deleting a file.
77  *
78  * Locking:  the vcache entry's lock is held.  It may be dropped and
79  * re-obtained.
80  *
81  * Since we drop and re-obtain the lock, we can't guarantee that there won't
82  * be some pages around when we return, newly created by concurrent activity.
83  */
84 void
85 osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
86 {
87     ReleaseWriteLock(&avc->lock);
88     osi_VM_FlushVCache(avc, NULL);
89     ObtainWriteLock(&avc->lock, 59);
90 }
91
92 /* Purge VM for a file when its callback is revoked.
93  *
94  * Locking:  No lock is held, not even the global lock.
95  */
96 void
97 osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
98 {
99     struct vnode *vp = AFSTOV(avc);
100
101     if (!vp)
102         return;
103     cache_purge(vp);
104     uvm_vnp_uncache(vp);
105     uvm_vnp_setsize(vp, avc->m.Length);
106 }
107
108 /* Purge pages beyond end-of-file, when truncating a file.
109  *
110  * Locking:  no lock is held, not even the global lock.
111  * activeV is raised.  This is supposed to block pageins, but at present
112  * it only works on Solaris.
113  */
114 void
115 osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
116 {
117     uvm_vnp_setsize(AFSTOV(avc), alen);
118 }