aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems/caching/netfs-api.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/filesystems/caching/netfs-api.txt')
-rw-r--r--Documentation/filesystems/caching/netfs-api.txt110
1 files changed, 91 insertions, 19 deletions
diff --git a/Documentation/filesystems/caching/netfs-api.txt b/Documentation/filesystems/caching/netfs-api.txt
index 97e6c0ecc5ef..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 update 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.
@@ -433,7 +439,7 @@ to the caller. The attribute adjustment excludes read and write operations.
433 439
434 440
435===================== 441=====================
436PAGE READ/ALLOC/WRITE 442PAGE ALLOC/READ/WRITE
437===================== 443=====================
438 444
439And the sixth step is to store and retrieve pages in the cache. There are 445And the sixth step is to store and retrieve pages in the cache. There are
@@ -499,7 +505,7 @@ Else if there's a copy of the page resident in the cache:
499 (*) An argument that's 0 on success or negative for an error code. 505 (*) An argument that's 0 on success or negative for an error code.
500 506
501 If an error occurs, it should be assumed that the page contains no usable 507 If an error occurs, it should be assumed that the page contains no usable
502 data. 508 data. fscache_readpages_cancel() may need to be called.
503 509
504 end_io_func() will be called in process context if the read is results in 510 end_io_func() will be called in process context if the read is results in
505 an error, but it might be called in interrupt context if the read is 511 an error, but it might be called in interrupt context if the read is
@@ -623,6 +629,22 @@ some of the pages being read and some being allocated. Those pages will have
623been marked appropriately and will need uncaching. 629been marked appropriately and will need uncaching.
624 630
625 631
632CANCELLATION OF UNREAD PAGES
633----------------------------
634
635If one or more pages are passed to fscache_read_or_alloc_pages() but not then
636read from the cache and also not read from the underlying filesystem then
637those pages will need to have any marks and reservations removed. This can be
638done by calling:
639
640 void fscache_readpages_cancel(struct fscache_cookie *cookie,
641 struct list_head *pages);
642
643prior to returning to the caller. The cookie argument should be as passed to
644fscache_read_or_alloc_pages(). Every page in the pages list will be examined
645and any that have PG_fscache set will be uncached.
646
647
626============== 648==============
627PAGE UNCACHING 649PAGE UNCACHING
628============== 650==============
@@ -690,9 +712,18 @@ written to the cache and for the cache to finish with the page generally. No
690error is returned. 712error is returned.
691 713
692 714
693========================== 715===============================
694INDEX AND DATA FILE UPDATE 716INDEX AND DATA FILE CONSISTENCY
695========================== 717===============================
718
719To find out whether auxiliary data for an object is up to data within the
720cache, the following function can be called:
721
722 int fscache_check_consistency(struct fscache_cookie *cookie)
723
724This will call back to the netfs to check whether the auxiliary data associated
725with a cookie is correct. It returns 0 if it is and -ESTALE if it isn't; it
726may also return -ENOMEM and -ERESTARTSYS.
696 727
697To request an update of the index data for an index or other object, the 728To request an update of the index data for an index or other object, the
698following function should be called: 729following function should be called:
@@ -708,6 +739,47 @@ Note that partial updates may happen automatically at other times, such as when
708data blocks are added to a data file object. 739data blocks are added to a data file object.
709 740
710 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
711=============================== 783===============================
712MISCELLANEOUS COOKIE OPERATIONS 784MISCELLANEOUS COOKIE OPERATIONS
713=============================== 785===============================
@@ -753,7 +825,7 @@ COOKIE UNREGISTRATION
753To get rid of a cookie, this function should be called. 825To get rid of a cookie, this function should be called.
754 826
755 void fscache_relinquish_cookie(struct fscache_cookie *cookie, 827 void fscache_relinquish_cookie(struct fscache_cookie *cookie,
756 int retire); 828 bool retire);
757 829
758If 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
759copies 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.