1 /* Copyright (C) 1998 Transarc Corporation - All rights reserved. */
3 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
4 * LICENSED MATERIALS - PROPERTY OF IBM
7 #include "../afs/param.h" /* Should be always first */
8 #include "../afs/sysincludes.h" /* Standard vendor system headers */
9 #include "../afs/afsincludes.h" /* Afs-based standard headers */
10 #include "../afs/afs_stats.h" /* statistics */
12 /* Linux VM operations
14 * The general model for Linux is to treat vm as a cache that's:
15 * 1) explicitly updated by AFS when AFS writes the data to the cache file.
16 * 2) reads go through the cache. A cache miss is satisfied by the filesystem.
18 * This means flushing VM is not required on this OS.
21 /* Try to discard pages, in order to recycle a vcache entry.
23 * We also make some sanity checks: ref count, open count, held locks.
25 * We also do some non-VM-related chores, such as releasing the cred pointer
26 * (for AIX and Solaris) and releasing the gnode (for AIX).
28 * Locking: afs_xvcache lock is held. If it is dropped and re-acquired,
29 * *slept should be set to warn the caller.
31 * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
32 * is not dropped and re-acquired for any platform. It may be that *slept is
33 * therefore obsolescent.
35 int osi_VM_FlushVCache(struct vcache *avc, int *slept)
37 struct inode *ip = (struct inode*)avc;
39 if (avc->vrefCount != 0)
45 invalidate_inode_pages(ip);
49 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
50 * try to free pages, when deleting a file.
52 * Locking: the vcache entry's lock is held. It may be dropped and
55 * Since we drop and re-obtain the lock, we can't guarantee that there won't
56 * be some pages around when we return, newly created by concurrent activity.
58 void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
60 invalidate_inode_pages((struct inode *)avc);
63 /* Flush and invalidate pages, for fsync() with INVAL flag
65 * Locking: only the global lock is held.
67 void osi_VM_FSyncInval(struct vcache *avc)
72 /* Try to store pages to cache, in order to store a file back to the server.
74 * Locking: the vcache entry's lock is held. It will usually be dropped and
77 void osi_VM_StoreAllSegments(struct vcache *avc)
82 /* Purge VM for a file when its callback is revoked.
84 * Locking: No lock is held, not even the global lock.
86 void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
88 invalidate_inode_pages((struct inode*)avc);
91 /* Purge pages beyond end-of-file, when truncating a file.
93 * Locking: no lock is held, not even the global lock.
94 * activeV is raised. This is supposed to block pageins, but at present
95 * it only works on Solaris.
97 void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
99 invalidate_inode_pages((struct inode*)avc);