]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/linux/fscache.h
Merge branch 'drm-tda998x-3.12-fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-cubox...
[karo-tx-linux.git] / include / linux / fscache.h
1 /* General filesystem caching interface
2  *
3  * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  *
11  * NOTE!!! See:
12  *
13  *      Documentation/filesystems/caching/netfs-api.txt
14  *
15  * for a description of the network filesystem interface declared here.
16  */
17
18 #ifndef _LINUX_FSCACHE_H
19 #define _LINUX_FSCACHE_H
20
21 #include <linux/fs.h>
22 #include <linux/list.h>
23 #include <linux/pagemap.h>
24 #include <linux/pagevec.h>
25
26 #if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
27 #define fscache_available() (1)
28 #define fscache_cookie_valid(cookie) (cookie)
29 #else
30 #define fscache_available() (0)
31 #define fscache_cookie_valid(cookie) (0)
32 #endif
33
34
35 /*
36  * overload PG_private_2 to give us PG_fscache - this is used to indicate that
37  * a page is currently backed by a local disk cache
38  */
39 #define PageFsCache(page)               PagePrivate2((page))
40 #define SetPageFsCache(page)            SetPagePrivate2((page))
41 #define ClearPageFsCache(page)          ClearPagePrivate2((page))
42 #define TestSetPageFsCache(page)        TestSetPagePrivate2((page))
43 #define TestClearPageFsCache(page)      TestClearPagePrivate2((page))
44
45 /* pattern used to fill dead space in an index entry */
46 #define FSCACHE_INDEX_DEADFILL_PATTERN 0x79
47
48 struct pagevec;
49 struct fscache_cache_tag;
50 struct fscache_cookie;
51 struct fscache_netfs;
52
53 typedef void (*fscache_rw_complete_t)(struct page *page,
54                                       void *context,
55                                       int error);
56
57 /* result of index entry consultation */
58 enum fscache_checkaux {
59         FSCACHE_CHECKAUX_OKAY,          /* entry okay as is */
60         FSCACHE_CHECKAUX_NEEDS_UPDATE,  /* entry requires update */
61         FSCACHE_CHECKAUX_OBSOLETE,      /* entry requires deletion */
62 };
63
64 /*
65  * fscache cookie definition
66  */
67 struct fscache_cookie_def {
68         /* name of cookie type */
69         char name[16];
70
71         /* cookie type */
72         uint8_t type;
73 #define FSCACHE_COOKIE_TYPE_INDEX       0
74 #define FSCACHE_COOKIE_TYPE_DATAFILE    1
75
76         /* select the cache into which to insert an entry in this index
77          * - optional
78          * - should return a cache identifier or NULL to cause the cache to be
79          *   inherited from the parent if possible or the first cache picked
80          *   for a non-index file if not
81          */
82         struct fscache_cache_tag *(*select_cache)(
83                 const void *parent_netfs_data,
84                 const void *cookie_netfs_data);
85
86         /* get an index key
87          * - should store the key data in the buffer
88          * - should return the amount of data stored
89          * - not permitted to return an error
90          * - the netfs data from the cookie being used as the source is
91          *   presented
92          */
93         uint16_t (*get_key)(const void *cookie_netfs_data,
94                             void *buffer,
95                             uint16_t bufmax);
96
97         /* get certain file attributes from the netfs data
98          * - this function can be absent for an index
99          * - not permitted to return an error
100          * - the netfs data from the cookie being used as the source is
101          *   presented
102          */
103         void (*get_attr)(const void *cookie_netfs_data, uint64_t *size);
104
105         /* get the auxiliary data from netfs data
106          * - this function can be absent if the index carries no state data
107          * - should store the auxiliary data in the buffer
108          * - should return the amount of amount stored
109          * - not permitted to return an error
110          * - the netfs data from the cookie being used as the source is
111          *   presented
112          */
113         uint16_t (*get_aux)(const void *cookie_netfs_data,
114                             void *buffer,
115                             uint16_t bufmax);
116
117         /* consult the netfs about the state of an object
118          * - this function can be absent if the index carries no state data
119          * - the netfs data from the cookie being used as the target is
120          *   presented, as is the auxiliary data
121          */
122         enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
123                                            const void *data,
124                                            uint16_t datalen);
125
126         /* get an extra reference on a read context
127          * - this function can be absent if the completion function doesn't
128          *   require a context
129          */
130         void (*get_context)(void *cookie_netfs_data, void *context);
131
132         /* release an extra reference on a read context
133          * - this function can be absent if the completion function doesn't
134          *   require a context
135          */
136         void (*put_context)(void *cookie_netfs_data, void *context);
137
138         /* indicate page that now have cache metadata retained
139          * - this function should mark the specified page as now being cached
140          * - the page will have been marked with PG_fscache before this is
141          *   called, so this is optional
142          */
143         void (*mark_page_cached)(void *cookie_netfs_data,
144                                  struct address_space *mapping,
145                                  struct page *page);
146
147         /* indicate the cookie is no longer cached
148          * - this function is called when the backing store currently caching
149          *   a cookie is removed
150          * - the netfs should use this to clean up any markers indicating
151          *   cached pages
152          * - this is mandatory for any object that may have data
153          */
154         void (*now_uncached)(void *cookie_netfs_data);
155 };
156
157 /*
158  * fscache cached network filesystem type
159  * - name, version and ops must be filled in before registration
160  * - all other fields will be set during registration
161  */
162 struct fscache_netfs {
163         uint32_t                        version;        /* indexing version */
164         const char                      *name;          /* filesystem name */
165         struct fscache_cookie           *primary_index;
166         struct list_head                link;           /* internal link */
167 };
168
169 /*
170  * slow-path functions for when there is actually caching available, and the
171  * netfs does actually have a valid token
172  * - these are not to be called directly
173  * - these are undefined symbols when FS-Cache is not configured and the
174  *   optimiser takes care of not using them
175  */
176 extern int __fscache_register_netfs(struct fscache_netfs *);
177 extern void __fscache_unregister_netfs(struct fscache_netfs *);
178 extern struct fscache_cache_tag *__fscache_lookup_cache_tag(const char *);
179 extern void __fscache_release_cache_tag(struct fscache_cache_tag *);
180
181 extern struct fscache_cookie *__fscache_acquire_cookie(
182         struct fscache_cookie *,
183         const struct fscache_cookie_def *,
184         void *);
185 extern void __fscache_relinquish_cookie(struct fscache_cookie *, int);
186 extern int __fscache_check_consistency(struct fscache_cookie *);
187 extern void __fscache_update_cookie(struct fscache_cookie *);
188 extern int __fscache_attr_changed(struct fscache_cookie *);
189 extern void __fscache_invalidate(struct fscache_cookie *);
190 extern void __fscache_wait_on_invalidate(struct fscache_cookie *);
191 extern int __fscache_read_or_alloc_page(struct fscache_cookie *,
192                                         struct page *,
193                                         fscache_rw_complete_t,
194                                         void *,
195                                         gfp_t);
196 extern int __fscache_read_or_alloc_pages(struct fscache_cookie *,
197                                          struct address_space *,
198                                          struct list_head *,
199                                          unsigned *,
200                                          fscache_rw_complete_t,
201                                          void *,
202                                          gfp_t);
203 extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
204 extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t);
205 extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
206 extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
207 extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
208 extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
209                                          gfp_t);
210 extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
211                                               struct inode *);
212 extern void __fscache_readpages_cancel(struct fscache_cookie *cookie,
213                                        struct list_head *pages);
214
215 /**
216  * fscache_register_netfs - Register a filesystem as desiring caching services
217  * @netfs: The description of the filesystem
218  *
219  * Register a filesystem as desiring caching services if they're available.
220  *
221  * See Documentation/filesystems/caching/netfs-api.txt for a complete
222  * description.
223  */
224 static inline
225 int fscache_register_netfs(struct fscache_netfs *netfs)
226 {
227         if (fscache_available())
228                 return __fscache_register_netfs(netfs);
229         else
230                 return 0;
231 }
232
233 /**
234  * fscache_unregister_netfs - Indicate that a filesystem no longer desires
235  * caching services
236  * @netfs: The description of the filesystem
237  *
238  * Indicate that a filesystem no longer desires caching services for the
239  * moment.
240  *
241  * See Documentation/filesystems/caching/netfs-api.txt for a complete
242  * description.
243  */
244 static inline
245 void fscache_unregister_netfs(struct fscache_netfs *netfs)
246 {
247         if (fscache_available())
248                 __fscache_unregister_netfs(netfs);
249 }
250
251 /**
252  * fscache_lookup_cache_tag - Look up a cache tag
253  * @name: The name of the tag to search for
254  *
255  * Acquire a specific cache referral tag that can be used to select a specific
256  * cache in which to cache an index.
257  *
258  * See Documentation/filesystems/caching/netfs-api.txt for a complete
259  * description.
260  */
261 static inline
262 struct fscache_cache_tag *fscache_lookup_cache_tag(const char *name)
263 {
264         if (fscache_available())
265                 return __fscache_lookup_cache_tag(name);
266         else
267                 return NULL;
268 }
269
270 /**
271  * fscache_release_cache_tag - Release a cache tag
272  * @tag: The tag to release
273  *
274  * Release a reference to a cache referral tag previously looked up.
275  *
276  * See Documentation/filesystems/caching/netfs-api.txt for a complete
277  * description.
278  */
279 static inline
280 void fscache_release_cache_tag(struct fscache_cache_tag *tag)
281 {
282         if (fscache_available())
283                 __fscache_release_cache_tag(tag);
284 }
285
286 /**
287  * fscache_acquire_cookie - Acquire a cookie to represent a cache object
288  * @parent: The cookie that's to be the parent of this one
289  * @def: A description of the cache object, including callback operations
290  * @netfs_data: An arbitrary piece of data to be kept in the cookie to
291  * represent the cache object to the netfs
292  *
293  * This function is used to inform FS-Cache about part of an index hierarchy
294  * that can be used to locate files.  This is done by requesting a cookie for
295  * each index in the path to the file.
296  *
297  * See Documentation/filesystems/caching/netfs-api.txt for a complete
298  * description.
299  */
300 static inline
301 struct fscache_cookie *fscache_acquire_cookie(
302         struct fscache_cookie *parent,
303         const struct fscache_cookie_def *def,
304         void *netfs_data)
305 {
306         if (fscache_cookie_valid(parent))
307                 return __fscache_acquire_cookie(parent, def, netfs_data);
308         else
309                 return NULL;
310 }
311
312 /**
313  * fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
314  * it
315  * @cookie: The cookie being returned
316  * @retire: True if the cache object the cookie represents is to be discarded
317  *
318  * This function returns a cookie to the cache, forcibly discarding the
319  * associated cache object if retire is set to true.
320  *
321  * See Documentation/filesystems/caching/netfs-api.txt for a complete
322  * description.
323  */
324 static inline
325 void fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
326 {
327         if (fscache_cookie_valid(cookie))
328                 __fscache_relinquish_cookie(cookie, retire);
329 }
330
331 /**
332  * fscache_check_consistency - Request that if the cache is updated
333  * @cookie: The cookie representing the cache object
334  *
335  * Request an consistency check from fscache, which passes the request
336  * to the backing cache.
337  *
338  * Returns 0 if consistent and -ESTALE if inconsistent.  May also
339  * return -ENOMEM and -ERESTARTSYS.
340  */
341 static inline
342 int fscache_check_consistency(struct fscache_cookie *cookie)
343 {
344         if (fscache_cookie_valid(cookie))
345                 return __fscache_check_consistency(cookie);
346         else
347                 return 0;
348 }
349
350 /**
351  * fscache_update_cookie - Request that a cache object be updated
352  * @cookie: The cookie representing the cache object
353  *
354  * Request an update of the index data for the cache object associated with the
355  * cookie.
356  *
357  * See Documentation/filesystems/caching/netfs-api.txt for a complete
358  * description.
359  */
360 static inline
361 void fscache_update_cookie(struct fscache_cookie *cookie)
362 {
363         if (fscache_cookie_valid(cookie))
364                 __fscache_update_cookie(cookie);
365 }
366
367 /**
368  * fscache_pin_cookie - Pin a data-storage cache object in its cache
369  * @cookie: The cookie representing the cache object
370  *
371  * Permit data-storage cache objects to be pinned in the cache.
372  *
373  * See Documentation/filesystems/caching/netfs-api.txt for a complete
374  * description.
375  */
376 static inline
377 int fscache_pin_cookie(struct fscache_cookie *cookie)
378 {
379         return -ENOBUFS;
380 }
381
382 /**
383  * fscache_pin_cookie - Unpin a data-storage cache object in its cache
384  * @cookie: The cookie representing the cache object
385  *
386  * Permit data-storage cache objects to be unpinned from the cache.
387  *
388  * See Documentation/filesystems/caching/netfs-api.txt for a complete
389  * description.
390  */
391 static inline
392 void fscache_unpin_cookie(struct fscache_cookie *cookie)
393 {
394 }
395
396 /**
397  * fscache_attr_changed - Notify cache that an object's attributes changed
398  * @cookie: The cookie representing the cache object
399  *
400  * Send a notification to the cache indicating that an object's attributes have
401  * changed.  This includes the data size.  These attributes will be obtained
402  * through the get_attr() cookie definition op.
403  *
404  * See Documentation/filesystems/caching/netfs-api.txt for a complete
405  * description.
406  */
407 static inline
408 int fscache_attr_changed(struct fscache_cookie *cookie)
409 {
410         if (fscache_cookie_valid(cookie))
411                 return __fscache_attr_changed(cookie);
412         else
413                 return -ENOBUFS;
414 }
415
416 /**
417  * fscache_invalidate - Notify cache that an object needs invalidation
418  * @cookie: The cookie representing the cache object
419  *
420  * Notify the cache that an object is needs to be invalidated and that it
421  * should abort any retrievals or stores it is doing on the cache.  The object
422  * is then marked non-caching until such time as the invalidation is complete.
423  *
424  * This can be called with spinlocks held.
425  *
426  * See Documentation/filesystems/caching/netfs-api.txt for a complete
427  * description.
428  */
429 static inline
430 void fscache_invalidate(struct fscache_cookie *cookie)
431 {
432         if (fscache_cookie_valid(cookie))
433                 __fscache_invalidate(cookie);
434 }
435
436 /**
437  * fscache_wait_on_invalidate - Wait for invalidation to complete
438  * @cookie: The cookie representing the cache object
439  *
440  * Wait for the invalidation of an object to complete.
441  *
442  * See Documentation/filesystems/caching/netfs-api.txt for a complete
443  * description.
444  */
445 static inline
446 void fscache_wait_on_invalidate(struct fscache_cookie *cookie)
447 {
448         if (fscache_cookie_valid(cookie))
449                 __fscache_wait_on_invalidate(cookie);
450 }
451
452 /**
453  * fscache_reserve_space - Reserve data space for a cached object
454  * @cookie: The cookie representing the cache object
455  * @i_size: The amount of space to be reserved
456  *
457  * Reserve an amount of space in the cache for the cache object attached to a
458  * cookie so that a write to that object within the space can always be
459  * honoured.
460  *
461  * See Documentation/filesystems/caching/netfs-api.txt for a complete
462  * description.
463  */
464 static inline
465 int fscache_reserve_space(struct fscache_cookie *cookie, loff_t size)
466 {
467         return -ENOBUFS;
468 }
469
470 /**
471  * fscache_read_or_alloc_page - Read a page from the cache or allocate a block
472  * in which to store it
473  * @cookie: The cookie representing the cache object
474  * @page: The netfs page to fill if possible
475  * @end_io_func: The callback to invoke when and if the page is filled
476  * @context: An arbitrary piece of data to pass on to end_io_func()
477  * @gfp: The conditions under which memory allocation should be made
478  *
479  * Read a page from the cache, or if that's not possible make a potential
480  * one-block reservation in the cache into which the page may be stored once
481  * fetched from the server.
482  *
483  * If the page is not backed by the cache object, or if it there's some reason
484  * it can't be, -ENOBUFS will be returned and nothing more will be done for
485  * that page.
486  *
487  * Else, if that page is backed by the cache, a read will be initiated directly
488  * to the netfs's page and 0 will be returned by this function.  The
489  * end_io_func() callback will be invoked when the operation terminates on a
490  * completion or failure.  Note that the callback may be invoked before the
491  * return.
492  *
493  * Else, if the page is unbacked, -ENODATA is returned and a block may have
494  * been allocated in the cache.
495  *
496  * See Documentation/filesystems/caching/netfs-api.txt for a complete
497  * description.
498  */
499 static inline
500 int fscache_read_or_alloc_page(struct fscache_cookie *cookie,
501                                struct page *page,
502                                fscache_rw_complete_t end_io_func,
503                                void *context,
504                                gfp_t gfp)
505 {
506         if (fscache_cookie_valid(cookie))
507                 return __fscache_read_or_alloc_page(cookie, page, end_io_func,
508                                                     context, gfp);
509         else
510                 return -ENOBUFS;
511 }
512
513 /**
514  * fscache_read_or_alloc_pages - Read pages from the cache and/or allocate
515  * blocks in which to store them
516  * @cookie: The cookie representing the cache object
517  * @mapping: The netfs inode mapping to which the pages will be attached
518  * @pages: A list of potential netfs pages to be filled
519  * @nr_pages: Number of pages to be read and/or allocated
520  * @end_io_func: The callback to invoke when and if each page is filled
521  * @context: An arbitrary piece of data to pass on to end_io_func()
522  * @gfp: The conditions under which memory allocation should be made
523  *
524  * Read a set of pages from the cache, or if that's not possible, attempt to
525  * make a potential one-block reservation for each page in the cache into which
526  * that page may be stored once fetched from the server.
527  *
528  * If some pages are not backed by the cache object, or if it there's some
529  * reason they can't be, -ENOBUFS will be returned and nothing more will be
530  * done for that pages.
531  *
532  * Else, if some of the pages are backed by the cache, a read will be initiated
533  * directly to the netfs's page and 0 will be returned by this function.  The
534  * end_io_func() callback will be invoked when the operation terminates on a
535  * completion or failure.  Note that the callback may be invoked before the
536  * return.
537  *
538  * Else, if a page is unbacked, -ENODATA is returned and a block may have
539  * been allocated in the cache.
540  *
541  * Because the function may want to return all of -ENOBUFS, -ENODATA and 0 in
542  * regard to different pages, the return values are prioritised in that order.
543  * Any pages submitted for reading are removed from the pages list.
544  *
545  * See Documentation/filesystems/caching/netfs-api.txt for a complete
546  * description.
547  */
548 static inline
549 int fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
550                                 struct address_space *mapping,
551                                 struct list_head *pages,
552                                 unsigned *nr_pages,
553                                 fscache_rw_complete_t end_io_func,
554                                 void *context,
555                                 gfp_t gfp)
556 {
557         if (fscache_cookie_valid(cookie))
558                 return __fscache_read_or_alloc_pages(cookie, mapping, pages,
559                                                      nr_pages, end_io_func,
560                                                      context, gfp);
561         else
562                 return -ENOBUFS;
563 }
564
565 /**
566  * fscache_alloc_page - Allocate a block in which to store a page
567  * @cookie: The cookie representing the cache object
568  * @page: The netfs page to allocate a page for
569  * @gfp: The conditions under which memory allocation should be made
570  *
571  * Request Allocation a block in the cache in which to store a netfs page
572  * without retrieving any contents from the cache.
573  *
574  * If the page is not backed by a file then -ENOBUFS will be returned and
575  * nothing more will be done, and no reservation will be made.
576  *
577  * Else, a block will be allocated if one wasn't already, and 0 will be
578  * returned
579  *
580  * See Documentation/filesystems/caching/netfs-api.txt for a complete
581  * description.
582  */
583 static inline
584 int fscache_alloc_page(struct fscache_cookie *cookie,
585                        struct page *page,
586                        gfp_t gfp)
587 {
588         if (fscache_cookie_valid(cookie))
589                 return __fscache_alloc_page(cookie, page, gfp);
590         else
591                 return -ENOBUFS;
592 }
593
594 /**
595  * fscache_readpages_cancel - Cancel read/alloc on pages
596  * @cookie: The cookie representing the inode's cache object.
597  * @pages: The netfs pages that we canceled write on in readpages()
598  *
599  * Uncache/unreserve the pages reserved earlier in readpages() via
600  * fscache_readpages_or_alloc() and similar.  In most successful caches in
601  * readpages() this doesn't do anything.  In cases when the underlying netfs's
602  * readahead failed we need to clean up the pagelist (unmark and uncache).
603  *
604  * This function may sleep as it may have to clean up disk state.
605  */
606 static inline
607 void fscache_readpages_cancel(struct fscache_cookie *cookie,
608                               struct list_head *pages)
609 {
610         if (fscache_cookie_valid(cookie))
611                 __fscache_readpages_cancel(cookie, pages);
612 }
613
614 /**
615  * fscache_write_page - Request storage of a page in the cache
616  * @cookie: The cookie representing the cache object
617  * @page: The netfs page to store
618  * @gfp: The conditions under which memory allocation should be made
619  *
620  * Request the contents of the netfs page be written into the cache.  This
621  * request may be ignored if no cache block is currently allocated, in which
622  * case it will return -ENOBUFS.
623  *
624  * If a cache block was already allocated, a write will be initiated and 0 will
625  * be returned.  The PG_fscache_write page bit is set immediately and will then
626  * be cleared at the completion of the write to indicate the success or failure
627  * of the operation.  Note that the completion may happen before the return.
628  *
629  * See Documentation/filesystems/caching/netfs-api.txt for a complete
630  * description.
631  */
632 static inline
633 int fscache_write_page(struct fscache_cookie *cookie,
634                        struct page *page,
635                        gfp_t gfp)
636 {
637         if (fscache_cookie_valid(cookie))
638                 return __fscache_write_page(cookie, page, gfp);
639         else
640                 return -ENOBUFS;
641 }
642
643 /**
644  * fscache_uncache_page - Indicate that caching is no longer required on a page
645  * @cookie: The cookie representing the cache object
646  * @page: The netfs page that was being cached.
647  *
648  * Tell the cache that we no longer want a page to be cached and that it should
649  * remove any knowledge of the netfs page it may have.
650  *
651  * Note that this cannot cancel any outstanding I/O operations between this
652  * page and the cache.
653  *
654  * See Documentation/filesystems/caching/netfs-api.txt for a complete
655  * description.
656  */
657 static inline
658 void fscache_uncache_page(struct fscache_cookie *cookie,
659                           struct page *page)
660 {
661         if (fscache_cookie_valid(cookie))
662                 __fscache_uncache_page(cookie, page);
663 }
664
665 /**
666  * fscache_check_page_write - Ask if a page is being writing to the cache
667  * @cookie: The cookie representing the cache object
668  * @page: The netfs page that is being cached.
669  *
670  * Ask the cache if a page is being written to the cache.
671  *
672  * See Documentation/filesystems/caching/netfs-api.txt for a complete
673  * description.
674  */
675 static inline
676 bool fscache_check_page_write(struct fscache_cookie *cookie,
677                               struct page *page)
678 {
679         if (fscache_cookie_valid(cookie))
680                 return __fscache_check_page_write(cookie, page);
681         return false;
682 }
683
684 /**
685  * fscache_wait_on_page_write - Wait for a page to complete writing to the cache
686  * @cookie: The cookie representing the cache object
687  * @page: The netfs page that is being cached.
688  *
689  * Ask the cache to wake us up when a page is no longer being written to the
690  * cache.
691  *
692  * See Documentation/filesystems/caching/netfs-api.txt for a complete
693  * description.
694  */
695 static inline
696 void fscache_wait_on_page_write(struct fscache_cookie *cookie,
697                                 struct page *page)
698 {
699         if (fscache_cookie_valid(cookie))
700                 __fscache_wait_on_page_write(cookie, page);
701 }
702
703 /**
704  * fscache_maybe_release_page - Consider releasing a page, cancelling a store
705  * @cookie: The cookie representing the cache object
706  * @page: The netfs page that is being cached.
707  * @gfp: The gfp flags passed to releasepage()
708  *
709  * Consider releasing a page for the vmscan algorithm, on behalf of the netfs's
710  * releasepage() call.  A storage request on the page may cancelled if it is
711  * not currently being processed.
712  *
713  * The function returns true if the page no longer has a storage request on it,
714  * and false if a storage request is left in place.  If true is returned, the
715  * page will have been passed to fscache_uncache_page().  If false is returned
716  * the page cannot be freed yet.
717  */
718 static inline
719 bool fscache_maybe_release_page(struct fscache_cookie *cookie,
720                                 struct page *page,
721                                 gfp_t gfp)
722 {
723         if (fscache_cookie_valid(cookie) && PageFsCache(page))
724                 return __fscache_maybe_release_page(cookie, page, gfp);
725         return false;
726 }
727
728 /**
729  * fscache_uncache_all_inode_pages - Uncache all an inode's pages
730  * @cookie: The cookie representing the inode's cache object.
731  * @inode: The inode to uncache pages from.
732  *
733  * Uncache all the pages in an inode that are marked PG_fscache, assuming them
734  * to be associated with the given cookie.
735  *
736  * This function may sleep.  It will wait for pages that are being written out
737  * and will wait whilst the PG_fscache mark is removed by the cache.
738  */
739 static inline
740 void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
741                                      struct inode *inode)
742 {
743         if (fscache_cookie_valid(cookie))
744                 __fscache_uncache_all_inode_pages(cookie, inode);
745 }
746
747 #endif /* _LINUX_FSCACHE_H */