diff options
Diffstat (limited to 'Documentation/filesystems/caching/netfs-api.txt')
-rw-r--r-- | Documentation/filesystems/caching/netfs-api.txt | 73 |
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 | ||
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. |
@@ -733,6 +739,47 @@ Note that partial updates may happen automatically at other times, such as when | |||
733 | data blocks are added to a data file object. | 739 | data blocks are added to a data file object. |
734 | 740 | ||
735 | 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 | |||
736 | =============================== | 783 | =============================== |
737 | MISCELLANEOUS COOKIE OPERATIONS | 784 | MISCELLANEOUS COOKIE OPERATIONS |
738 | =============================== | 785 | =============================== |
@@ -778,7 +825,7 @@ COOKIE UNREGISTRATION | |||
778 | To get rid of a cookie, this function should be called. | 825 | To 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 | ||
783 | 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 |
784 | 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. |