1 /* SPDX-License-Identifier: LGPL-2.1 */
3 * CIFS filesystem cache interface definitions
5 * Copyright (c) 2010 Novell, Inc.
9 #ifndef _CIFS_FSCACHE_H
10 #define _CIFS_FSCACHE_H
12 #include <linux/fscache.h>
16 #ifdef CONFIG_CIFS_FSCACHE
19 * Auxiliary data attached to CIFS superblock within the cache
21 struct cifs_fscache_super_auxdata {
22 u64 resource_id; /* unique server resource id */
23 __le64 vol_create_time;
24 u32 vol_serial_number;
28 * Auxiliary data attached to CIFS inode within the cache
30 struct cifs_fscache_inode_auxdata {
31 u64 last_write_time_sec;
32 u64 last_change_time_sec;
33 u32 last_write_time_nsec;
34 u32 last_change_time_nsec;
41 extern struct fscache_netfs cifs_fscache_netfs;
42 extern const struct fscache_cookie_def cifs_fscache_server_index_def;
43 extern const struct fscache_cookie_def cifs_fscache_super_index_def;
44 extern const struct fscache_cookie_def cifs_fscache_inode_object_def;
46 extern int cifs_fscache_register(void);
47 extern void cifs_fscache_unregister(void);
52 extern void cifs_fscache_get_client_cookie(struct TCP_Server_Info *);
53 extern void cifs_fscache_release_client_cookie(struct TCP_Server_Info *);
54 extern void cifs_fscache_get_super_cookie(struct cifs_tcon *);
55 extern void cifs_fscache_release_super_cookie(struct cifs_tcon *);
57 extern void cifs_fscache_release_inode_cookie(struct inode *);
58 extern void cifs_fscache_update_inode_cookie(struct inode *inode);
59 extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *);
60 extern void cifs_fscache_reset_inode_cookie(struct inode *);
62 extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
63 extern void __cifs_fscache_wait_on_page_write(struct inode *inode, struct page *page);
64 extern void __cifs_fscache_uncache_page(struct inode *inode, struct page *page);
65 extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);
66 extern int __cifs_readpage_from_fscache(struct inode *, struct page *);
67 extern int __cifs_readpages_from_fscache(struct inode *,
68 struct address_space *,
71 extern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *);
73 extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
75 static inline void cifs_fscache_invalidate_page(struct page *page,
78 if (PageFsCache(page))
79 __cifs_fscache_invalidate_page(page, inode);
82 static inline void cifs_fscache_wait_on_page_write(struct inode *inode,
85 if (PageFsCache(page))
86 __cifs_fscache_wait_on_page_write(inode, page);
89 static inline void cifs_fscache_uncache_page(struct inode *inode,
92 if (PageFsCache(page))
93 __cifs_fscache_uncache_page(inode, page);
96 static inline int cifs_readpage_from_fscache(struct inode *inode,
99 if (CIFS_I(inode)->fscache)
100 return __cifs_readpage_from_fscache(inode, page);
105 static inline int cifs_readpages_from_fscache(struct inode *inode,
106 struct address_space *mapping,
107 struct list_head *pages,
110 if (CIFS_I(inode)->fscache)
111 return __cifs_readpages_from_fscache(inode, mapping, pages,
116 static inline void cifs_readpage_to_fscache(struct inode *inode,
119 if (PageFsCache(page))
120 __cifs_readpage_to_fscache(inode, page);
123 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
124 struct list_head *pages)
126 if (CIFS_I(inode)->fscache)
127 return __cifs_fscache_readpages_cancel(inode, pages);
130 #else /* CONFIG_CIFS_FSCACHE */
131 static inline int cifs_fscache_register(void) { return 0; }
132 static inline void cifs_fscache_unregister(void) {}
135 cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {}
137 cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) {}
138 static inline void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) {}
140 cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) {}
142 static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {}
143 static inline void cifs_fscache_update_inode_cookie(struct inode *inode) {}
144 static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
145 struct file *filp) {}
146 static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {}
147 static inline int cifs_fscache_release_page(struct page *page, gfp_t gfp)
149 return 1; /* May release page */
152 static inline void cifs_fscache_invalidate_page(struct page *page,
153 struct inode *inode) {}
154 static inline void cifs_fscache_wait_on_page_write(struct inode *inode,
155 struct page *page) {}
156 static inline void cifs_fscache_uncache_page(struct inode *inode,
157 struct page *page) {}
160 cifs_readpage_from_fscache(struct inode *inode, struct page *page)
165 static inline int cifs_readpages_from_fscache(struct inode *inode,
166 struct address_space *mapping,
167 struct list_head *pages,
173 static inline void cifs_readpage_to_fscache(struct inode *inode,
174 struct page *page) {}
176 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
177 struct list_head *pages)
181 #endif /* CONFIG_CIFS_FSCACHE */
183 #endif /* _CIFS_FSCACHE_H */