sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget-/translations/zh_CN/filesystems/nfs/rpc-cachemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/zh_TW/filesystems/nfs/rpc-cachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/it_IT/filesystems/nfs/rpc-cachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/ja_JP/filesystems/nfs/rpc-cachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/ko_KR/filesystems/nfs/rpc-cachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget-/translations/sp_SP/filesystems/nfs/rpc-cachemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h RPC Cacheh]h RPC Cache}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhG/var/lib/git/docbuild/linux/Documentation/filesystems/nfs/rpc-cache.rsthKubh paragraph)}(hThis document gives a brief introduction to the caching mechanisms in the sunrpc layer that is used, in particular, for NFS authentication.h]hThis document gives a brief introduction to the caching mechanisms in the sunrpc layer that is used, in particular, for NFS authentication.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hCachesh]hCaches}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(h`The caching replaces the old exports table and allows for a wide variety of values to be caches.h]h`The caching replaces the old exports table and allows for a wide variety of values to be caches.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hThere are a number of caches that are similar in structure though quite possibly very different in content and use. There is a corpus of common code for managing these caches.h]hThere are a number of caches that are similar in structure though quite possibly very different in content and use. There is a corpus of common code for managing these caches.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h4Examples of caches that are likely to be needed are:h]h4Examples of caches that are likely to be needed are:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh block_quote)}(hXh- mapping from IP address to client name - mapping from client name and filesystem to export options - mapping from UID to list of GIDs, to work around NFS's limitation of 16 gids. - mappings between local UID/GID and remote UID/GID for sites that do not have uniform uid assignment - mapping from network identify to public key for crypto authentication. h]h bullet_list)}(hhh](h list_item)}(h&mapping from IP address to client nameh]h)}(hjh]h&mapping from IP address to client name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hj ubj)}(h9mapping from client name and filesystem to export optionsh]h)}(hj(h]h9mapping from client name and filesystem to export options}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj&ubah}(h]h ]h"]h$]h&]uh1j hj ubj)}(hMmapping from UID to list of GIDs, to work around NFS's limitation of 16 gids.h]h)}(hMmapping from UID to list of GIDs, to work around NFS's limitation of 16 gids.h]hOmapping from UID to list of GIDs, to work around NFS’s limitation of 16 gids.}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj=ubah}(h]h ]h"]h$]h&]uh1j hj ubj)}(hcmappings between local UID/GID and remote UID/GID for sites that do not have uniform uid assignmenth]h)}(hcmappings between local UID/GID and remote UID/GID for sites that do not have uniform uid assignmenth]hcmappings between local UID/GID and remote UID/GID for sites that do not have uniform uid assignment}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubah}(h]h ]h"]h$]h&]uh1j hj ubj)}(hGmapping from network identify to public key for crypto authentication. h]h)}(hFmapping from network identify to public key for crypto authentication.h]hFmapping from network identify to public key for crypto authentication.}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjmubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhhhhubh)}(h'The common code handles such things as:h]h'The common code handles such things as:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubj)}(hX- general cache lookup with correct locking - supporting 'NEGATIVE' as well as positive entries - allowing an EXPIRED time on cache items, and removing items after they expire, and are no longer in-use. - making requests to user-space to fill in cache entries - allowing user-space to directly set entries in the cache - delaying RPC requests that depend on as-yet incomplete cache entries, and replaying those requests when the cache entry is complete. - clean out old entries as they expire. h]j )}(hhh](j)}(h)general cache lookup with correct lockingh]h)}(hjh]h)general cache lookup with correct locking}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(h1supporting 'NEGATIVE' as well as positive entriesh]h)}(hjh]h5supporting ‘NEGATIVE’ as well as positive entries}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(hhallowing an EXPIRED time on cache items, and removing items after they expire, and are no longer in-use.h]h)}(hhallowing an EXPIRED time on cache items, and removing items after they expire, and are no longer in-use.h]hhallowing an EXPIRED time on cache items, and removing items after they expire, and are no longer in-use.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(h6making requests to user-space to fill in cache entriesh]h)}(hjh]h6making requests to user-space to fill in cache entries}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK#hjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(h8allowing user-space to directly set entries in the cacheh]h)}(hjh]h8allowing user-space to directly set entries in the cache}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(hdelaying RPC requests that depend on as-yet incomplete cache entries, and replaying those requests when the cache entry is complete.h]h)}(hdelaying RPC requests that depend on as-yet incomplete cache entries, and replaying those requests when the cache entry is complete.h]hdelaying RPC requests that depend on as-yet incomplete cache entries, and replaying those requests when the cache entry is complete.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(h&clean out old entries as they expire. h]h)}(h%clean out old entries as they expire.h]h%clean out old entries as they expire.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hj4ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhhhhubh)}(hhh](h)}(hCreating a Cacheh]hCreating a Cache}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjXhhhhhK+ubj )}(hhh](j)}(hX-A cache needs a datum to store. This is in the form of a structure definition that must contain a struct cache_head as an element, usually the first. It will also contain a key and some content. Each cache element is reference counted and contains expiry and update times for use in cache management.h]h)}(hX-A cache needs a datum to store. This is in the form of a structure definition that must contain a struct cache_head as an element, usually the first. It will also contain a key and some content. Each cache element is reference counted and contains expiry and update times for use in cache management.h]hX-A cache needs a datum to store. This is in the form of a structure definition that must contain a struct cache_head as an element, usually the first. It will also contain a key and some content. Each cache element is reference counted and contains expiry and update times for use in cache management.}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hjlubah}(h]h ]h"]h$]h&]uh1j hjihhhhhNubj)}(hXQA cache needs a "cache_detail" structure that describes the cache. This stores the hash table, some parameters for cache management, and some operations detailing how to work with particular cache items. The operations are: struct cache_head \*alloc(void) This simply allocates appropriate memory and returns a pointer to the cache_detail embedded within the structure void cache_put(struct kref \*) This is called when the last reference to an item is dropped. The pointer passed is to the 'ref' field in the cache_head. cache_put should release any references create by 'cache_init' and, if CACHE_VALID is set, any references created by cache_update. It should then release the memory allocated by 'alloc'. int match(struct cache_head \*orig, struct cache_head \*new) test if the keys in the two structures match. Return 1 if they do, 0 if they don't. void init(struct cache_head \*orig, struct cache_head \*new) Set the 'key' fields in 'new' from 'orig'. This may include taking references to shared objects. void update(struct cache_head \*orig, struct cache_head \*new) Set the 'content' fields in 'new' from 'orig'. int cache_show(struct seq_file \*m, struct cache_detail \*cd, struct cache_head \*h) Optional. Used to provide a /proc file that lists the contents of a cache. This should show one item, usually on just one line. int cache_request(struct cache_detail \*cd, struct cache_head \*h, char \*\*bpp, int \*blen) Format a request to be send to user-space for an item to be instantiated. \*bpp is a buffer of size \*blen. bpp should be moved forward over the encoded message, and \*blen should be reduced to show how much free space remains. Return 0 on success or <0 if not enough room or other problem. int cache_parse(struct cache_detail \*cd, char \*buf, int len) A message from user space has arrived to fill out a cache entry. It is in 'buf' of length 'len'. cache_parse should parse this, find the item in the cache with sunrpc_cache_lookup_rcu, and update the item with sunrpc_cache_update. h](h)}(hA cache needs a "cache_detail" structure that describes the cache. This stores the hash table, some parameters for cache management, and some operations detailing how to work with particular cache items.h]hA cache needs a “cache_detail” structure that describes the cache. This stores the hash table, some parameters for cache management, and some operations detailing how to work with particular cache items.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK3hjubh)}(hThe operations are:h]hThe operations are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjubj)}(hXIstruct cache_head \*alloc(void) This simply allocates appropriate memory and returns a pointer to the cache_detail embedded within the structure void cache_put(struct kref \*) This is called when the last reference to an item is dropped. The pointer passed is to the 'ref' field in the cache_head. cache_put should release any references create by 'cache_init' and, if CACHE_VALID is set, any references created by cache_update. It should then release the memory allocated by 'alloc'. int match(struct cache_head \*orig, struct cache_head \*new) test if the keys in the two structures match. Return 1 if they do, 0 if they don't. void init(struct cache_head \*orig, struct cache_head \*new) Set the 'key' fields in 'new' from 'orig'. This may include taking references to shared objects. void update(struct cache_head \*orig, struct cache_head \*new) Set the 'content' fields in 'new' from 'orig'. int cache_show(struct seq_file \*m, struct cache_detail \*cd, struct cache_head \*h) Optional. Used to provide a /proc file that lists the contents of a cache. This should show one item, usually on just one line. int cache_request(struct cache_detail \*cd, struct cache_head \*h, char \*\*bpp, int \*blen) Format a request to be send to user-space for an item to be instantiated. \*bpp is a buffer of size \*blen. bpp should be moved forward over the encoded message, and \*blen should be reduced to show how much free space remains. Return 0 on success or <0 if not enough room or other problem. int cache_parse(struct cache_detail \*cd, char \*buf, int len) A message from user space has arrived to fill out a cache entry. It is in 'buf' of length 'len'. cache_parse should parse this, find the item in the cache with sunrpc_cache_lookup_rcu, and update the item with sunrpc_cache_update. h]hdefinition_list)}(hhh](hdefinition_list_item)}(hstruct cache_head \*alloc(void) This simply allocates appropriate memory and returns a pointer to the cache_detail embedded within the structure h](hterm)}(hstruct cache_head \*alloc(void)h]hstruct cache_head *alloc(void)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK=hjubh definition)}(hhh]h)}(hpThis simply allocates appropriate memory and returns a pointer to the cache_detail embedded within the structureh]hpThis simply allocates appropriate memory and returns a pointer to the cache_detail embedded within the structure}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK=hjubj)}(hXVvoid cache_put(struct kref \*) This is called when the last reference to an item is dropped. The pointer passed is to the 'ref' field in the cache_head. cache_put should release any references create by 'cache_init' and, if CACHE_VALID is set, any references created by cache_update. It should then release the memory allocated by 'alloc'. h](j)}(hvoid cache_put(struct kref \*)h]hvoid cache_put(struct kref *)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKFhjubj)}(hhh]h)}(hX6This is called when the last reference to an item is dropped. The pointer passed is to the 'ref' field in the cache_head. cache_put should release any references create by 'cache_init' and, if CACHE_VALID is set, any references created by cache_update. It should then release the memory allocated by 'alloc'.h]hXBThis is called when the last reference to an item is dropped. The pointer passed is to the ‘ref’ field in the cache_head. cache_put should release any references create by ‘cache_init’ and, if CACHE_VALID is set, any references created by cache_update. It should then release the memory allocated by ‘alloc’.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKFhjubj)}(hint match(struct cache_head \*orig, struct cache_head \*new) test if the keys in the two structures match. Return 1 if they do, 0 if they don't. h](j)}(hvoid update(struct cache_head \*orig, struct cache_head \*new)h]h>void update(struct cache_head *orig, struct cache_head *new)}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKQhjoubj)}(hhh]h)}(h.Set the 'content' fields in 'new' from 'orig'.h]h:Set the ‘content’ fields in ‘new’ from ‘orig’.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjubah}(h]h ]h"]h$]h&]uh1jhjoubeh}(h]h ]h"]h$]h&]uh1jhhhKQhjubj)}(hint cache_show(struct seq_file \*m, struct cache_detail \*cd, struct cache_head \*h) Optional. Used to provide a /proc file that lists the contents of a cache. This should show one item, usually on just one line. h](j)}(hTint cache_show(struct seq_file \*m, struct cache_detail \*cd, struct cache_head \*h)h]hTint cache_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKVhjubj)}(hhh]h)}(hOptional. Used to provide a /proc file that lists the contents of a cache. This should show one item, usually on just one line.h]hOptional. Used to provide a /proc file that lists the contents of a cache. This should show one item, usually on just one line.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKVhjubj)}(hXint cache_request(struct cache_detail \*cd, struct cache_head \*h, char \*\*bpp, int \*blen) Format a request to be send to user-space for an item to be instantiated. \*bpp is a buffer of size \*blen. bpp should be moved forward over the encoded message, and \*blen should be reduced to show how much free space remains. Return 0 on success or <0 if not enough room or other problem. h](j)}(h\int cache_request(struct cache_detail \*cd, struct cache_head \*h, char \*\*bpp, int \*blen)h]h\int cache_request(struct cache_detail *cd, struct cache_head *h, char **bpp, int *blen)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK^hjubj)}(hhh]h)}(hX%Format a request to be send to user-space for an item to be instantiated. \*bpp is a buffer of size \*blen. bpp should be moved forward over the encoded message, and \*blen should be reduced to show how much free space remains. Return 0 on success or <0 if not enough room or other problem.h]hX%Format a request to be send to user-space for an item to be instantiated. *bpp is a buffer of size *blen. bpp should be moved forward over the encoded message, and *blen should be reduced to show how much free space remains. Return 0 on success or <0 if not enough room or other problem.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK^hjubj)}(hX(int cache_parse(struct cache_detail \*cd, char \*buf, int len) A message from user space has arrived to fill out a cache entry. It is in 'buf' of length 'len'. cache_parse should parse this, find the item in the cache with sunrpc_cache_lookup_rcu, and update the item with sunrpc_cache_update. h](j)}(h>int cache_parse(struct cache_detail \*cd, char \*buf, int len)h]h>int cache_parse(struct cache_detail *cd, char *buf, int len)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKfhjubj)}(hhh]h)}(hA message from user space has arrived to fill out a cache entry. It is in 'buf' of length 'len'. cache_parse should parse this, find the item in the cache with sunrpc_cache_lookup_rcu, and update the item with sunrpc_cache_update.h]hA message from user space has arrived to fill out a cache entry. It is in ‘buf’ of length ‘len’. cache_parse should parse this, find the item in the cache with sunrpc_cache_lookup_rcu, and update the item with sunrpc_cache_update.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKfhjubeh}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhK:hjubeh}(h]h ]h"]h$]h&]uh1j hjihhhhhNubj)}(hA cache needs to be registered using cache_register(). This includes it on a list of caches that will be regularly cleaned to discard old data. h]h)}(hA cache needs to be registered using cache_register(). This includes it on a list of caches that will be regularly cleaned to discard old data.h]hA cache needs to be registered using cache_register(). This includes it on a list of caches that will be regularly cleaned to discard old data.}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhj=ubah}(h]h ]h"]h$]h&]uh1j hjihhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhK-hjXhhubeh}(h]creating-a-cacheah ]h"]creating a cacheah$]h&]uh1hhhhhhhhK+ubh)}(hhh](h)}(h Using a cacheh]h Using a cache}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjchhhhhKmubh)}(hX;To find a value in a cache, call sunrpc_cache_lookup_rcu passing a pointer to the cache_head in a sample item with the 'key' fields filled in. This will be passed to ->match to identify the target entry. If no entry is found, a new entry will be create, added to the cache, and marked as not containing valid data.h]hX?To find a value in a cache, call sunrpc_cache_lookup_rcu passing a pointer to the cache_head in a sample item with the ‘key’ fields filled in. This will be passed to ->match to identify the target entry. If no entry is found, a new entry will be create, added to the cache, and marked as not containing valid data.}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohjchhubh)}(hX,The item returned is typically passed to cache_check which will check if the data is valid, and may initiate an up-call to get fresh data. cache_check will return -ENOENT in the entry is negative or if an up call is needed but not possible, -EAGAIN if an upcall is pending, or 0 if the data is valid;h]hX,The item returned is typically passed to cache_check which will check if the data is valid, and may initiate an up-call to get fresh data. cache_check will return -ENOENT in the entry is negative or if an up call is needed but not possible, -EAGAIN if an upcall is pending, or 0 if the data is valid;}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhjchhubh)}(hXcache_check can be passed a "struct cache_req\*". This structure is typically embedded in the actual request and can be used to create a deferred copy of the request (struct cache_deferred_req). This is done when the found cache item is not uptodate, but the is reason to believe that userspace might provide information soon. When the cache item does become valid, the deferred copy of the request will be revisited (->revisit). It is expected that this method will reschedule the request for processing.h]hXcache_check can be passed a “struct cache_req*”. This structure is typically embedded in the actual request and can be used to create a deferred copy of the request (struct cache_deferred_req). This is done when the found cache item is not uptodate, but the is reason to believe that userspace might provide information soon. When the cache item does become valid, the deferred copy of the request will be revisited (->revisit). It is expected that this method will reschedule the request for processing.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hjchhubh)}(hXThe value returned by sunrpc_cache_lookup_rcu can also be passed to sunrpc_cache_update to set the content for the item. A second item is passed which should hold the content. If the item found by _lookup has valid data, then it is discarded and a new item is created. This saves any user of an item from worrying about content changing while it is being inspected. If the item found by _lookup does not contain valid data, then the content is copied across and CACHE_VALID is set.h]hXThe value returned by sunrpc_cache_lookup_rcu can also be passed to sunrpc_cache_update to set the content for the item. A second item is passed which should hold the content. If the item found by _lookup has valid data, then it is discarded and a new item is created. This saves any user of an item from worrying about content changing while it is being inspected. If the item found by _lookup does not contain valid data, then the content is copied across and CACHE_VALID is set.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjchhubeh}(h] using-a-cacheah ]h"] using a cacheah$]h&]uh1hhhhhhhhKmubh)}(hhh](h)}(hPopulating a cacheh]hPopulating a cache}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hoEach cache has a name, and when the cache is registered, a directory with that name is created in /proc/net/rpch]hoEach cache has a name, and when the cache is registered, a directory with that name is created in /proc/net/rpc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThis directory contains a file called 'channel' which is a channel for communicating between kernel and user for populating the cache. This directory may later contain other files of interacting with the cache.h]hThis directory contains a file called ‘channel’ which is a channel for communicating between kernel and user for populating the cache. This directory may later contain other files of interacting with the cache.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe 'channel' works a bit like a datagram socket. Each 'write' is passed as a whole to the cache for parsing and interpretation. Each cache can treat the write requests differently, but it is expected that a message written will contain:h]hThe ‘channel’ works a bit like a datagram socket. Each ‘write’ is passed as a whole to the cache for parsing and interpretation. Each cache can treat the write requests differently, but it is expected that a message written will contain:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h&- a key - an expiry time - a content. h]j )}(hhh](j)}(ha keyh]h)}(hjh]ha key}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj)}(han expiry timeh]h)}(hjh]han expiry time}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hjubj)}(h a content. h]h)}(h a content.h]h a content.}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(hwith the intention that an item in the cache with the give key should be create or updated to have the given content, and the expiry time should be set on that item.h]hwith the intention that an item in the cache with the give key should be create or updated to have the given content, and the expiry time should be set on that item.}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hReading from a channel is a bit more interesting. When a cache lookup fails, or when it succeeds but finds an entry that may soon expire, a request is lodged for that cache item to be updated by user-space. These requests appear in the channel file.h]hReading from a channel is a bit more interesting. When a cache lookup fails, or when it succeeds but finds an entry that may soon expire, a request is lodged for that cache item to be updated by user-space. These requests appear in the channel file.}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hSuccessive reads will return successive requests. If there are no more requests to return, read will return EOF, but a select or poll for read will block waiting for another request to be added.h]hSuccessive reads will return successive requests. If there are no more requests to return, read will return EOF, but a select or poll for read will block waiting for another request to be added.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h'Thus a user-space helper is likely to::h]h&Thus a user-space helper is likely to:}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh literal_block)}(hQopen the channel. select for readable read a request write a response loop.h]hQopen the channel. select for readable read a request write a response loop.}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhjhhubh)}(hIf it dies and needs to be restarted, any requests that have not been answered will still appear in the file and will be read by the new instance of the helper.h]hIf it dies and needs to be restarted, any requests that have not been answered will still appear in the file and will be read by the new instance of the helper.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hEach cache should define a "cache_parse" method which takes a message written from user-space and processes it. It should return an error (which propagates back to the write syscall) or 0.h]hEach cache should define a “cache_parse” method which takes a message written from user-space and processes it. It should return an error (which propagates back to the write syscall) or 0.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hEach cache should also define a "cache_request" method which takes a cache item and encodes a request into the buffer provided.h]hEach cache should also define a “cache_request” method which takes a cache item and encodes a request into the buffer provided.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubhnote)}(hXrIf a cache has no active readers on the channel, and has had not active readers for more than 60 seconds, further requests will not be added to the channel but instead all lookups that do not find a valid entry will fail. This is partly for backward compatibility: The previous nfs exports table was deemed to be authoritative and a failed lookup meant a definite 'no'.h]h)}(hXrIf a cache has no active readers on the channel, and has had not active readers for more than 60 seconds, further requests will not be added to the channel but instead all lookups that do not find a valid entry will fail. This is partly for backward compatibility: The previous nfs exports table was deemed to be authoritative and a failed lookup meant a definite 'no'.h]hXvIf a cache has no active readers on the channel, and has had not active readers for more than 60 seconds, further requests will not be added to the channel but instead all lookups that do not find a valid entry will fail. This is partly for backward compatibility: The previous nfs exports table was deemed to be authoritative and a failed lookup meant a definite ‘no’.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]populating-a-cacheah ]h"]populating a cacheah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hrequest/response formath]hrequest/response format}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXWhile each cache is free to use its own format for requests and responses over channel, the following is recommended as appropriate and support routines are available to help: Each request or response record should be printable ASCII with precisely one newline character which should be at the end. Fields within the record should be separated by spaces, normally one. If spaces, newlines, or nul characters are needed in a field they much be quoted. two mechanisms are available:h]hXWhile each cache is free to use its own format for requests and responses over channel, the following is recommended as appropriate and support routines are available to help: Each request or response record should be printable ASCII with precisely one newline character which should be at the end. Fields within the record should be separated by spaces, normally one. If spaces, newlines, or nul characters are needed in a field they much be quoted. two mechanisms are available:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj )}(hhh](j)}(hIf a field begins '\x' then it must contain an even number of hex digits, and pairs of these digits provide the bytes in the field.h]h)}(hIf a field begins '\x' then it must contain an even number of hex digits, and pairs of these digits provide the bytes in the field.h]hIf a field begins ‘x’ then it must contain an even number of hex digits, and pairs of these digits provide the bytes in the field.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubj)}(hotherwise a \ in the field must be followed by 3 octal digits which give the code for a byte. Other characters are treated as them selves. At the very least, space, newline, nul, and '\' must be quoted in this way.h]h)}(hotherwise a \ in the field must be followed by 3 octal digits which give the code for a byte. Other characters are treated as them selves. At the very least, space, newline, nul, and '\' must be quoted in this way.h]hotherwise a in the field must be followed by 3 octal digits which give the code for a byte. Other characters are treated as them selves. At the very least, space, newline, nul, and ‘' must be quoted in this way.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubeh}(h]request-response-formatah ]h"]request/response formatah$]h&]uh1hhhhhhhhKubeh}(h]cachesah ]h"]cachesah$]h&]uh1hhhhhhhhK ubeh}(h] rpc-cacheah ]h"] rpc cacheah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjqerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jKjHjCj@j`j]jjjjj;j8u nametypes}(jKjCj`jjj;uh}(jHhj@hj]jXjjcjjj8ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.