3 * THE REGENTS OF THE UNIVERSITY OF MICHIGAN
6 * Permission is granted to use, copy, create derivative works
7 * and redistribute this software and such derivative works
8 * for any purpose, so long as the name of The University of
9 * Michigan is not used in any advertising or publicity
10 * pertaining to the use of distribution of this software
11 * without specific, written prior authorization. If the
12 * above copyright notice or any other identification of the
13 * University of Michigan is included in any copy of any
14 * portion of this software, then the disclaimer below must
17 * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION
18 * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY
19 * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY O
20 * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
21 * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
23 * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE
24 * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR
25 * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING
26 * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
27 * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF
32 * Portions Copyright (c) 2008
33 * The Linux Box Corporation
36 * Permission is granted to use, copy, create derivative works
37 * and redistribute this software and such derivative works
38 * for any purpose, so long as the name of the Linux Box
39 * Corporation is not used in any advertising or publicity
40 * pertaining to the use or distribution of this software
41 * without specific, written prior authorization. If the
42 * above copyright notice or any other identification of the
43 * Linux Box Corporation is included in any copy of any
44 * portion of this software, then the disclaimer below must
47 * This software is provided as is, without representation
48 * from the Linux Box Corporation as to its fitness for any
49 * purpose, and without warranty by the Linux Box Corporation
50 * of any kind, either express or implied, including
51 * without limitation the implied warranties of
52 * merchantability and fitness for a particular purpose. The
53 * Linux Box Corporation shall not be liable for any damages,
54 * including special, indirect, incidental, or consequential
55 * damages, with respect to any claim arising out of or in
56 * connection with the use of the software, even if it has been
57 * or is hereafter advised of the possibility of such damages.
61 #ifndef _AFS_BYPASSCACHE_H
62 #define _AFS_BYPASSCACHE_H
64 #if defined(AFS_CACHE_BYPASS)
66 #include <afsconfig.h>
67 #include "afs/param.h"
68 #include "afs/sysincludes.h"
69 #include "afsincludes.h"
71 #define AFS_CACHE_BYPASS_DISABLED -1
75 #define PAGE_SIZE 1024 * sizeof(long) / 8
79 /* A ptr to an object of the following type is expected to be passed
80 * as the ab->parm[0] to afs_BQueue */
81 struct nocache_read_request {
82 /* Why can't we all get along? */
83 #if defined(AFS_SUN5_ENV)
88 #elif defined(AFS_SGI_ENV)
89 /* SGI (of some vintage) */
94 #elif defined(AFS_LINUX24_ENV) || defined(AFS_USR_LINUX24_ENV)
95 /* The tested platform, as CITI impl. just packs ab->parms */
97 struct vrequest *areq;
103 enum cache_bypass_strategies
107 LARGE_FILES_BYPASS_CACHE
110 extern int cache_bypass_prefetch;
111 extern int cache_bypass_strategy;
112 extern int cache_bypass_threshold;
114 void afs_TransitionToBypass(struct vcache *, afs_ucred_t *, int);
115 void afs_TransitionToCaching(struct vcache *, afs_ucred_t *, int);
117 /* Cache strategy permits vnode transition between caching and no-cache--
118 * currently, this means LARGE_FILES_BYPASS_CACHE. Currently, no pioctl permits
119 * setting FCSBypass manually for a vnode */
120 #define variable_cache_strategy \
121 (! ((cache_bypass_strategy == ALWAYS_BYPASS_CACHE) || \
122 (cache_bypass_strategy == NEVER_BYPASS_CACHE)) )
124 /* Cache-coherently toggle cache/no-cache for a vnode */
125 #define trydo_cache_transition(avc, credp, bypasscache) \
127 if(variable_cache_strategy) { \
129 if(!(avc->cachingStates & FCSBypass)) \
130 afs_TransitionToBypass(avc, credp, TRANSChangeDesiredBit); \
132 if(avc->cachingStates & FCSBypass) \
133 afs_TransitionToCaching(avc, credp, TRANSChangeDesiredBit); \
139 /* dispatch a no-cache read request */
141 afs_ReadNoCache(struct vcache *avc, struct nocache_read_request *bparms,
144 /* no-cache prefetch routine */
146 afs_PrefetchNoCache(struct vcache *avc, afs_ucred_t *acred,
147 struct nocache_read_request *bparms);
150 #endif /* AFS_CACHE_BYPASS */
151 #endif /* _AFS_BYPASSCACHE_H */