Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984. NFS allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. NFS uses a client/server model, in which a server makes directories on its storage accessible to one or more clients; and clients mount the directories to access the files in them. NFS uses remote procedure calls (RPCs) to route requests between clients and server, and TCP/IP as a transport protocol. NFS is hierarchical in nature, where directories (a special type of file) can contain further directories and files.
NFS (unlike Server Message Block, or SMB, which is a proprietary protocol) is an industry standard, defined by the IETF, and has several versions defined in different Requests for Comments (RFCs). Sun Microsystems used version 1 only for in-house experimental purposes. When the NFS protocol was released for general use, it was called NFS version 2. NFS version 2 supports both UDP and TCP. NFS version 2 with UDP as its transport protocol provides a stateless network connection between the server and the client. In the stateless condition, a server need not maintain any protocol state information about any of its clients in order to function correctly. Stateless servers have a distinct advantage over stateful servers in the event of a failure. With stateless servers, a client only needs to retry a request until the server responds; it does not even need to know that the server has crashed or that the network temporarily went down. The client of a stateful server, on the other hand, needs to either detect a server failure and rebuild the server’s state when it comes back up, or cause client operations to fail. NFS version 3 supports both UDP and TCP. NFS version 3 introduces support for larger files and file systems such as 64-bit file sizes and offsets, support for asynchronous writes on the server to improve write performance, and additional file attributes in many replies to avoid the need to refetch them. NFS version 3 provides backward compatibility with the existing installed base of NFS version 2 protocol implementations.
NFS version 4 uses the TCP protocol to communicate with the server. NFS version 4 offers advanced file caching for performance improvements and strong authentication, and it introduces a stateful protocol where client usage information of an object is maintained by the server. NFS version 4.1 provides protocol support to take advantage of clustered server deployments, including the ability to provide scalable parallel access to files distributed among multiple servers (pNFS extension). Version 4.1 also includes a session trunking mechanism (also known as NFS Multipathing) and is available in some enterprise solutions such as VMware ESXi. When the trunking is available, you can use multiple IP addresses to access a single NFS volume. NFS version 4.2 introduces new features including server-side clone and copy, application I/O advise, sparse files, space reservation, application data block (ADB), labeled NFS with sec_label that accommodates any MAC security system, and two new operations for pNFS (LAYOUTERROR and LAYOUTSTATS). A traditional file copy of a remotely accessed file, whether from one server to another or between locations in the same server, results in the data being put on the network twice—from the source to the client and then from the client to the destination. NFS version 4.2 allows unnecessary traffic to be eliminated, and a file can be copied between servers without copying it to the client first, as shown in Figure 10-1. Applications and clients want to advise the server to expected I/O behavior. Using IO_ADVISE to communicate future I/O behavior—such as whether a file will be accessed sequentially or randomly and whether a file will be accessed in the near future—allows servers to optimize future I/O requests for a file by, for example, prefetching or evicting data. Sparse files are those that have unallocated or uninitialized data blocks as holes in the file. Such holes are typically transferred as zeros when read from the file. Sparse files are very efficient because they do not store the zeros on disk; instead, they hold enough data describing how many zeros need to be generated while reading the file. To read more about the other features on NFS version 4.2, refer to RFC 7862 (https://tools.ietf.org/html/rfc7862).
Figure 10-1 NFS v4.2 Server-to-Server Copy
The advantage of NFSv4 over its predecessors is that only one IP port, 2049, is used to run the service, which simplifies using the protocol across firewalls. NFS is supported in a heterogenous environment: Windows, Linux, and even VMware clients support NFS shares (exports) of directories and files.