NFS lookup cache
An NFS lookup cache retains directory-name resolution results, including found and missing entries, subject to revalidation.
Linux lookupcache=positive revalidates negative entries; lookupcache=none revalidates both positive and negative entries before use. These controls do not disable file-data caching. More validation can increase server work. [1]
The Linux client drops all cached LOOKUP results for a directory when it sees that directory's mtime change. Because the mtime is itself a cached attribute, detection waits for the directory attribute cache, which by default lasts between 30 and 60 seconds. Negative results have been cached since kernel 2.6.28, and earlier clients tracked only positive results. [1]
NFSv4 bounds how long a name cache entry may be used without checking the directory. Directory-changing operations return change_info4, a flag plus 64-bit change values from before and after the operation. A client may update its name cache only when the server reports them atomically and the before value matches its cached one, otherwise it purges that directory's cache. [2]
Relations
- related
- NFS change attribute, NFS, NFS attribute cache, Close-to-open consistency, NFS READDIR cookie
Advantages
- Applications that do not share directories with other clients avoid repeated LOOKUP round trips. [1]
Limitations
- Name visibility is not evidence of durable file contents or a multi-file transaction. [2, 3]
- Applications on several clients that must notice file creation or removal quickly can see stale entries until the next revalidation. [1]
Citations
- nfs-utils nfs(5), Debian trixie: lookupcache option.
- RFC 7530, section 10.8: Name Caching.
- NFS stable writes: what COMMIT, flush and FUA actually promise
Sources & caveats
- nfs-client is the nfs(5) manual page from nfs-utils in Debian trixie, read on the access date in the lookupcache, acdirmin and acdirmax options and Directory entry caching.
- rfc7530 is RFC 7530 (NFSv4.0), read in section 10.8 and the change_info4 data type.
- 30 and 60 seconds and 2.6.28 come from nfs-client. 64-bit comes from rfc7530 (changeid4 is uint64_t).