Merge tag 'linux-can-next-for-4.2-20150506' of git://git.kernel.org/pub/scm/linux...
[linux-2.6/btrfs-unstable.git] / fs / 9p / cache.h
blob2f96754910950b59b26ac4a2046808cc7bf043c1
1 /*
2 * V9FS cache definitions.
4 * Copyright (C) 2009 by Abhishek Kulkarni <adkulkar@umail.iu.edu>
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.
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.
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
23 #ifndef _9P_CACHE_H
24 #ifdef CONFIG_9P_FSCACHE
25 #include <linux/fscache.h>
26 #include <linux/spinlock.h>
28 extern struct fscache_netfs v9fs_cache_netfs;
29 extern const struct fscache_cookie_def v9fs_cache_session_index_def;
30 extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
32 extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
33 extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
35 extern void v9fs_cache_inode_get_cookie(struct inode *inode);
36 extern void v9fs_cache_inode_put_cookie(struct inode *inode);
37 extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
38 extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
39 extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
41 extern int __v9fs_cache_register(void);
42 extern void __v9fs_cache_unregister(void);
44 extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
45 extern void __v9fs_fscache_invalidate_page(struct page *page);
46 extern int __v9fs_readpage_from_fscache(struct inode *inode,
47 struct page *page);
48 extern int __v9fs_readpages_from_fscache(struct inode *inode,
49 struct address_space *mapping,
50 struct list_head *pages,
51 unsigned *nr_pages);
52 extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
53 extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
54 struct page *page);
56 static inline int v9fs_fscache_release_page(struct page *page,
57 gfp_t gfp)
59 return __v9fs_fscache_release_page(page, gfp);
62 static inline void v9fs_fscache_invalidate_page(struct page *page)
64 __v9fs_fscache_invalidate_page(page);
67 static inline int v9fs_readpage_from_fscache(struct inode *inode,
68 struct page *page)
70 return __v9fs_readpage_from_fscache(inode, page);
73 static inline int v9fs_readpages_from_fscache(struct inode *inode,
74 struct address_space *mapping,
75 struct list_head *pages,
76 unsigned *nr_pages)
78 return __v9fs_readpages_from_fscache(inode, mapping, pages,
79 nr_pages);
82 static inline void v9fs_readpage_to_fscache(struct inode *inode,
83 struct page *page)
85 if (PageFsCache(page))
86 __v9fs_readpage_to_fscache(inode, page);
89 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
91 struct v9fs_inode *v9inode = V9FS_I(inode);
92 fscache_uncache_page(v9inode->fscache, page);
93 BUG_ON(PageFsCache(page));
96 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
97 struct page *page)
99 return __v9fs_fscache_wait_on_page_write(inode, page);
102 #else /* CONFIG_9P_FSCACHE */
104 static inline void v9fs_cache_inode_get_cookie(struct inode *inode)
108 static inline void v9fs_cache_inode_put_cookie(struct inode *inode)
112 static inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *file)
116 static inline int v9fs_fscache_release_page(struct page *page,
117 gfp_t gfp) {
118 return 1;
121 static inline void v9fs_fscache_invalidate_page(struct page *page) {}
123 static inline int v9fs_readpage_from_fscache(struct inode *inode,
124 struct page *page)
126 return -ENOBUFS;
129 static inline int v9fs_readpages_from_fscache(struct inode *inode,
130 struct address_space *mapping,
131 struct list_head *pages,
132 unsigned *nr_pages)
134 return -ENOBUFS;
137 static inline void v9fs_readpage_to_fscache(struct inode *inode,
138 struct page *page)
141 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
144 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
145 struct page *page)
147 return;
150 #endif /* CONFIG_9P_FSCACHE */
151 #endif /* _9P_CACHE_H */