Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: nfs: rpc-cache: convert to ReST

Convert rpc-cache.txt to ReST. Changes aim to improve presentation
but the content itself remains mostly the same.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Link: https://lore.kernel.org/r/20200129044917.566906-3-dwlsalmeida@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Daniel W. S. Almeida and committed by
Jonathan Corbet
f0bf8a98 34e75cf4

+76 -57
+1
Documentation/filesystems/nfs/index.rst
··· 7 7 :maxdepth: 1 8 8 9 9 pnfs 10 + rpc-cache
+75 -57
Documentation/filesystems/nfs/rpc-cache.txt Documentation/filesystems/nfs/rpc-cache.rst
··· 1 - This document gives a brief introduction to the caching 1 + ========= 2 + RPC Cache 3 + ========= 4 + 5 + This document gives a brief introduction to the caching 2 6 mechanisms in the sunrpc layer that is used, in particular, 3 7 for NFS authentication. 4 8 5 - CACHES 9 + Caches 6 10 ====== 11 + 7 12 The caching replaces the old exports table and allows for 8 13 a wide variety of values to be caches. 9 14 ··· 17 12 of common code for managing these caches. 18 13 19 14 Examples of caches that are likely to be needed are: 15 + 20 16 - mapping from IP address to client name 21 17 - mapping from client name and filesystem to export options 22 18 - mapping from UID to list of GIDs, to work around NFS's limitation ··· 27 21 - mapping from network identify to public key for crypto authentication. 28 22 29 23 The common code handles such things as: 24 + 30 25 - general cache lookup with correct locking 31 26 - supporting 'NEGATIVE' as well as positive entries 32 27 - allowing an EXPIRED time on cache items, and removing ··· 42 35 Creating a Cache 43 36 ---------------- 44 37 45 - 1/ A cache needs a datum to store. This is in the form of a 46 - structure definition that must contain a 47 - struct cache_head 38 + - A cache needs a datum to store. This is in the form of a 39 + structure definition that must contain a struct cache_head 48 40 as an element, usually the first. 49 41 It will also contain a key and some content. 50 42 Each cache element is reference counted and contains 51 43 expiry and update times for use in cache management. 52 - 2/ A cache needs a "cache_detail" structure that 44 + - A cache needs a "cache_detail" structure that 53 45 describes the cache. This stores the hash table, some 54 46 parameters for cache management, and some operations detailing how 55 47 to work with particular cache items. 56 - The operations requires are: 57 - struct cache_head *alloc(void) 58 - This simply allocates appropriate memory and returns 59 - a pointer to the cache_detail embedded within the 60 - structure 61 - void cache_put(struct kref *) 62 - This is called when the last reference to an item is 63 - dropped. The pointer passed is to the 'ref' field 64 - in the cache_head. cache_put should release any 65 - references create by 'cache_init' and, if CACHE_VALID 66 - is set, any references created by cache_update. 67 - It should then release the memory allocated by 68 - 'alloc'. 69 - int match(struct cache_head *orig, struct cache_head *new) 70 - test if the keys in the two structures match. Return 71 - 1 if they do, 0 if they don't. 72 - void init(struct cache_head *orig, struct cache_head *new) 73 - Set the 'key' fields in 'new' from 'orig'. This may 74 - include taking references to shared objects. 75 - void update(struct cache_head *orig, struct cache_head *new) 76 - Set the 'content' fileds in 'new' from 'orig'. 77 - int cache_show(struct seq_file *m, struct cache_detail *cd, 78 - struct cache_head *h) 79 - Optional. Used to provide a /proc file that lists the 80 - contents of a cache. This should show one item, 81 - usually on just one line. 82 - int cache_request(struct cache_detail *cd, struct cache_head *h, 83 - char **bpp, int *blen) 84 - Format a request to be send to user-space for an item 85 - to be instantiated. *bpp is a buffer of size *blen. 86 - bpp should be moved forward over the encoded message, 87 - and *blen should be reduced to show how much free 88 - space remains. Return 0 on success or <0 if not 89 - enough room or other problem. 90 - int cache_parse(struct cache_detail *cd, char *buf, int len) 91 - A message from user space has arrived to fill out a 92 - cache entry. It is in 'buf' of length 'len'. 93 - cache_parse should parse this, find the item in the 94 - cache with sunrpc_cache_lookup_rcu, and update the item 95 - with sunrpc_cache_update. 48 + 49 + The operations are: 50 + 51 + struct cache_head \*alloc(void) 52 + This simply allocates appropriate memory and returns 53 + a pointer to the cache_detail embedded within the 54 + structure 55 + 56 + void cache_put(struct kref \*) 57 + This is called when the last reference to an item is 58 + dropped. The pointer passed is to the 'ref' field 59 + in the cache_head. cache_put should release any 60 + references create by 'cache_init' and, if CACHE_VALID 61 + is set, any references created by cache_update. 62 + It should then release the memory allocated by 63 + 'alloc'. 64 + 65 + int match(struct cache_head \*orig, struct cache_head \*new) 66 + test if the keys in the two structures match. Return 67 + 1 if they do, 0 if they don't. 68 + 69 + void init(struct cache_head \*orig, struct cache_head \*new) 70 + Set the 'key' fields in 'new' from 'orig'. This may 71 + include taking references to shared objects. 72 + 73 + void update(struct cache_head \*orig, struct cache_head \*new) 74 + Set the 'content' fileds in 'new' from 'orig'. 75 + 76 + int cache_show(struct seq_file \*m, struct cache_detail \*cd, struct cache_head \*h) 77 + Optional. Used to provide a /proc file that lists the 78 + contents of a cache. This should show one item, 79 + usually on just one line. 80 + 81 + int cache_request(struct cache_detail \*cd, struct cache_head \*h, char \*\*bpp, int \*blen) 82 + Format a request to be send to user-space for an item 83 + to be instantiated. \*bpp is a buffer of size \*blen. 84 + bpp should be moved forward over the encoded message, 85 + and \*blen should be reduced to show how much free 86 + space remains. Return 0 on success or <0 if not 87 + enough room or other problem. 88 + 89 + int cache_parse(struct cache_detail \*cd, char \*buf, int len) 90 + A message from user space has arrived to fill out a 91 + cache entry. It is in 'buf' of length 'len'. 92 + cache_parse should parse this, find the item in the 93 + cache with sunrpc_cache_lookup_rcu, and update the item 94 + with sunrpc_cache_update. 96 95 97 96 98 - 3/ A cache needs to be registered using cache_register(). This 97 + - A cache needs to be registered using cache_register(). This 99 98 includes it on a list of caches that will be regularly 100 99 cleaned to discard old data. 101 100 ··· 120 107 call is needed but not possible, -EAGAIN if an upcall is pending, 121 108 or 0 if the data is valid; 122 109 123 - cache_check can be passed a "struct cache_req *". This structure is 110 + cache_check can be passed a "struct cache_req\*". This structure is 124 111 typically embedded in the actual request and can be used to create a 125 112 deferred copy of the request (struct cache_deferred_req). This is 126 113 done when the found cache item is not uptodate, but the is reason to ··· 152 139 passed as a whole to the cache for parsing and interpretation. 153 140 Each cache can treat the write requests differently, but it is 154 141 expected that a message written will contain: 142 + 155 143 - a key 156 144 - an expiry time 157 145 - a content. 146 + 158 147 with the intention that an item in the cache with the give key 159 148 should be create or updated to have the given content, and the 160 149 expiry time should be set on that item. ··· 171 156 select or poll for read will block waiting for another request to be 172 157 added. 173 158 174 - Thus a user-space helper is likely to: 159 + Thus a user-space helper is likely to:: 160 + 175 161 open the channel. 176 162 select for readable 177 163 read a request ··· 191 175 takes a cache item and encodes a request into the buffer 192 176 provided. 193 177 194 - Note: If a cache has no active readers on the channel, and has had not 195 - active readers for more than 60 seconds, further requests will not be 196 - added to the channel but instead all lookups that do not find a valid 197 - entry will fail. This is partly for backward compatibility: The 198 - previous nfs exports table was deemed to be authoritative and a 199 - failed lookup meant a definite 'no'. 178 + .. note:: 179 + If a cache has no active readers on the channel, and has had not 180 + active readers for more than 60 seconds, further requests will not be 181 + added to the channel but instead all lookups that do not find a valid 182 + entry will fail. This is partly for backward compatibility: The 183 + previous nfs exports table was deemed to be authoritative and a 184 + failed lookup meant a definite 'no'. 200 185 201 186 request/response format 202 187 ----------------------- ··· 210 193 Fields within the record should be separated by spaces, normally one. 211 194 If spaces, newlines, or nul characters are needed in a field they 212 195 much be quoted. two mechanisms are available: 213 - 1/ If a field begins '\x' then it must contain an even number of 196 + 197 + - If a field begins '\x' then it must contain an even number of 214 198 hex digits, and pairs of these digits provide the bytes in the 215 199 field. 216 - 2/ otherwise a \ in the field must be followed by 3 octal digits 200 + - otherwise a \ in the field must be followed by 3 octal digits 217 201 which give the code for a byte. Other characters are treated 218 202 as them selves. At the very least, space, newline, nul, and 219 203 '\' must be quoted in this way.