thinkpad-acpi: constrain IBM-era support to IBM boxes
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / 9p / cache.h
bloba94192bfaee843183bbc74f068c1f72dcbc6468d
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 kmem_cache *vcookie_cache;
30 struct v9fs_cookie {
31 spinlock_t lock;
32 struct inode inode;
33 struct fscache_cookie *fscache;
34 struct p9_qid *qid;
37 static inline struct v9fs_cookie *v9fs_inode2cookie(const struct inode *inode)
39 return container_of(inode, struct v9fs_cookie, inode);
42 extern struct fscache_netfs v9fs_cache_netfs;
43 extern const struct fscache_cookie_def v9fs_cache_session_index_def;
44 extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
46 extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
47 extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
49 extern void v9fs_cache_inode_get_cookie(struct inode *inode);
50 extern void v9fs_cache_inode_put_cookie(struct inode *inode);
51 extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
52 extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
53 extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
55 extern int __v9fs_cache_register(void);
56 extern void __v9fs_cache_unregister(void);
58 extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
59 extern void __v9fs_fscache_invalidate_page(struct page *page);
60 extern int __v9fs_readpage_from_fscache(struct inode *inode,
61 struct page *page);
62 extern int __v9fs_readpages_from_fscache(struct inode *inode,
63 struct address_space *mapping,
64 struct list_head *pages,
65 unsigned *nr_pages);
66 extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
69 /**
70 * v9fs_cache_register - Register v9fs file system with the cache
72 static inline int v9fs_cache_register(void)
74 return __v9fs_cache_register();
77 /**
78 * v9fs_cache_unregister - Unregister v9fs from the cache
80 static inline void v9fs_cache_unregister(void)
82 __v9fs_cache_unregister();
85 static inline int v9fs_fscache_release_page(struct page *page,
86 gfp_t gfp)
88 return __v9fs_fscache_release_page(page, gfp);
91 static inline void v9fs_fscache_invalidate_page(struct page *page)
93 __v9fs_fscache_invalidate_page(page);
96 static inline int v9fs_readpage_from_fscache(struct inode *inode,
97 struct page *page)
99 return __v9fs_readpage_from_fscache(inode, page);
102 static inline int v9fs_readpages_from_fscache(struct inode *inode,
103 struct address_space *mapping,
104 struct list_head *pages,
105 unsigned *nr_pages)
107 return __v9fs_readpages_from_fscache(inode, mapping, pages,
108 nr_pages);
111 static inline void v9fs_readpage_to_fscache(struct inode *inode,
112 struct page *page)
114 if (PageFsCache(page))
115 __v9fs_readpage_to_fscache(inode, page);
118 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
120 struct v9fs_cookie *vcookie = v9fs_inode2cookie(inode);
121 fscache_uncache_page(vcookie->fscache, page);
122 BUG_ON(PageFsCache(page));
125 static inline void v9fs_vcookie_set_qid(struct inode *inode,
126 struct p9_qid *qid)
128 struct v9fs_cookie *vcookie = v9fs_inode2cookie(inode);
129 spin_lock(&vcookie->lock);
130 vcookie->qid = qid;
131 spin_unlock(&vcookie->lock);
134 #else /* CONFIG_9P_FSCACHE */
136 static inline int v9fs_cache_register(void)
138 return 1;
141 static inline void v9fs_cache_unregister(void) {}
143 static inline int v9fs_fscache_release_page(struct page *page,
144 gfp_t gfp) {
145 return 1;
148 static inline void v9fs_fscache_invalidate_page(struct page *page) {}
150 static inline int v9fs_readpage_from_fscache(struct inode *inode,
151 struct page *page)
153 return -ENOBUFS;
156 static inline int v9fs_readpages_from_fscache(struct inode *inode,
157 struct address_space *mapping,
158 struct list_head *pages,
159 unsigned *nr_pages)
161 return -ENOBUFS;
164 static inline void v9fs_readpage_to_fscache(struct inode *inode,
165 struct page *page)
168 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
171 static inline void v9fs_vcookie_set_qid(struct inode *inode,
172 struct p9_qid *qid)
175 #endif /* CONFIG_9P_FSCACHE */
176 #endif /* _9P_CACHE_H */