1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _9P_CACHE_H
24#ifdef CONFIG_9P_FSCACHE
25#include <linux/fscache.h>
26#include <linux/spinlock.h>
27
28extern struct kmem_cache *vcookie_cache;
29
30struct v9fs_cookie {
31 spinlock_t lock;
32 struct inode inode;
33 struct fscache_cookie *fscache;
34 struct p9_qid *qid;
35};
36
37static inline struct v9fs_cookie *v9fs_inode2cookie(const struct inode *inode)
38{
39 return container_of(inode, struct v9fs_cookie, inode);
40}
41
42extern struct fscache_netfs v9fs_cache_netfs;
43extern const struct fscache_cookie_def v9fs_cache_session_index_def;
44extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
45
46extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
47extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
48
49extern void v9fs_cache_inode_get_cookie(struct inode *inode);
50extern void v9fs_cache_inode_put_cookie(struct inode *inode);
51extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
52extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
53extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
54
55extern int __v9fs_cache_register(void);
56extern void __v9fs_cache_unregister(void);
57
58extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
59extern void __v9fs_fscache_invalidate_page(struct page *page);
60extern int __v9fs_readpage_from_fscache(struct inode *inode,
61 struct page *page);
62extern int __v9fs_readpages_from_fscache(struct inode *inode,
63 struct address_space *mapping,
64 struct list_head *pages,
65 unsigned *nr_pages);
66extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
67
68
69
70
71
72static inline int v9fs_cache_register(void)
73{
74 return __v9fs_cache_register();
75}
76
77
78
79
80static inline void v9fs_cache_unregister(void)
81{
82 __v9fs_cache_unregister();
83}
84
85static inline int v9fs_fscache_release_page(struct page *page,
86 gfp_t gfp)
87{
88 return __v9fs_fscache_release_page(page, gfp);
89}
90
91static inline void v9fs_fscache_invalidate_page(struct page *page)
92{
93 __v9fs_fscache_invalidate_page(page);
94}
95
96static inline int v9fs_readpage_from_fscache(struct inode *inode,
97 struct page *page)
98{
99 return __v9fs_readpage_from_fscache(inode, page);
100}
101
102static inline int v9fs_readpages_from_fscache(struct inode *inode,
103 struct address_space *mapping,
104 struct list_head *pages,
105 unsigned *nr_pages)
106{
107 return __v9fs_readpages_from_fscache(inode, mapping, pages,
108 nr_pages);
109}
110
111static inline void v9fs_readpage_to_fscache(struct inode *inode,
112 struct page *page)
113{
114 if (PageFsCache(page))
115 __v9fs_readpage_to_fscache(inode, page);
116}
117
118static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
119{
120 struct v9fs_cookie *vcookie = v9fs_inode2cookie(inode);
121 fscache_uncache_page(vcookie->fscache, page);
122 BUG_ON(PageFsCache(page));
123}
124
125static inline void v9fs_vcookie_set_qid(struct inode *inode,
126 struct p9_qid *qid)
127{
128 struct v9fs_cookie *vcookie = v9fs_inode2cookie(inode);
129 spin_lock(&vcookie->lock);
130 vcookie->qid = qid;
131 spin_unlock(&vcookie->lock);
132}
133
134#else
135
136static inline int v9fs_cache_register(void)
137{
138 return 1;
139}
140
141static inline void v9fs_cache_unregister(void) {}
142
143static inline int v9fs_fscache_release_page(struct page *page,
144 gfp_t gfp) {
145 return 1;
146}
147
148static inline void v9fs_fscache_invalidate_page(struct page *page) {}
149
150static inline int v9fs_readpage_from_fscache(struct inode *inode,
151 struct page *page)
152{
153 return -ENOBUFS;
154}
155
156static inline int v9fs_readpages_from_fscache(struct inode *inode,
157 struct address_space *mapping,
158 struct list_head *pages,
159 unsigned *nr_pages)
160{
161 return -ENOBUFS;
162}
163
164static inline void v9fs_readpage_to_fscache(struct inode *inode,
165 struct page *page)
166{}
167
168static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
169{}
170
171static inline void v9fs_vcookie_set_qid(struct inode *inode,
172 struct p9_qid *qid)
173{}
174
175#endif
176#endif
177