Network File System (NFS)
Network File System (NFS)
(NFS)
Distributed file System
NFS (Network File System)
• NFS (Network File System) in Linux is a distributed file
system protocol that is used for sharing of files and
directories across a network. It enables users to access
files and directories on remote systems as if they were
stored locally on their machines.
• The NFS protocol defines a set of operations that a
server must support
◆ Reading and writing files
◆ Accessing file attributes
◆ Searching for a file within a directory
◆ Reading a set of directory links
◆ Manipulating links and directories
• These operations are implemented as RPCs
◆ Usually by daemon processes (e.g., nfsd)
◆ A local operation is transformed into an RPC to a server
◆ Server performs operation on its own file system and
returns
Statelessness
NFS is stateless
• Note that NFS has no open or close operations
◆ An NFS server does not keep track of which clients have mounted
its file systems or are accessing its files
◆ Each RPC has to specify all information in a request » Operation, FS
handle, file id, offset in file, sequence #
◆ Robust No reconciliation needs to be done on a server crash/reboot
◆ Clients detect server reboot, continue to issue requests Writes
must be synchronous to disk, though
◆ Clients assume that a write is persistent on return ◆ Servers
cannot cache writes
Consistency
• Since NFS is stateless, consistency is tough
• ◆ NFS can be (mostly) consistent, but limits
performance
• ◆ NFS assumes that if you want consistency,
applications will use higher-level mechanisms to
guarantee it Writes are supposed to be atomic
• ◆ But performed in multiple RPCs (larger than a
network packet) ◆ Simultaneous writes from clients can
interleave RPCs (bad) Server caching
• ◆ Can cache reads, but we saw that it cannot cache
writes
Consistency
• Client caching can lead to consistency problems
◆ Caching a write on client A will not be seen by other clients
◆ Cached writes by clients A and B are unordered at server
◆ Since sharing is rare, though, NFS clients usually do cache NFS
statelessness is both its key to success and its Achilles’ heel
◆ NFS is straightforward to implement and reason about
◆ But limitations on caching can severely limit performance »
Dozens of network file system designs and implementations that
perform much better than NFS
◆ But note that it is still the most widely used remote file system
protocol and implementation
NFS
• The advent of distributed computing was marked by the
introduction of distributed file systems. Such systems involved
multiple client machines and one or a few servers. The server
stores data on its disks and the clients may request data
through some protocol messages.
• Advantages of a distributed file system:
• Allows easy sharing of data among clients.
• NFSv2 Protocol:
Why Build NFS?