Merge tag 'acpi-5.15-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6-microblaze.git] / fs / cifs / fscache.h
1 /* SPDX-License-Identifier: LGPL-2.1 */
2 /*
3  *   fs/cifs/fscache.h - CIFS filesystem cache interface definitions
4  *
5  *   Copyright (c) 2010 Novell, Inc.
6  *   Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
7  *
8  */
9 #ifndef _CIFS_FSCACHE_H
10 #define _CIFS_FSCACHE_H
11
12 #include <linux/fscache.h>
13
14 #include "cifsglob.h"
15
16 #ifdef CONFIG_CIFS_FSCACHE
17
18 /*
19  * Auxiliary data attached to CIFS superblock within the cache
20  */
21 struct cifs_fscache_super_auxdata {
22         u64     resource_id;            /* unique server resource id */
23         __le64  vol_create_time;
24         u32     vol_serial_number;
25 } __packed;
26
27 /*
28  * Auxiliary data attached to CIFS inode within the cache
29  */
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;
35         u64 eof;
36 };
37
38 /*
39  * cache.c
40  */
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;
45
46 extern int cifs_fscache_register(void);
47 extern void cifs_fscache_unregister(void);
48
49 /*
50  * fscache.c
51  */
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 *);
56
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 *);
61
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 *,
69                                          struct list_head *,
70                                          unsigned *);
71 extern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *);
72
73 extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
74
75 static inline void cifs_fscache_invalidate_page(struct page *page,
76                                                struct inode *inode)
77 {
78         if (PageFsCache(page))
79                 __cifs_fscache_invalidate_page(page, inode);
80 }
81
82 static inline void cifs_fscache_wait_on_page_write(struct inode *inode,
83                                                    struct page *page)
84 {
85         if (PageFsCache(page))
86                 __cifs_fscache_wait_on_page_write(inode, page);
87 }
88
89 static inline void cifs_fscache_uncache_page(struct inode *inode,
90                                                    struct page *page)
91 {
92         if (PageFsCache(page))
93                 __cifs_fscache_uncache_page(inode, page);
94 }
95
96 static inline int cifs_readpage_from_fscache(struct inode *inode,
97                                              struct page *page)
98 {
99         if (CIFS_I(inode)->fscache)
100                 return __cifs_readpage_from_fscache(inode, page);
101
102         return -ENOBUFS;
103 }
104
105 static inline int cifs_readpages_from_fscache(struct inode *inode,
106                                               struct address_space *mapping,
107                                               struct list_head *pages,
108                                               unsigned *nr_pages)
109 {
110         if (CIFS_I(inode)->fscache)
111                 return __cifs_readpages_from_fscache(inode, mapping, pages,
112                                                      nr_pages);
113         return -ENOBUFS;
114 }
115
116 static inline void cifs_readpage_to_fscache(struct inode *inode,
117                                             struct page *page)
118 {
119         if (PageFsCache(page))
120                 __cifs_readpage_to_fscache(inode, page);
121 }
122
123 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
124                                                  struct list_head *pages)
125 {
126         if (CIFS_I(inode)->fscache)
127                 return __cifs_fscache_readpages_cancel(inode, pages);
128 }
129
130 #else /* CONFIG_CIFS_FSCACHE */
131 static inline int cifs_fscache_register(void) { return 0; }
132 static inline void cifs_fscache_unregister(void) {}
133
134 static inline void
135 cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {}
136 static inline void
137 cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) {}
138 static inline void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) {}
139 static inline void
140 cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) {}
141
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)
148 {
149         return 1; /* May release page */
150 }
151
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) {}
158
159 static inline int
160 cifs_readpage_from_fscache(struct inode *inode, struct page *page)
161 {
162         return -ENOBUFS;
163 }
164
165 static inline int cifs_readpages_from_fscache(struct inode *inode,
166                                               struct address_space *mapping,
167                                               struct list_head *pages,
168                                               unsigned *nr_pages)
169 {
170         return -ENOBUFS;
171 }
172
173 static inline void cifs_readpage_to_fscache(struct inode *inode,
174                         struct page *page) {}
175
176 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
177                                                  struct list_head *pages)
178 {
179 }
180
181 #endif /* CONFIG_CIFS_FSCACHE */
182
183 #endif /* _CIFS_FSCACHE_H */