From d82a3d7e2c126950382e3db24e8494de5a1db2a0 Mon Sep 17 00:00:00 2001 From: Hartmut Reuter Date: Thu, 18 Oct 2012 07:00:18 -0400 Subject: [PATCH] linux: fix cache bypass applicability function don't allow cache bypass if execsOrWriters is true don't trigger cache bypass based on being larger than the "disabled" value of -1. Change-Id: Ic174b133e5da3e9215465c9c2705c25e81a8beca Reviewed-on: http://gerrit.openafs.org/8248 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/LINUX/osi_vnodeops.c | 3 ++- src/afs/afs_pioctl.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 4a4c96a26..11062ce4e 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -2241,13 +2241,14 @@ afs_linux_bypass_readpage(struct file *fp, struct page *pp) static inline int afs_linux_can_bypass(struct inode *ip) { + switch(cache_bypass_strategy) { case NEVER_BYPASS_CACHE: return 0; case ALWAYS_BYPASS_CACHE: return 1; case LARGE_FILES_BYPASS_CACHE: - if(i_size_read(ip) > cache_bypass_threshold) + if (i_size_read(ip) > cache_bypass_threshold) return 1; default: return 0; diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 0836b873d..0d7747186 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -5093,7 +5093,12 @@ DECL_PIOCTL(PSetCachingThreshold) cache_bypass_threshold = threshold; afs_warn("Cache Bypass Threshold set to: %d\n", threshold); /* TODO: move to separate pioctl, or enhance pioctl */ - cache_bypass_strategy = LARGE_FILES_BYPASS_CACHE; + if (threshold == AFS_CACHE_BYPASS_DISABLED) + cache_bypass_strategy = NEVER_BYPASS_CACHE; + else if (!threshold) + cache_bypass_strategy = ALWAYS_BYPASS_CACHE; + else + cache_bypass_strategy = LARGE_FILES_BYPASS_CACHE; } /* Return the current size threshold */ -- 2.39.5