Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afs / afs_bypasscache.h
CommitLineData
805e021f
CE
1/*
2 * COPYRIGHT © 2000
3 * THE REGENTS OF THE UNIVERSITY OF MICHIGAN
4 * ALL RIGHTS RESERVED
5 *
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
15 * also be included.
16 *
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
28 * SUCH DAMAGES.
29 */
30
31 /*
32 * Portions Copyright (c) 2008
33 * The Linux Box Corporation
34 * ALL RIGHTS RESERVED
35 *
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
45 * also be included.
46 *
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.
58 */
59
60
61#ifndef _AFS_BYPASSCACHE_H
62#define _AFS_BYPASSCACHE_H
63
64#if defined(AFS_CACHE_BYPASS) || defined(UKERNEL)
65#include <afsconfig.h>
66#include "afs/param.h"
67#include "afs/sysincludes.h"
68#include "afsincludes.h"
69
70#define AFS_CACHE_BYPASS_DISABLED -1
71
72#ifdef UKERNEL
73#ifndef PAGE_CACHE_SIZE
74#define PAGE_CACHE_SIZE 4096
75#endif
76#endif
77
78/* A ptr to an object of the following type is expected to be passed
79 * as the ab->parm[0] to afs_BQueue */
80struct nocache_read_request {
81 /* Why can't we all get along? */
82#if defined(AFS_SUN5_ENV)
83 /* SOLARIS */
84 u_offset_t offset;
85 struct seg *segment;
86 caddr_t address;
87#elif defined(AFS_LINUX24_ENV) || defined(UKERNEL)
88 /* The tested platform, as CITI impl. just packs ab->parms */
89 struct uio *auio;
90 struct vrequest *areq;
91 afs_size_t offset;
92 afs_size_t length;
93#endif
94};
95
96enum cache_bypass_strategies
97{
98 ALWAYS_BYPASS_CACHE,
99 NEVER_BYPASS_CACHE,
100 LARGE_FILES_BYPASS_CACHE
101};
102
103extern int cache_bypass_prefetch;
104extern int cache_bypass_strategy;
105extern afs_size_t cache_bypass_threshold;
106
107void afs_TransitionToBypass(struct vcache *, afs_ucred_t *, int);
108void afs_TransitionToCaching(struct vcache *, afs_ucred_t *, int);
109
110/* Cache strategy permits vnode transition between caching and no-cache--
111 * currently, this means LARGE_FILES_BYPASS_CACHE. Currently, no pioctl permits
112 * setting FCSBypass manually for a vnode */
113#define variable_cache_strategy \
114 (! ((cache_bypass_strategy == ALWAYS_BYPASS_CACHE) || \
115 (cache_bypass_strategy == NEVER_BYPASS_CACHE)) )
116
117/* Cache-coherently toggle cache/no-cache for a vnode */
118#define trydo_cache_transition(avc, credp, bypasscache) \
119 do { \
120 if(variable_cache_strategy) { \
121 if(bypasscache) { \
122 if(!(avc->cachingStates & FCSBypass)) \
123 afs_TransitionToBypass(avc, credp, TRANSChangeDesiredBit); \
124 } else { \
125 if(avc->cachingStates & FCSBypass) \
126 afs_TransitionToCaching(avc, credp, TRANSChangeDesiredBit); \
127 } \
128 } \
129 } \
130 while(0);
131
132/* dispatch a no-cache read request */
133afs_int32
134afs_ReadNoCache(struct vcache *avc, struct nocache_read_request *bparms,
135 afs_ucred_t *acred) AFS_NONNULL((1,2));
136
137/* no-cache prefetch routine */
138afs_int32
139afs_PrefetchNoCache(struct vcache *avc, afs_ucred_t *acred,
140 struct nocache_read_request *bparms);
141
142#endif /* AFS_CACHE_BYPASS || UKERNEL */
143#endif /* _AFS_BYPASSCACHE_H */