GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.kernel.org — RPC Cache — The Linux Kernel documentation RPC Cache¶This document gives a brief introduction to the caching mechanisms in the sunrpc layer that is used, in particular, for NFS authentication. Caches¶The caching replaces the old exports table and allows for a wide variety of values to be caches. There 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. Examples of caches that are likely to be needed are:
The common code handles such things as:
Creating a Cache¶
Using a cache¶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. 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; cache_check can be passed a “ The 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. Populating a cache¶Each cache has a name, and when the cache is registered, a directory with that name is created in /proc/net/rpc This 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. The ‘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:
with 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. Reading 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. Successive 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. Thus a user-space helper is likely to: open the channel. select for readable read a request write a response loop. If 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. Each 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. Each cache should also define a “cache_request” method which takes a cache item and encodes a request into the buffer provided. Note If 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’. request/response format¶While 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:
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |