Standardize License information
[openafs.git] / src / afs / LINUX / 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 "../afs/param.h"       /* Should be always first */
11 #include "../afs/sysincludes.h" /* Standard vendor system headers */
12 #include "../afs/afsincludes.h" /* Afs-based standard headers */
13 #include "../afs/afs_stats.h"   /* statistics */
14
15 /* Linux VM operations
16  *
17  * The general model for Linux is to treat vm as a cache that's:
18  * 1) explicitly updated by AFS when AFS writes the data to the cache file.
19  * 2) reads go through the cache. A cache miss is satisfied by the filesystem.
20  *
21  * This means flushing VM is not required on this OS.
22  */
23
24 /* Try to discard pages, in order to recycle a vcache entry.
25  *
26  * We also make some sanity checks:  ref count, open count, held locks.
27  *
28  * We also do some non-VM-related chores, such as releasing the cred pointer
29  * (for AIX and Solaris) and releasing the gnode (for AIX).
30  *
31  * Locking:  afs_xvcache lock is held.  If it is dropped and re-acquired,
32  *   *slept should be set to warn the caller.
33  *
34  * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
35  * is not dropped and re-acquired for any platform.  It may be that *slept is
36  * therefore obsolescent.
37  */
38 int osi_VM_FlushVCache(struct vcache *avc, int *slept)
39 {
40     struct inode *ip = (struct inode*)avc;
41
42     if (avc->vrefCount != 0)
43         return EBUSY;
44
45     if (avc->opens != 0)
46         return EBUSY;
47
48     invalidate_inode_pages(ip);
49     return 0;
50 }
51
52 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
53  * try to free pages, when deleting a file.
54  *
55  * Locking:  the vcache entry's lock is held.  It may be dropped and 
56  * re-obtained.
57  *
58  * Since we drop and re-obtain the lock, we can't guarantee that there won't
59  * be some pages around when we return, newly created by concurrent activity.
60  */
61 void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
62 {
63     invalidate_inode_pages((struct inode *)avc);
64 }
65
66 /* Flush and invalidate pages, for fsync() with INVAL flag
67  *
68  * Locking:  only the global lock is held.
69  */
70 void osi_VM_FSyncInval(struct vcache *avc)
71 {
72
73 }
74
75 /* Try to store pages to cache, in order to store a file back to the server.
76  *
77  * Locking:  the vcache entry's lock is held.  It will usually be dropped and
78  * re-obtained.
79  */
80 void osi_VM_StoreAllSegments(struct vcache *avc)
81 {
82
83 }
84
85 /* Purge VM for a file when its callback is revoked.
86  *
87  * Locking:  No lock is held, not even the global lock.
88  */
89 void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
90 {
91     invalidate_inode_pages((struct inode*)avc);
92 }
93
94 /* Purge pages beyond end-of-file, when truncating a file.
95  *
96  * Locking:  no lock is held, not even the global lock.
97  * activeV is raised.  This is supposed to block pageins, but at present
98  * it only works on Solaris.
99  */
100 void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
101 {
102     invalidate_inode_pages((struct inode*)avc);
103 }