CLIENT ASERVERCACHE/nfs/amilk1fd = open("/nfs/a", O_RDONLY);2read(fd, buf, 4);3pread(fd, buf, 4, 0); // 1 s4pread(fd, buf, 4, 0); // 5 sBLOOKUPREADGETATTRWRITEfhmilkeggsmilkeggsv1
Left: client A (NFS client, cache, program) · right: the NFS server and its diskMiddle: the network, with cables to A, the server and client BEnvelopes: requests (LOOKUP, READ, GETATTR, WRITE) · discs: replies (handle, data, attributes)Client A (its kernel's NFS client and its cache) and A's program on the left, the NFS server and its disk on the right, a network switch between them and client B in front. open() sends LOOKUP and gets a file handle; a READ lost in a server crash is simply sent again; B's WRITE changes the disk; A's cache gives stale milk until GETATTR shows the change and A reads eggs. Times are Linux defaults: cached file attributes are trusted for at least 3 seconds (acregmin) and at most 60 (acregmax), and over TCP a request waits 60 seconds before a retry. Opening the file again would have asked the server at once (close-to-open).

A remote file

  1. Your program opens /nfs/a, but the file lives on a server's disk across the network. The kernel's NFS client turns each file call into a request message. The server answers each request and then forgets it.

Crashes and retries

Caches

What happens

;; step 1/11 · remote
client A                       server
  program   open, read, ...      NFS server
  kernel    NFS client  ---->    disk: /nfs/a = milk
            (a file system
             that talks)

/nfs is a mount: the server's exported directory
appears inside the client's own directory tree.

The lesson follows NFS versions 2 and 3, the classic stateless design described in OSTEP. NFS version 4 adds state on the server (opens and locks), but it keeps the file handle, the client cache and the attribute checks. Times are Linux defaults: cached file attributes are trusted for at least 3 seconds (acregmin) and at most 60 (acregmax), and over TCP a request waits 60 seconds before a retry. Opening the file again would have asked the server at once (close-to-open).