/* * Directory caching routines. They work as follows: * - a cache is maintained per VDIR nfsnode. * - for each offset cookie that is exported to userspace, and can * thus be thrown back at us as an offset to VOP_READDIR, store * information in the cache. * - cached are: * - cookie itself * - blocknumber (essentially just a search key in the buffer cache) * - entry number in block. * - offset cookie of block in which this entry is stored * - 32 bit cookie if NFSMNT_XLATECOOKIE is used. * - entries are looked up in a hash table * - also maintained is an LRU list of entries, used to determine * which ones to delete if the cache grows too large. * - if 32 <-> 64 translation mode is requested for a filesystem, * the cache also functions as a translation table * - in the translation case, invalidating the cache does not mean * flushing it, but just marking entries as invalid, except for * the <64bit cookie, 32bitcookie> pair which is still valid, to * still be able to use the cache as a translation table. * - 32 bit cookies are uniquely created by combining the hash table * entry value, and one generation count per hash table entry, * incremented each time an entry is appended to the chain. * - the cache is invalidated each time a direcory is modified * - sanity checks are also done; if an entry in a block turns * out not to have a matching cookie, the cache is invalidated * and a new block starting from the wanted offset is fetched from * the server. * - directory entries as read from the server are extended to contain * the 64bit and, optionally, the 32bit cookies, for sanity checking * the cache and exporting them to userspace through the cookie * argument to VOP_READDIR. */