LINUX 5.3.0: Check for 'recurse' arg in keyring_search
[openafs.git] / src / afs / LINUX / osi_vm.c
index 0fa7978..2bea020 100644 (file)
@@ -15,6 +15,8 @@
 #include "afsincludes.h"       /* Afs-based standard headers */
 #include "afs/afs_stats.h"     /* statistics */
 
+#include "osi_compat.h"
+
 /* Linux VM operations
  *
  * The general model for Linux is to treat vm as a cache that's:
  * We also do some non-VM-related chores, such as releasing the cred pointer
  * (for AIX and Solaris) and releasing the gnode (for AIX).
  *
- * Locking:  afs_xvcache lock is held.  If it is dropped and re-acquired,
- *   *slept should be set to warn the caller.
- *
- * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
- * is not dropped and re-acquired for any platform.  It may be that *slept is
- * therefore obsolescent.
+ * Locking:  afs_xvcache lock is held. It must not be dropped.
  */
 int
-osi_VM_FlushVCache(struct vcache *avc, int *slept)
+osi_VM_FlushVCache(struct vcache *avc)
 {
     struct inode *ip = AFSTOV(avc);
 
@@ -49,14 +46,7 @@ osi_VM_FlushVCache(struct vcache *avc, int *slept)
     if (avc->opens != 0)
        return EBUSY;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-    return vmtruncate(ip, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    truncate_inode_pages(ip, 0);
-#else
-    invalidate_inode_pages(ip);
-#endif
-    return 0;
+    return afs_truncate(ip, 0);
 }
 
 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
@@ -69,15 +59,11 @@ osi_VM_FlushVCache(struct vcache *avc, int *slept)
  * be some pages around when we return, newly created by concurrent activity.
  */
 void
-osi_VM_TryToSmush(struct vcache *avc, AFS_UCRED *acred, int sync)
+osi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync)
 {
     struct inode *ip = AFSTOV(avc);
 
-#if defined(AFS_LINUX26_ENV)
-    invalidate_inode_pages(ip->i_mapping);
-#else
-    invalidate_inode_pages(ip);
-#endif
+    invalidate_remote_inode(ip);
 }
 
 /* Flush and invalidate pages, for fsync() with INVAL flag
@@ -100,22 +86,16 @@ osi_VM_StoreAllSegments(struct vcache *avc)
 {
     struct inode *ip = AFSTOV(avc);
 
-    if (avc->f.states & CPageWrite)
+    if (!list_empty(&avc->pagewriters))
        return; /* someone already writing */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
     /* filemap_fdatasync() only exported in 2.4.5 and above */
     ReleaseWriteLock(&avc->lock);
     AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
     filemap_fdatawrite(ip->i_mapping);
-#else
-    filemap_fdatasync(ip->i_mapping);
-#endif
     filemap_fdatawait(ip->i_mapping);
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock, 121);
-#endif
 }
 
 /* Purge VM for a file when its callback is revoked.
@@ -128,19 +108,13 @@ osi_VM_StoreAllSegments(struct vcache *avc)
  * then these callers should be updated.
  */
 void
-osi_VM_FlushPages(struct vcache *avc, AFS_UCRED *credp)
+osi_VM_FlushPages(struct vcache *avc, afs_ucred_t *credp)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     struct inode *ip = AFSTOV(avc);
     
+    afs_linux_lock_inode(ip);
     truncate_inode_pages(&ip->i_data, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = AFSTOV(avc);
-
-    truncate_inode_pages(ip, 0);
-#else
-    invalidate_inode_pages(AFSTOV(avc));
-#endif
+    afs_linux_unlock_inode(ip);
 }
 
 /* Purge pages beyond end-of-file, when truncating a file.
@@ -150,15 +124,7 @@ osi_VM_FlushPages(struct vcache *avc, AFS_UCRED *credp)
  * it only works on Solaris.
  */
 void
-osi_VM_Truncate(struct vcache *avc, int alen, AFS_UCRED *acred)
+osi_VM_Truncate(struct vcache *avc, int alen, afs_ucred_t *acred)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-    vmtruncate(AFSTOV(avc), alen);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = AFSTOV(avc);
-
-    truncate_inode_pages(ip, alen);
-#else
-    invalidate_inode_pages(AFSTOV(avc));
-#endif
+    afs_truncate(AFSTOV(avc), alen);
 }