ext4: Optimize ext4 DIO overwrites
[linux/fpc-iii.git] / fs / 9p / cache.h
blob00f107af443ef62379256767fb1041f1b1ea6792
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * V9FS cache definitions.
5 * Copyright (C) 2009 by Abhishek Kulkarni <adkulkar@umail.iu.edu>
6 */
8 #ifndef _9P_CACHE_H
9 #define _9P_CACHE_H
10 #ifdef CONFIG_9P_FSCACHE
11 #include <linux/fscache.h>
12 #include <linux/spinlock.h>
14 extern struct fscache_netfs v9fs_cache_netfs;
15 extern const struct fscache_cookie_def v9fs_cache_session_index_def;
16 extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
18 extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
19 extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
21 extern void v9fs_cache_inode_get_cookie(struct inode *inode);
22 extern void v9fs_cache_inode_put_cookie(struct inode *inode);
23 extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
24 extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
25 extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
27 extern int __v9fs_cache_register(void);
28 extern void __v9fs_cache_unregister(void);
30 extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
31 extern void __v9fs_fscache_invalidate_page(struct page *page);
32 extern int __v9fs_readpage_from_fscache(struct inode *inode,
33 struct page *page);
34 extern int __v9fs_readpages_from_fscache(struct inode *inode,
35 struct address_space *mapping,
36 struct list_head *pages,
37 unsigned *nr_pages);
38 extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
39 extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
40 struct page *page);
42 static inline int v9fs_fscache_release_page(struct page *page,
43 gfp_t gfp)
45 return __v9fs_fscache_release_page(page, gfp);
48 static inline void v9fs_fscache_invalidate_page(struct page *page)
50 __v9fs_fscache_invalidate_page(page);
53 static inline int v9fs_readpage_from_fscache(struct inode *inode,
54 struct page *page)
56 return __v9fs_readpage_from_fscache(inode, page);
59 static inline int v9fs_readpages_from_fscache(struct inode *inode,
60 struct address_space *mapping,
61 struct list_head *pages,
62 unsigned *nr_pages)
64 return __v9fs_readpages_from_fscache(inode, mapping, pages,
65 nr_pages);
68 static inline void v9fs_readpage_to_fscache(struct inode *inode,
69 struct page *page)
71 if (PageFsCache(page))
72 __v9fs_readpage_to_fscache(inode, page);
75 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
77 struct v9fs_inode *v9inode = V9FS_I(inode);
78 fscache_uncache_page(v9inode->fscache, page);
79 BUG_ON(PageFsCache(page));
82 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
83 struct page *page)
85 return __v9fs_fscache_wait_on_page_write(inode, page);
88 #else /* CONFIG_9P_FSCACHE */
90 static inline void v9fs_cache_inode_get_cookie(struct inode *inode)
94 static inline void v9fs_cache_inode_put_cookie(struct inode *inode)
98 static inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *file)
102 static inline int v9fs_fscache_release_page(struct page *page,
103 gfp_t gfp) {
104 return 1;
107 static inline void v9fs_fscache_invalidate_page(struct page *page) {}
109 static inline int v9fs_readpage_from_fscache(struct inode *inode,
110 struct page *page)
112 return -ENOBUFS;
115 static inline int v9fs_readpages_from_fscache(struct inode *inode,
116 struct address_space *mapping,
117 struct list_head *pages,
118 unsigned *nr_pages)
120 return -ENOBUFS;
123 static inline void v9fs_readpage_to_fscache(struct inode *inode,
124 struct page *page)
127 static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
130 static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
131 struct page *page)
133 return;
136 #endif /* CONFIG_9P_FSCACHE */
137 #endif /* _9P_CACHE_H */