From 46a6d6129d80c4027d8a9f0e1d06b32cc12d6367 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Tue, 23 Nov 2010 18:39:33 -0500 Subject: [PATCH] Cache bypass: Only compile bypass code for the Linux kernel Only compile the afs_bypasscache.c code if AFS_LINUX24_ENV is set, since it's currently the only case where the code is actually used. Only sections that caused problems for UKERNEL were previously ifdef'ed. Besides making the code cleaner, the main effect of this change is to prevent compiling most of the bypass code for UKERNEL where it isn't currently used. If support for bypass is added for other platforms eventually, the code here would need to be reworked anyway, ideally abstracting out and moving any OS specific bits into the platform subdirectories. Change-Id: If39294926ea38896ce2dedd1e46b2da0d622cae5 Reviewed-on: http://gerrit.openafs.org/3374 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- src/afs/afs_bypasscache.c | 52 +++------------------------------------ src/afs/afs_pioctl.c | 6 ++--- 2 files changed, 7 insertions(+), 51 deletions(-) diff --git a/src/afs/afs_bypasscache.c b/src/afs/afs_bypasscache.c index 8d7e601a7..45df34e13 100644 --- a/src/afs/afs_bypasscache.c +++ b/src/afs/afs_bypasscache.c @@ -61,7 +61,7 @@ #include #include "afs/param.h" -#if defined(AFS_CACHE_BYPASS) +#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV) #include "afs/afs_bypasscache.h" @@ -75,11 +75,6 @@ #include "afs/nfsclient.h" #include "rx/rx_globals.h" -#if defined(AFS_LINUX26_ENV) -#define LockPage(pp) lock_page(pp) -#define UnlockPage(pp) unlock_page(pp) -#endif - #ifndef afs_min #define afs_min(A,B) ((A)<(B)) ? (A) : (B) #endif @@ -274,7 +269,6 @@ done: * afs_PrefetchNoCache, all of the pages they've been passed need * to be unlocked. */ -#if defined(AFS_LINUX24_ENV) #define unlock_and_release_pages(auio) \ do { \ struct iovec *ciov; \ @@ -287,7 +281,7 @@ done: while(1) { \ if (pp) { \ if (PageLocked(pp)) \ - UnlockPage(pp); \ + unlock_page(pp); \ put_page(pp); /* decrement refcount */ \ } \ iovno++; \ @@ -297,14 +291,6 @@ done: pp = (struct page*) ciov->iov_base; \ } \ } while(0) -#else -#ifdef UKERNEL -#define unlock_and_release_pages(auio) \ - do { } while(0) -#else -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif /* no-cache prefetch routine */ static afs_int32 @@ -377,13 +363,7 @@ afs_NoCacheFetchProc(struct rx_call *acall, clen = ciov->iov_len - iovoff; tlen = afs_min(length, clen); -#ifdef AFS_LINUX24_ENV address = page_buffer; -#else -#ifndef UKERNEL -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif /* LINUX24 */ COND_GUNLOCK(locked); code = rx_Read(acall, address, tlen); COND_RE_GLOCK(locked); @@ -406,33 +386,21 @@ afs_NoCacheFetchProc(struct rx_call *acall, iovoff += code; address += code; } else { -#ifdef AFS_LINUX24_ENV if(pp) { address = kmap_atomic(pp, KM_USER0); memcpy(address, page_buffer, PAGE_SIZE); kunmap_atomic(address, KM_USER0); } -#else -#ifndef UKERNEL -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif /* LINUX 24 */ /* we filled a page, conditionally release it */ if (release_pages && ciov->iov_base) { /* this is appropriate when no caller intends to unlock * and release the page */ -#ifdef AFS_LINUX24_ENV SetPageUptodate(pp); if(PageLocked(pp)) - UnlockPage(pp); + unlock_page(pp); else afs_warn("afs_NoCacheFetchProc: page not locked at iovno %d!\n", iovno); put_page(pp); /* decrement refcount */ -#else -#ifndef UKERNEL -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif /* LINUX24 */ } /* and carry uio_iov */ iovno++; @@ -515,13 +483,7 @@ cleanup: * do everything that would normally happen when the request was * processed, like unlocking the pages and freeing memory. */ -#ifdef AFS_LINUX24_ENV unlock_and_release_pages(bparms->auio); -#else -#ifndef UKERNEL -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif osi_Free(areq, sizeof(struct vrequest)); osi_Free(bparms->auio->uio_iov, bparms->auio->uio_iovcnt * sizeof(struct iovec)); @@ -629,13 +591,7 @@ afs_PrefetchNoCache(struct vcache *avc, } else { afs_warn("BYPASS: No connection.\n"); code = -1; -#ifdef AFS_LINUX24_ENV unlock_and_release_pages(auio); -#else -#ifndef UKERNEL -#error AFS_CACHE_BYPASS not implemented on this platform -#endif -#endif goto done; } } while (afs_Analyze(tc, code, &avc->f.fid, areq, @@ -656,4 +612,4 @@ done: return code; } -#endif /* AFS_CACHE_BYPASS */ +#endif /* AFS_CACHE_BYPASS && AFS_LINUX24_ENV */ diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index b18b45a46..2cd52427a 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -302,7 +302,7 @@ DECL_PIOCTL(PNFSNukeCreds); DECL_PIOCTL(PNewUuid); DECL_PIOCTL(PPrecache); DECL_PIOCTL(PGetPAG); -#if defined(AFS_CACHE_BYPASS) +#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV) DECL_PIOCTL(PSetCachingThreshold); #endif @@ -425,7 +425,7 @@ static pioctlFunction CpioctlSw[] = { static pioctlFunction OpioctlSw[] = { PBogus, /* 0 */ PNFSNukeCreds, /* 1 -- nuke all creds for NFS client */ -#if defined(AFS_CACHE_BYPASS) +#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV) PSetCachingThreshold /* 2 -- get/set cache-bypass size threshold */ #else PNoop /* 2 -- get/set cache-bypass size threshold */ @@ -5041,7 +5041,7 @@ DECL_PIOCTL(PNewUuid) return 0; } -#if defined(AFS_CACHE_BYPASS) +#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV) DECL_PIOCTL(PSetCachingThreshold) { -- 2.39.5