aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems/caching/netfs-api.txt
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-09-20 19:09:31 -0400
committerDavid Howells <dhowells@redhat.com>2013-09-27 13:40:25 -0400
commit94d30ae90a00cafe686c1057be57f4885f963abf (patch)
tree2a4f927bcaf87e988f4f180d0a011856064186b5 /Documentation/filesystems/caching/netfs-api.txt
parent8fb883f3e30065529e4f35d4b4f355193dcdb7a2 (diff)
FS-Cache: Provide the ability to enable/disable cookies
Provide the ability to enable and disable fscache cookies. A disabled cookie will reject or ignore further requests to: Acquire a child cookie Invalidate and update backing objects Check the consistency of a backing object Allocate storage for backing page Read backing pages Write to backing pages but still allows: Checks/waits on the completion of already in-progress objects Uncaching of pages Relinquishment of cookies Two new operations are provided: (1) Disable a cookie: void fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate); If the cookie is not already disabled, this locks the cookie against other dis/enablement ops, marks the cookie as being disabled, discards or invalidates any backing objects and waits for cessation of activity on any associated object. This is a wrapper around a chunk split out of fscache_relinquish_cookie(), but it reinitialises the cookie such that it can be reenabled. All possible failures are handled internally. The caller should consider calling fscache_uncache_all_inode_pages() afterwards to make sure all page markings are cleared up. (2) Enable a cookie: void fscache_enable_cookie(struct fscache_cookie *cookie, bool (*can_enable)(void *data), void *data) If the cookie is not already enabled, this locks the cookie against other dis/enablement ops, invokes can_enable() and, if the cookie is not an index cookie, will begin the procedure of acquiring backing objects. The optional can_enable() function is passed the data argument and returns a ruling as to whether or not enablement should actually be permitted to begin. All possible failures are handled internally. The cookie will only be marked as enabled if provisional backing objects are allocated. A later patch will introduce these to NFS. Cookie enablement during nfs_open() is then contingent on i_writecount <= 0. can_enable() checks for a race between open(O_RDONLY) and open(O_WRONLY/O_RDWR). This simplifies NFS's cookie handling and allows us to get rid of open(O_RDONLY) accidentally introducing caching to an inode that's open for writing already. One operation has its API modified: (3) Acquire a cookie. struct fscache_cookie *fscache_acquire_cookie( struct fscache_cookie *parent, const struct fscache_cookie_def *def, void *netfs_data, bool enable); This now has an additional argument that indicates whether the requested cookie should be enabled by default. It doesn't need the can_enable() function because the caller must prevent multiple calls for the same netfs object and it doesn't need to take the enablement lock because no one else can get at the cookie before this returns. Signed-off-by: David Howells <dhowells@redhat.com
Diffstat (limited to 'Documentation/filesystems/caching/netfs-api.txt')
-rw-r--r--Documentation/filesystems/caching/netfs-api.txt73
1 files changed, 60 insertions, 13 deletions
diff --git a/Documentation/filesystems/caching/netfs-api.txt b/Documentation/filesystems/caching/netfs-api.txt
index 11a0a40ce445..aed6b94160b1 100644
--- a/Documentation/filesystems/caching/netfs-api.txt
+++ b/Documentation/filesystems/caching/netfs-api.txt
@@ -29,15 +29,16 @@ This document contains the following sections:
29 (6) Index registration 29 (6) Index registration
30 (7) Data file registration 30 (7) Data file registration
31 (8) Miscellaneous object registration 31 (8) Miscellaneous object registration
32 (9) Setting the data file size 32 (9) Setting the data file size
33 (10) Page alloc/read/write 33 (10) Page alloc/read/write
34 (11) Page uncaching 34 (11) Page uncaching
35 (12) Index and data file consistency 35 (12) Index and data file consistency
36 (13) Miscellaneous cookie operations 36 (13) Cookie enablement
37 (14) Cookie unregistration 37 (14) Miscellaneous cookie operations
38 (15) Index invalidation 38 (15) Cookie unregistration
39 (16) Data file invalidation 39 (16) Index invalidation
40 (17) FS-Cache specific page flags. 40 (17) Data file invalidation
41 (18) FS-Cache specific page flags.
41 42
42 43
43============================= 44=============================
@@ -334,7 +335,8 @@ the path to the file:
334 struct fscache_cookie * 335 struct fscache_cookie *
335 fscache_acquire_cookie(struct fscache_cookie *parent, 336 fscache_acquire_cookie(struct fscache_cookie *parent,
336 const struct fscache_object_def *def, 337 const struct fscache_object_def *def,
337 void *netfs_data); 338 void *netfs_data,
339 bool enable);
338 340
339This function creates an index entry in the index represented by parent, 341This function creates an index entry in the index represented by parent,
340filling in the index entry by calling the operations pointed to by def. 342filling in the index entry by calling the operations pointed to by def.
@@ -350,6 +352,10 @@ object needs to be created somewhere down the hierarchy. Furthermore, an index
350may be created in several different caches independently at different times. 352may be created in several different caches independently at different times.
351This is all handled transparently, and the netfs doesn't see any of it. 353This is all handled transparently, and the netfs doesn't see any of it.
352 354
355A cookie will be created in the disabled state if enabled is false. A cookie
356must be enabled to do anything with it. A disabled cookie can be enabled by
357calling fscache_enable_cookie() (see below).
358
353For example, with AFS, a cell would be added to the primary index. This index 359For example, with AFS, a cell would be added to the primary index. This index
354entry would have a dependent inode containing a volume location index for the 360entry would have a dependent inode containing a volume location index for the
355volume mappings within this cell: 361volume mappings within this cell:
@@ -357,7 +363,7 @@ volume mappings within this cell:
357 cell->cache = 363 cell->cache =
358 fscache_acquire_cookie(afs_cache_netfs.primary_index, 364 fscache_acquire_cookie(afs_cache_netfs.primary_index,
359 &afs_cell_cache_index_def, 365 &afs_cell_cache_index_def,
360 cell); 366 cell, true);
361 367
362Then when a volume location was accessed, it would be entered into the cell's 368Then when a volume location was accessed, it would be entered into the cell's
363index and an inode would be allocated that acts as a volume type and hash chain 369index and an inode would be allocated that acts as a volume type and hash chain
@@ -366,7 +372,7 @@ combination:
366 vlocation->cache = 372 vlocation->cache =
367 fscache_acquire_cookie(cell->cache, 373 fscache_acquire_cookie(cell->cache,
368 &afs_vlocation_cache_index_def, 374 &afs_vlocation_cache_index_def,
369 vlocation); 375 vlocation, true);
370 376
371And then a particular flavour of volume (R/O for example) could be added to 377And then a particular flavour of volume (R/O for example) could be added to
372that index, creating another index for vnodes (AFS inode equivalents): 378that index, creating another index for vnodes (AFS inode equivalents):
@@ -374,7 +380,7 @@ that index, creating another index for vnodes (AFS inode equivalents):
374 volume->cache = 380 volume->cache =
375 fscache_acquire_cookie(vlocation->cache, 381 fscache_acquire_cookie(vlocation->cache,
376 &afs_volume_cache_index_def, 382 &afs_volume_cache_index_def,
377 volume); 383 volume, true);
378 384
379 385
380====================== 386======================
@@ -388,7 +394,7 @@ the object definition should be something other than index type.
388 vnode->cache = 394 vnode->cache =
389 fscache_acquire_cookie(volume->cache, 395 fscache_acquire_cookie(volume->cache,
390 &afs_vnode_cache_object_def, 396 &afs_vnode_cache_object_def,
391 vnode); 397 vnode, true);
392 398
393 399
394================================= 400=================================
@@ -404,7 +410,7 @@ it would be some other type of object such as a data file.
404 xattr->cache = 410 xattr->cache =
405 fscache_acquire_cookie(vnode->cache, 411 fscache_acquire_cookie(vnode->cache,
406 &afs_xattr_cache_object_def, 412 &afs_xattr_cache_object_def,
407 xattr); 413 xattr, true);
408 414
409Miscellaneous objects might be used to store extended attributes or directory 415Miscellaneous objects might be used to store extended attributes or directory
410entries for example. 416entries for example.
@@ -733,6 +739,47 @@ Note that partial updates may happen automatically at other times, such as when
733data blocks are added to a data file object. 739data blocks are added to a data file object.
734 740
735 741
742=================
743COOKIE ENABLEMENT
744=================
745
746Cookies exist in one of two states: enabled and disabled. If a cookie is
747disabled, it ignores all attempts to acquire child cookies; check, update or
748invalidate its state; allocate, read or write backing pages - though it is
749still possible to uncache pages and relinquish the cookie.
750
751The initial enablement state is set by fscache_acquire_cookie(), but the cookie
752can be enabled or disabled later. To disable a cookie, call:
753
754 void fscache_disable_cookie(struct fscache_cookie *cookie,
755 bool invalidate);
756
757If the cookie is not already disabled, this locks the cookie against other
758enable and disable ops, marks the cookie as being disabled, discards or
759invalidates any backing objects and waits for cessation of activity on any
760associated object before unlocking the cookie.
761
762All possible failures are handled internally. The caller should consider
763calling fscache_uncache_all_inode_pages() afterwards to make sure all page
764markings are cleared up.
765
766Cookies can be enabled or reenabled with:
767
768 void fscache_enable_cookie(struct fscache_cookie *cookie,
769 bool (*can_enable)(void *data),
770 void *data)
771
772If the cookie is not already enabled, this locks the cookie against other
773enable and disable ops, invokes can_enable() and, if the cookie is not an index
774cookie, will begin the procedure of acquiring backing objects.
775
776The optional can_enable() function is passed the data argument and returns a
777ruling as to whether or not enablement should actually be permitted to begin.
778
779All possible failures are handled internally. The cookie will only be marked
780as enabled if provisional backing objects are allocated.
781
782
736=============================== 783===============================
737MISCELLANEOUS COOKIE OPERATIONS 784MISCELLANEOUS COOKIE OPERATIONS
738=============================== 785===============================
@@ -778,7 +825,7 @@ COOKIE UNREGISTRATION
778To get rid of a cookie, this function should be called. 825To get rid of a cookie, this function should be called.
779 826
780 void fscache_relinquish_cookie(struct fscache_cookie *cookie, 827 void fscache_relinquish_cookie(struct fscache_cookie *cookie,
781 int retire); 828 bool retire);
782 829
783If retire is non-zero, then the object will be marked for recycling, and all 830If retire is non-zero, then the object will be marked for recycling, and all
784copies of it will be removed from all active caches in which it is present. 831copies of it will be removed from all active caches in which it is present.