diff options
Diffstat (limited to 'Documentation/filesystems/caching/netfs-api.txt')
-rw-r--r-- | Documentation/filesystems/caching/netfs-api.txt | 110 |
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 | ||
339 | This function creates an index entry in the index represented by parent, | 341 | This function creates an index entry in the index represented by parent, |
340 | filling in the index entry by calling the operations pointed to by def. | 342 | filling 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 | |||
350 | may be created in several different caches independently at different times. | 352 | may be created in several different caches independently at different times. |
351 | This is all handled transparently, and the netfs doesn't see any of it. | 353 | This is all handled transparently, and the netfs doesn't see any of it. |
352 | 354 | ||
355 | A cookie will be created in the disabled state if enabled is false. A cookie | ||
356 | must be enabled to do anything with it. A disabled cookie can be enabled by | ||
357 | calling fscache_enable_cookie() (see below). | ||
358 | |||
353 | For example, with AFS, a cell would be added to the primary index. This index | 359 | For example, with AFS, a cell would be added to the primary index. This index |
354 | entry would have a dependent inode containing a volume location index for the | 360 | entry would have a dependent inode containing a volume location index for the |
355 | volume mappings within this cell: | 361 | volume 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 | ||
362 | Then when a volume location was accessed, it would be entered into the cell's | 368 | Then when a volume location was accessed, it would be entered into the cell's |
363 | index and an inode would be allocated that acts as a volume type and hash chain | 369 | index 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 | ||
371 | And then a particular flavour of volume (R/O for example) could be added to | 377 | And then a particular flavour of volume (R/O for example) could be added to |
372 | that index, creating another index for vnodes (AFS inode equivalents): | 378 | that 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 | ||
409 | Miscellaneous objects might be used to store extended attributes or directory | 415 | Miscellaneous objects might be used to store extended attributes or directory |
410 | entries for example. | 416 | entries for example. |
@@ -433,7 +439,7 @@ to the caller. The attribute adjustment excludes read and write operations. | |||
433 | 439 | ||
434 | 440 | ||
435 | ===================== | 441 | ===================== |
436 | PAGE READ/ALLOC/WRITE | 442 | PAGE ALLOC/READ/WRITE |
437 | ===================== | 443 | ===================== |
438 | 444 | ||
439 | And the sixth step is to store and retrieve pages in the cache. There are | 445 | And 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 | |||
623 | been marked appropriately and will need uncaching. | 629 | been marked appropriately and will need uncaching. |
624 | 630 | ||
625 | 631 | ||
632 | CANCELLATION OF UNREAD PAGES | ||
633 | ---------------------------- | ||
634 | |||
635 | If one or more pages are passed to fscache_read_or_alloc_pages() but not then | ||
636 | read from the cache and also not read from the underlying filesystem then | ||
637 | those pages will need to have any marks and reservations removed. This can be | ||
638 | done by calling: | ||
639 | |||
640 | void fscache_readpages_cancel(struct fscache_cookie *cookie, | ||
641 | struct list_head *pages); | ||
642 | |||
643 | prior to returning to the caller. The cookie argument should be as passed to | ||
644 | fscache_read_or_alloc_pages(). Every page in the pages list will be examined | ||
645 | and any that have PG_fscache set will be uncached. | ||
646 | |||
647 | |||
626 | ============== | 648 | ============== |
627 | PAGE UNCACHING | 649 | PAGE UNCACHING |
628 | ============== | 650 | ============== |
@@ -690,9 +712,18 @@ written to the cache and for the cache to finish with the page generally. No | |||
690 | error is returned. | 712 | error is returned. |
691 | 713 | ||
692 | 714 | ||
693 | ========================== | 715 | =============================== |
694 | INDEX AND DATA FILE UPDATE | 716 | INDEX AND DATA FILE CONSISTENCY |
695 | ========================== | 717 | =============================== |
718 | |||
719 | To find out whether auxiliary data for an object is up to data within the | ||
720 | cache, the following function can be called: | ||
721 | |||
722 | int fscache_check_consistency(struct fscache_cookie *cookie) | ||
723 | |||
724 | This will call back to the netfs to check whether the auxiliary data associated | ||
725 | with a cookie is correct. It returns 0 if it is and -ESTALE if it isn't; it | ||
726 | may also return -ENOMEM and -ERESTARTSYS. | ||
696 | 727 | ||
697 | To request an update of the index data for an index or other object, the | 728 | To request an update of the index data for an index or other object, the |
698 | following function should be called: | 729 | following function should be called: |
@@ -708,6 +739,47 @@ Note that partial updates may happen automatically at other times, such as when | |||
708 | data blocks are added to a data file object. | 739 | data blocks are added to a data file object. |
709 | 740 | ||
710 | 741 | ||
742 | ================= | ||
743 | COOKIE ENABLEMENT | ||
744 | ================= | ||
745 | |||
746 | Cookies exist in one of two states: enabled and disabled. If a cookie is | ||
747 | disabled, it ignores all attempts to acquire child cookies; check, update or | ||
748 | invalidate its state; allocate, read or write backing pages - though it is | ||
749 | still possible to uncache pages and relinquish the cookie. | ||
750 | |||
751 | The initial enablement state is set by fscache_acquire_cookie(), but the cookie | ||
752 | can be enabled or disabled later. To disable a cookie, call: | ||
753 | |||
754 | void fscache_disable_cookie(struct fscache_cookie *cookie, | ||
755 | bool invalidate); | ||
756 | |||
757 | If the cookie is not already disabled, this locks the cookie against other | ||
758 | enable and disable ops, marks the cookie as being disabled, discards or | ||
759 | invalidates any backing objects and waits for cessation of activity on any | ||
760 | associated object before unlocking the cookie. | ||
761 | |||
762 | All possible failures are handled internally. The caller should consider | ||
763 | calling fscache_uncache_all_inode_pages() afterwards to make sure all page | ||
764 | markings are cleared up. | ||
765 | |||
766 | Cookies 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 | |||
772 | If the cookie is not already enabled, this locks the cookie against other | ||
773 | enable and disable ops, invokes can_enable() and, if the cookie is not an index | ||
774 | cookie, will begin the procedure of acquiring backing objects. | ||
775 | |||
776 | The optional can_enable() function is passed the data argument and returns a | ||
777 | ruling as to whether or not enablement should actually be permitted to begin. | ||
778 | |||
779 | All possible failures are handled internally. The cookie will only be marked | ||
780 | as enabled if provisional backing objects are allocated. | ||
781 | |||
782 | |||
711 | =============================== | 783 | =============================== |
712 | MISCELLANEOUS COOKIE OPERATIONS | 784 | MISCELLANEOUS COOKIE OPERATIONS |
713 | =============================== | 785 | =============================== |
@@ -753,7 +825,7 @@ COOKIE UNREGISTRATION | |||
753 | To get rid of a cookie, this function should be called. | 825 | To 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 | ||
758 | If retire is non-zero, then the object will be marked for recycling, and all | 830 | If retire is non-zero, then the object will be marked for recycling, and all |
759 | copies of it will be removed from all active caches in which it is present. | 831 | copies of it will be removed from all active caches in which it is present. |