blob: 2f96754910950b59b26ac4a2046808cc7bf043c1 [file] [log] [blame]
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -05001/*
2 * V9FS cache definitions.
3 *
4 * Copyright (C) 2009 by Abhishek Kulkarni <adkulkar@umail.iu.edu>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to:
17 * Free Software Foundation
18 * 51 Franklin Street, Fifth Floor
19 * Boston, MA 02111-1301 USA
20 *
21 */
22
23#ifndef _9P_CACHE_H
24#ifdef CONFIG_9P_FSCACHE
25#include <linux/fscache.h>
26#include <linux/spinlock.h>
27
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050028extern struct fscache_netfs v9fs_cache_netfs;
29extern const struct fscache_cookie_def v9fs_cache_session_index_def;
30extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
31
32extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
33extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
34
35extern void v9fs_cache_inode_get_cookie(struct inode *inode);
36extern void v9fs_cache_inode_put_cookie(struct inode *inode);
37extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
38extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
39extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
40
41extern int __v9fs_cache_register(void);
42extern void __v9fs_cache_unregister(void);
43
44extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
45extern void __v9fs_fscache_invalidate_page(struct page *page);
46extern int __v9fs_readpage_from_fscache(struct inode *inode,
47 struct page *page);
48extern int __v9fs_readpages_from_fscache(struct inode *inode,
49 struct address_space *mapping,
50 struct list_head *pages,
51 unsigned *nr_pages);
52extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
Aneesh Kumar K.V2efda792011-02-28 17:03:56 +053053extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
54 struct page *page);
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050055
56static inline int v9fs_fscache_release_page(struct page *page,
57 gfp_t gfp)
58{
59 return __v9fs_fscache_release_page(page, gfp);
60}
61
62static inline void v9fs_fscache_invalidate_page(struct page *page)
63{
64 __v9fs_fscache_invalidate_page(page);
65}
66
67static inline int v9fs_readpage_from_fscache(struct inode *inode,
68 struct page *page)
69{
70 return __v9fs_readpage_from_fscache(inode, page);
71}
72
73static inline int v9fs_readpages_from_fscache(struct inode *inode,
74 struct address_space *mapping,
75 struct list_head *pages,
76 unsigned *nr_pages)
77{
78 return __v9fs_readpages_from_fscache(inode, mapping, pages,
79 nr_pages);
80}
81
82static inline void v9fs_readpage_to_fscache(struct inode *inode,
83 struct page *page)
84{
85 if (PageFsCache(page))
86 __v9fs_readpage_to_fscache(inode, page);
87}
88
89static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
90{
Aneesh Kumar K.Va78ce052011-02-28 17:04:02 +053091 struct v9fs_inode *v9inode = V9FS_I(inode);
92 fscache_uncache_page(v9inode->fscache, page);
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050093 BUG_ON(PageFsCache(page));
94}
95
Aneesh Kumar K.V2efda792011-02-28 17:03:56 +053096static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
97 struct page *page)
98{
99 return __v9fs_fscache_wait_on_page_write(inode, page);
100}
101
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500102#else /* CONFIG_9P_FSCACHE */
103
Al Viroceaec152013-09-17 08:07:11 -0400104static inline void v9fs_cache_inode_get_cookie(struct inode *inode)
105{
106}
107
108static inline void v9fs_cache_inode_put_cookie(struct inode *inode)
109{
110}
111
112static inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *file)
113{
114}
115
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500116static inline int v9fs_fscache_release_page(struct page *page,
117 gfp_t gfp) {
118 return 1;
119}
120
121static inline void v9fs_fscache_invalidate_page(struct page *page) {}
122
123static inline int v9fs_readpage_from_fscache(struct inode *inode,
124 struct page *page)
125{
126 return -ENOBUFS;
127}
128
129static inline int v9fs_readpages_from_fscache(struct inode *inode,
130 struct address_space *mapping,
131 struct list_head *pages,
132 unsigned *nr_pages)
133{
134 return -ENOBUFS;
135}
136
137static inline void v9fs_readpage_to_fscache(struct inode *inode,
138 struct page *page)
139{}
140
141static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
142{}
143
Aneesh Kumar K.V2efda792011-02-28 17:03:56 +0530144static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
145 struct page *page)
146{
147 return;
148}
149
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500150#endif /* CONFIG_9P_FSCACHE */
151#endif /* _9P_CACHE_H */