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
25 #ifdef CONFIG_9P_FSCACHE
26 #include <linux/fscache.h>
27 #include <linux/spinlock.h>
29 extern struct fscache_netfs v9fs_cache_netfs;
30 extern const struct fscache_cookie_def v9fs_cache_session_index_def;
31 extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
33 extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
34 extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
36 extern void v9fs_cache_inode_get_cookie(struct inode *inode);
37 extern void v9fs_cache_inode_put_cookie(struct inode *inode);
38 extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
39 extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
40 extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
42 extern int __v9fs_cache_register(void);
43 extern void __v9fs_cache_unregister(void);
45 extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
46 extern void __v9fs_fscache_invalidate_page(struct page *page);
47 extern int __v9fs_readpage_from_fscache(struct inode *inode,
49 extern int __v9fs_readpages_from_fscache(struct inode *inode,
50 struct address_space *mapping,
51 struct list_head *pages,
53 extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
54 extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
57 static inline int v9fs_fscache_release_page(struct page *page,
60 return __v9fs_fscache_release_page(page, gfp);
63 static inline void v9fs_fscache_invalidate_page(struct page *page)
65 __v9fs_fscache_invalidate_page(page);
68 static inline int v9fs_readpage_from_fscache(struct inode *inode,
71 return __v9fs_readpage_from_fscache(inode, page);
74 static inline int v9fs_readpages_from_fscache(struct inode *inode,
75 struct address_space *mapping,
76 struct list_head *pages,
79 return __v9fs_readpages_from_fscache(inode, mapping, pages,
83 static inline void v9fs_readpage_to_fscache(struct inode *inode,
86 if (PageFsCache(page))
87 __v9fs_readpage_to_fscache(inode, page);
90 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
92 struct v9fs_inode *v9inode = V9FS_I(inode);
93 fscache_uncache_page(v9inode->fscache, page);
94 BUG_ON(PageFsCache(page));
97 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
100 return __v9fs_fscache_wait_on_page_write(inode, page);
103 #else /* CONFIG_9P_FSCACHE */
105 static inline void v9fs_cache_inode_get_cookie(struct inode *inode)
109 static inline void v9fs_cache_inode_put_cookie(struct inode *inode)
113 static inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *file)
117 static inline int v9fs_fscache_release_page(struct page *page,
122 static inline void v9fs_fscache_invalidate_page(struct page *page) {}
124 static inline int v9fs_readpage_from_fscache(struct inode *inode,
130 static inline int v9fs_readpages_from_fscache(struct inode *inode,
131 struct address_space *mapping,
132 struct list_head *pages,
138 static inline void v9fs_readpage_to_fscache(struct inode *inode,
142 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
145 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
151 #endif /* CONFIG_9P_FSCACHE */
152 #endif /* _9P_CACHE_H */