Question 10 of 15 · CIE-2 QB · 7 marks
Open in ChatGPTExplain the architecture and working of NFS. Discuss its file access and caching mechanisms.
Introduction
NFS (Network File System) lets a client mount a directory exported by a server and then use ordinary file calls on it. It is the standard shared file system of Unix, and its design is deliberately simple: a stateless server and a client that caches aggressively.
Architecture
- Server: exports a directory, and identifies each file by a file handle (file system id, inode, generation number) that survives a restart.
- Client: mounts the export at a local path through the VFS layer, so
read()on a mounted path becomes an NFS call. - Protocol: remote procedure calls:
LOOKUP,READ,WRITE,GETATTR,SETATTR,READDIR: each carrying the handle and all needed arguments. - Statelessness: the server keeps no per-client state, so a crashed server can restart and continue; the client retries.

File access
- A
LOOKUPresolves a name to a handle; subsequent operations use the handle. - Reads and writes are done in blocks (commonly 4–64 KB) with a byte offset and a count, so large files are read incrementally.
- Close-to-open consistency: the client flushes dirty blocks on
close, and revalidates cached attributes onopen.
Caching
- The client caches file data, attributes and directory entries, each with a timestamp.
- A cached block is considered stale after a short interval; attribute caching makes repeated
statcalls local. - The kernel also does read-ahead and write-behind, batching NFS requests.
Diagram
Limitations
- Statelessness means every call repeats the handle, and locking needs a separate protocol (NLM).
- Cache revalidation by timeout gives weak consistency between clients.
- A single server is a single point of failure unless exported from a replicated or clustered file system.
Conclusion
NFS is a thin protocol over RPC with a stateless server and a trusting client cache. That is what makes it easy to implement, easy to recover, and only eventually consistent.