How NFS object addressing works
mainIn this NFSv3 implementation, every filesystem object (directory, file, or symlink) is addressed in two ways:
fileid3: A 64-bit integer equivalent to an inode number.nfs_fh3: A variable-length opaque object (up to 64 bytes).
The Lifecycle of an Access:
- Mounting: The client uses the MOUNT protocol to request a handle for the root directory (e.g.,
MNT("/")). - Traversal: To access a nested file (e.g.,
dir/a.txt), the client must first have the handle fordir/. It then callsLOOKUP(directory_handle, "a.txt")to receive thenfs_fh3for the target file. - Access: Once the client has the
nfs_fh3, it uses that handle for subsequent operations.
Why use nfs_fh3 instead of just fileid3?
- Extended Metadata: It allows the server to cache more information than a 64-bit ID allows (e.g., volume identifiers).
- Cache Invalidation: The handle can include a token unique to the server's current session. If the server restarts, old handles become invalid, signaling the client to clear its caches.