1 /* General filesystem caching interface
3 * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
13 * Documentation/filesystems/caching/netfs-api.txt
15 * for a description of the network filesystem interface declared here.
18 #ifndef _LINUX_FSCACHE_H
19 #define _LINUX_FSCACHE_H
22 #include <linux/list.h>
23 #include <linux/pagemap.h>
24 #include <linux/pagevec.h>
26 #if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
27 #define fscache_available() (1)
28 #define fscache_cookie_valid(cookie) (cookie)
30 #define fscache_available() (0)
31 #define fscache_cookie_valid(cookie) (0)
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
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))
45 /* pattern used to fill dead space in an index entry */
46 #define FSCACHE_INDEX_DEADFILL_PATTERN 0x79
49 struct fscache_cache_tag
;
50 struct fscache_cookie
;
53 typedef void (*fscache_rw_complete_t
)(struct page
*page
,
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 */
65 * fscache cookie definition
67 struct fscache_cookie_def
{
68 /* name of cookie type */
73 #define FSCACHE_COOKIE_TYPE_INDEX 0
74 #define FSCACHE_COOKIE_TYPE_DATAFILE 1
76 /* select the cache into which to insert an entry in this index
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
82 struct fscache_cache_tag
*(*select_cache
)(
83 const void *parent_netfs_data
,
84 const void *cookie_netfs_data
);
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
93 uint16_t (*get_key
)(const void *cookie_netfs_data
,
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
103 void (*get_attr
)(const void *cookie_netfs_data
, uint64_t *size
);
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
113 uint16_t (*get_aux
)(const void *cookie_netfs_data
,
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
122 enum fscache_checkaux (*check_aux
)(void *cookie_netfs_data
,
126 /* get an extra reference on a read context
127 * - this function can be absent if the completion function doesn't
130 void (*get_context
)(void *cookie_netfs_data
, void *context
);
132 /* release an extra reference on a read context
133 * - this function can be absent if the completion function doesn't
136 void (*put_context
)(void *cookie_netfs_data
, void *context
);
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
143 void (*mark_page_cached
)(void *cookie_netfs_data
,
144 struct address_space
*mapping
,
149 * fscache cached network filesystem type
150 * - name, version and ops must be filled in before registration
151 * - all other fields will be set during registration
153 struct fscache_netfs
{
154 uint32_t version
; /* indexing version */
155 const char *name
; /* filesystem name */
156 struct fscache_cookie
*primary_index
;
157 struct list_head link
; /* internal link */
161 * data file or index object cookie
162 * - a file will only appear in one cache
163 * - a request to cache a file may or may not be honoured, subject to
164 * constraints such as disk space
165 * - indices are created on disk just-in-time
167 struct fscache_cookie
{
168 atomic_t usage
; /* number of users of this cookie */
169 atomic_t n_children
; /* number of children of this cookie */
170 atomic_t n_active
; /* number of active users of netfs ptrs */
172 spinlock_t stores_lock
; /* lock on page store tree */
173 struct hlist_head backing_objects
; /* object(s) backing this file/index */
174 const struct fscache_cookie_def
*def
; /* definition */
175 struct fscache_cookie
*parent
; /* parent of this entry */
176 void *netfs_data
; /* back pointer to netfs */
177 struct radix_tree_root stores
; /* pages to be stored on this cookie */
178 #define FSCACHE_COOKIE_PENDING_TAG 0 /* pages tag: pending write to cache */
179 #define FSCACHE_COOKIE_STORING_TAG 1 /* pages tag: writing to cache */
182 #define FSCACHE_COOKIE_LOOKING_UP 0 /* T if non-index cookie being looked up still */
183 #define FSCACHE_COOKIE_NO_DATA_YET 1 /* T if new object with no cached data yet */
184 #define FSCACHE_COOKIE_UNAVAILABLE 2 /* T if cookie is unavailable (error, etc) */
185 #define FSCACHE_COOKIE_INVALIDATING 3 /* T if cookie is being invalidated */
186 #define FSCACHE_COOKIE_RELINQUISHED 4 /* T if cookie has been relinquished */
187 #define FSCACHE_COOKIE_ENABLED 5 /* T if cookie is enabled */
188 #define FSCACHE_COOKIE_ENABLEMENT_LOCK 6 /* T if cookie is being en/disabled */
191 static inline bool fscache_cookie_enabled(struct fscache_cookie
*cookie
)
193 return test_bit(FSCACHE_COOKIE_ENABLED
, &cookie
->flags
);
197 * slow-path functions for when there is actually caching available, and the
198 * netfs does actually have a valid token
199 * - these are not to be called directly
200 * - these are undefined symbols when FS-Cache is not configured and the
201 * optimiser takes care of not using them
203 extern int __fscache_register_netfs(struct fscache_netfs
*);
204 extern void __fscache_unregister_netfs(struct fscache_netfs
*);
205 extern struct fscache_cache_tag
*__fscache_lookup_cache_tag(const char *);
206 extern void __fscache_release_cache_tag(struct fscache_cache_tag
*);
208 extern struct fscache_cookie
*__fscache_acquire_cookie(
209 struct fscache_cookie
*,
210 const struct fscache_cookie_def
*,
212 extern void __fscache_relinquish_cookie(struct fscache_cookie
*, bool);
213 extern int __fscache_check_consistency(struct fscache_cookie
*);
214 extern void __fscache_update_cookie(struct fscache_cookie
*);
215 extern int __fscache_attr_changed(struct fscache_cookie
*);
216 extern void __fscache_invalidate(struct fscache_cookie
*);
217 extern void __fscache_wait_on_invalidate(struct fscache_cookie
*);
218 extern int __fscache_read_or_alloc_page(struct fscache_cookie
*,
220 fscache_rw_complete_t
,
223 extern int __fscache_read_or_alloc_pages(struct fscache_cookie
*,
224 struct address_space
*,
227 fscache_rw_complete_t
,
230 extern int __fscache_alloc_page(struct fscache_cookie
*, struct page
*, gfp_t
);
231 extern int __fscache_write_page(struct fscache_cookie
*, struct page
*, gfp_t
);
232 extern void __fscache_uncache_page(struct fscache_cookie
*, struct page
*);
233 extern bool __fscache_check_page_write(struct fscache_cookie
*, struct page
*);
234 extern void __fscache_wait_on_page_write(struct fscache_cookie
*, struct page
*);
235 extern bool __fscache_maybe_release_page(struct fscache_cookie
*, struct page
*,
237 extern void __fscache_uncache_all_inode_pages(struct fscache_cookie
*,
239 extern void __fscache_readpages_cancel(struct fscache_cookie
*cookie
,
240 struct list_head
*pages
);
241 extern void __fscache_disable_cookie(struct fscache_cookie
*, bool);
242 extern void __fscache_enable_cookie(struct fscache_cookie
*,
243 bool (*)(void *), void *);
246 * fscache_register_netfs - Register a filesystem as desiring caching services
247 * @netfs: The description of the filesystem
249 * Register a filesystem as desiring caching services if they're available.
251 * See Documentation/filesystems/caching/netfs-api.txt for a complete
255 int fscache_register_netfs(struct fscache_netfs
*netfs
)
257 if (fscache_available())
258 return __fscache_register_netfs(netfs
);
264 * fscache_unregister_netfs - Indicate that a filesystem no longer desires
266 * @netfs: The description of the filesystem
268 * Indicate that a filesystem no longer desires caching services for the
271 * See Documentation/filesystems/caching/netfs-api.txt for a complete
275 void fscache_unregister_netfs(struct fscache_netfs
*netfs
)
277 if (fscache_available())
278 __fscache_unregister_netfs(netfs
);
282 * fscache_lookup_cache_tag - Look up a cache tag
283 * @name: The name of the tag to search for
285 * Acquire a specific cache referral tag that can be used to select a specific
286 * cache in which to cache an index.
288 * See Documentation/filesystems/caching/netfs-api.txt for a complete
292 struct fscache_cache_tag
*fscache_lookup_cache_tag(const char *name
)
294 if (fscache_available())
295 return __fscache_lookup_cache_tag(name
);
301 * fscache_release_cache_tag - Release a cache tag
302 * @tag: The tag to release
304 * Release a reference to a cache referral tag previously looked up.
306 * See Documentation/filesystems/caching/netfs-api.txt for a complete
310 void fscache_release_cache_tag(struct fscache_cache_tag
*tag
)
312 if (fscache_available())
313 __fscache_release_cache_tag(tag
);
317 * fscache_acquire_cookie - Acquire a cookie to represent a cache object
318 * @parent: The cookie that's to be the parent of this one
319 * @def: A description of the cache object, including callback operations
320 * @netfs_data: An arbitrary piece of data to be kept in the cookie to
321 * represent the cache object to the netfs
322 * @enable: Whether or not to enable a data cookie immediately
324 * This function is used to inform FS-Cache about part of an index hierarchy
325 * that can be used to locate files. This is done by requesting a cookie for
326 * each index in the path to the file.
328 * See Documentation/filesystems/caching/netfs-api.txt for a complete
332 struct fscache_cookie
*fscache_acquire_cookie(
333 struct fscache_cookie
*parent
,
334 const struct fscache_cookie_def
*def
,
338 if (fscache_cookie_valid(parent
) && fscache_cookie_enabled(parent
))
339 return __fscache_acquire_cookie(parent
, def
, netfs_data
,
346 * fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
348 * @cookie: The cookie being returned
349 * @retire: True if the cache object the cookie represents is to be discarded
351 * This function returns a cookie to the cache, forcibly discarding the
352 * associated cache object if retire is set to true.
354 * See Documentation/filesystems/caching/netfs-api.txt for a complete
358 void fscache_relinquish_cookie(struct fscache_cookie
*cookie
, bool retire
)
360 if (fscache_cookie_valid(cookie
))
361 __fscache_relinquish_cookie(cookie
, retire
);
365 * fscache_check_consistency - Request that if the cache is updated
366 * @cookie: The cookie representing the cache object
368 * Request an consistency check from fscache, which passes the request
369 * to the backing cache.
371 * Returns 0 if consistent and -ESTALE if inconsistent. May also
372 * return -ENOMEM and -ERESTARTSYS.
375 int fscache_check_consistency(struct fscache_cookie
*cookie
)
377 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
378 return __fscache_check_consistency(cookie
);
384 * fscache_update_cookie - Request that a cache object be updated
385 * @cookie: The cookie representing the cache object
387 * Request an update of the index data for the cache object associated with the
390 * See Documentation/filesystems/caching/netfs-api.txt for a complete
394 void fscache_update_cookie(struct fscache_cookie
*cookie
)
396 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
397 __fscache_update_cookie(cookie
);
401 * fscache_pin_cookie - Pin a data-storage cache object in its cache
402 * @cookie: The cookie representing the cache object
404 * Permit data-storage cache objects to be pinned in the cache.
406 * See Documentation/filesystems/caching/netfs-api.txt for a complete
410 int fscache_pin_cookie(struct fscache_cookie
*cookie
)
416 * fscache_pin_cookie - Unpin a data-storage cache object in its cache
417 * @cookie: The cookie representing the cache object
419 * Permit data-storage cache objects to be unpinned from the cache.
421 * See Documentation/filesystems/caching/netfs-api.txt for a complete
425 void fscache_unpin_cookie(struct fscache_cookie
*cookie
)
430 * fscache_attr_changed - Notify cache that an object's attributes changed
431 * @cookie: The cookie representing the cache object
433 * Send a notification to the cache indicating that an object's attributes have
434 * changed. This includes the data size. These attributes will be obtained
435 * through the get_attr() cookie definition op.
437 * See Documentation/filesystems/caching/netfs-api.txt for a complete
441 int fscache_attr_changed(struct fscache_cookie
*cookie
)
443 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
444 return __fscache_attr_changed(cookie
);
450 * fscache_invalidate - Notify cache that an object needs invalidation
451 * @cookie: The cookie representing the cache object
453 * Notify the cache that an object is needs to be invalidated and that it
454 * should abort any retrievals or stores it is doing on the cache. The object
455 * is then marked non-caching until such time as the invalidation is complete.
457 * This can be called with spinlocks held.
459 * See Documentation/filesystems/caching/netfs-api.txt for a complete
463 void fscache_invalidate(struct fscache_cookie
*cookie
)
465 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
466 __fscache_invalidate(cookie
);
470 * fscache_wait_on_invalidate - Wait for invalidation to complete
471 * @cookie: The cookie representing the cache object
473 * Wait for the invalidation of an object to complete.
475 * See Documentation/filesystems/caching/netfs-api.txt for a complete
479 void fscache_wait_on_invalidate(struct fscache_cookie
*cookie
)
481 if (fscache_cookie_valid(cookie
))
482 __fscache_wait_on_invalidate(cookie
);
486 * fscache_reserve_space - Reserve data space for a cached object
487 * @cookie: The cookie representing the cache object
488 * @i_size: The amount of space to be reserved
490 * Reserve an amount of space in the cache for the cache object attached to a
491 * cookie so that a write to that object within the space can always be
494 * See Documentation/filesystems/caching/netfs-api.txt for a complete
498 int fscache_reserve_space(struct fscache_cookie
*cookie
, loff_t size
)
504 * fscache_read_or_alloc_page - Read a page from the cache or allocate a block
505 * in which to store it
506 * @cookie: The cookie representing the cache object
507 * @page: The netfs page to fill if possible
508 * @end_io_func: The callback to invoke when and if the page is filled
509 * @context: An arbitrary piece of data to pass on to end_io_func()
510 * @gfp: The conditions under which memory allocation should be made
512 * Read a page from the cache, or if that's not possible make a potential
513 * one-block reservation in the cache into which the page may be stored once
514 * fetched from the server.
516 * If the page is not backed by the cache object, or if it there's some reason
517 * it can't be, -ENOBUFS will be returned and nothing more will be done for
520 * Else, if that page is backed by the cache, a read will be initiated directly
521 * to the netfs's page and 0 will be returned by this function. The
522 * end_io_func() callback will be invoked when the operation terminates on a
523 * completion or failure. Note that the callback may be invoked before the
526 * Else, if the page is unbacked, -ENODATA is returned and a block may have
527 * been allocated in the cache.
529 * See Documentation/filesystems/caching/netfs-api.txt for a complete
533 int fscache_read_or_alloc_page(struct fscache_cookie
*cookie
,
535 fscache_rw_complete_t end_io_func
,
539 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
540 return __fscache_read_or_alloc_page(cookie
, page
, end_io_func
,
547 * fscache_read_or_alloc_pages - Read pages from the cache and/or allocate
548 * blocks in which to store them
549 * @cookie: The cookie representing the cache object
550 * @mapping: The netfs inode mapping to which the pages will be attached
551 * @pages: A list of potential netfs pages to be filled
552 * @nr_pages: Number of pages to be read and/or allocated
553 * @end_io_func: The callback to invoke when and if each page is filled
554 * @context: An arbitrary piece of data to pass on to end_io_func()
555 * @gfp: The conditions under which memory allocation should be made
557 * Read a set of pages from the cache, or if that's not possible, attempt to
558 * make a potential one-block reservation for each page in the cache into which
559 * that page may be stored once fetched from the server.
561 * If some pages are not backed by the cache object, or if it there's some
562 * reason they can't be, -ENOBUFS will be returned and nothing more will be
563 * done for that pages.
565 * Else, if some of the pages are backed by the cache, a read will be initiated
566 * directly to the netfs's page and 0 will be returned by this function. The
567 * end_io_func() callback will be invoked when the operation terminates on a
568 * completion or failure. Note that the callback may be invoked before the
571 * Else, if a page is unbacked, -ENODATA is returned and a block may have
572 * been allocated in the cache.
574 * Because the function may want to return all of -ENOBUFS, -ENODATA and 0 in
575 * regard to different pages, the return values are prioritised in that order.
576 * Any pages submitted for reading are removed from the pages list.
578 * See Documentation/filesystems/caching/netfs-api.txt for a complete
582 int fscache_read_or_alloc_pages(struct fscache_cookie
*cookie
,
583 struct address_space
*mapping
,
584 struct list_head
*pages
,
586 fscache_rw_complete_t end_io_func
,
590 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
591 return __fscache_read_or_alloc_pages(cookie
, mapping
, pages
,
592 nr_pages
, end_io_func
,
599 * fscache_alloc_page - Allocate a block in which to store a page
600 * @cookie: The cookie representing the cache object
601 * @page: The netfs page to allocate a page for
602 * @gfp: The conditions under which memory allocation should be made
604 * Request Allocation a block in the cache in which to store a netfs page
605 * without retrieving any contents from the cache.
607 * If the page is not backed by a file then -ENOBUFS will be returned and
608 * nothing more will be done, and no reservation will be made.
610 * Else, a block will be allocated if one wasn't already, and 0 will be
613 * See Documentation/filesystems/caching/netfs-api.txt for a complete
617 int fscache_alloc_page(struct fscache_cookie
*cookie
,
621 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
622 return __fscache_alloc_page(cookie
, page
, gfp
);
628 * fscache_readpages_cancel - Cancel read/alloc on pages
629 * @cookie: The cookie representing the inode's cache object.
630 * @pages: The netfs pages that we canceled write on in readpages()
632 * Uncache/unreserve the pages reserved earlier in readpages() via
633 * fscache_readpages_or_alloc() and similar. In most successful caches in
634 * readpages() this doesn't do anything. In cases when the underlying netfs's
635 * readahead failed we need to clean up the pagelist (unmark and uncache).
637 * This function may sleep as it may have to clean up disk state.
640 void fscache_readpages_cancel(struct fscache_cookie
*cookie
,
641 struct list_head
*pages
)
643 if (fscache_cookie_valid(cookie
))
644 __fscache_readpages_cancel(cookie
, pages
);
648 * fscache_write_page - Request storage of a page in the cache
649 * @cookie: The cookie representing the cache object
650 * @page: The netfs page to store
651 * @gfp: The conditions under which memory allocation should be made
653 * Request the contents of the netfs page be written into the cache. This
654 * request may be ignored if no cache block is currently allocated, in which
655 * case it will return -ENOBUFS.
657 * If a cache block was already allocated, a write will be initiated and 0 will
658 * be returned. The PG_fscache_write page bit is set immediately and will then
659 * be cleared at the completion of the write to indicate the success or failure
660 * of the operation. Note that the completion may happen before the return.
662 * See Documentation/filesystems/caching/netfs-api.txt for a complete
666 int fscache_write_page(struct fscache_cookie
*cookie
,
670 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
671 return __fscache_write_page(cookie
, page
, gfp
);
677 * fscache_uncache_page - Indicate that caching is no longer required on a page
678 * @cookie: The cookie representing the cache object
679 * @page: The netfs page that was being cached.
681 * Tell the cache that we no longer want a page to be cached and that it should
682 * remove any knowledge of the netfs page it may have.
684 * Note that this cannot cancel any outstanding I/O operations between this
685 * page and the cache.
687 * See Documentation/filesystems/caching/netfs-api.txt for a complete
691 void fscache_uncache_page(struct fscache_cookie
*cookie
,
694 if (fscache_cookie_valid(cookie
))
695 __fscache_uncache_page(cookie
, page
);
699 * fscache_check_page_write - Ask if a page is being writing to the cache
700 * @cookie: The cookie representing the cache object
701 * @page: The netfs page that is being cached.
703 * Ask the cache if a page is being written to the cache.
705 * See Documentation/filesystems/caching/netfs-api.txt for a complete
709 bool fscache_check_page_write(struct fscache_cookie
*cookie
,
712 if (fscache_cookie_valid(cookie
))
713 return __fscache_check_page_write(cookie
, page
);
718 * fscache_wait_on_page_write - Wait for a page to complete writing to the cache
719 * @cookie: The cookie representing the cache object
720 * @page: The netfs page that is being cached.
722 * Ask the cache to wake us up when a page is no longer being written to the
725 * See Documentation/filesystems/caching/netfs-api.txt for a complete
729 void fscache_wait_on_page_write(struct fscache_cookie
*cookie
,
732 if (fscache_cookie_valid(cookie
))
733 __fscache_wait_on_page_write(cookie
, page
);
737 * fscache_maybe_release_page - Consider releasing a page, cancelling a store
738 * @cookie: The cookie representing the cache object
739 * @page: The netfs page that is being cached.
740 * @gfp: The gfp flags passed to releasepage()
742 * Consider releasing a page for the vmscan algorithm, on behalf of the netfs's
743 * releasepage() call. A storage request on the page may cancelled if it is
744 * not currently being processed.
746 * The function returns true if the page no longer has a storage request on it,
747 * and false if a storage request is left in place. If true is returned, the
748 * page will have been passed to fscache_uncache_page(). If false is returned
749 * the page cannot be freed yet.
752 bool fscache_maybe_release_page(struct fscache_cookie
*cookie
,
756 if (fscache_cookie_valid(cookie
) && PageFsCache(page
))
757 return __fscache_maybe_release_page(cookie
, page
, gfp
);
762 * fscache_uncache_all_inode_pages - Uncache all an inode's pages
763 * @cookie: The cookie representing the inode's cache object.
764 * @inode: The inode to uncache pages from.
766 * Uncache all the pages in an inode that are marked PG_fscache, assuming them
767 * to be associated with the given cookie.
769 * This function may sleep. It will wait for pages that are being written out
770 * and will wait whilst the PG_fscache mark is removed by the cache.
773 void fscache_uncache_all_inode_pages(struct fscache_cookie
*cookie
,
776 if (fscache_cookie_valid(cookie
))
777 __fscache_uncache_all_inode_pages(cookie
, inode
);
781 * fscache_disable_cookie - Disable a cookie
782 * @cookie: The cookie representing the cache object
783 * @invalidate: Invalidate the backing object
785 * Disable a cookie from accepting further alloc, read, write, invalidate,
786 * update or acquire operations. Outstanding operations can still be waited
787 * upon and pages can still be uncached and the cookie relinquished.
789 * This will not return until all outstanding operations have completed.
791 * If @invalidate is set, then the backing object will be invalidated and
792 * detached, otherwise it will just be detached.
795 void fscache_disable_cookie(struct fscache_cookie
*cookie
, bool invalidate
)
797 if (fscache_cookie_valid(cookie
) && fscache_cookie_enabled(cookie
))
798 __fscache_disable_cookie(cookie
, invalidate
);
802 * fscache_enable_cookie - Reenable a cookie
803 * @cookie: The cookie representing the cache object
804 * @can_enable: A function to permit enablement once lock is held
805 * @data: Data for can_enable()
807 * Reenable a previously disabled cookie, allowing it to accept further alloc,
808 * read, write, invalidate, update or acquire operations. An attempt will be
809 * made to immediately reattach the cookie to a backing object.
811 * The can_enable() function is called (if not NULL) once the enablement lock
812 * is held to rule on whether enablement is still permitted to go ahead.
815 void fscache_enable_cookie(struct fscache_cookie
*cookie
,
816 bool (*can_enable
)(void *data
),
819 if (fscache_cookie_valid(cookie
) && !fscache_cookie_enabled(cookie
))
820 __fscache_enable_cookie(cookie
, can_enable
, data
);
823 #endif /* _LINUX_FSCACHE_H */