From Protocol to Distributed File System
In this lesson, we see how NFSv2's protocol functions in a distributed file system.
We'll cover the following
Hopefully, you are now getting some sense of how this protocol is turned into a file system across the client-side file system and the file server. The client-side file system tracks open files and generally translates application requests into the relevant set of protocol messages. The server simply responds to protocol messages, each of which contains all information needed to complete the request.
Reading A File: Client-side And File Server Actions
For example, let us consider a simple application that reads a file. In the diagram below, we show what system calls the application makes, and what the client-side file system and file server do in responding to such calls.
A few comments about the figure. First, notice how the client tracks all relevant state for the file access, including the mapping of the integer file descriptor to an NFS file handle as well as the current file pointer. This enables the client to turn each read request (which you may have noticed do not specify the offset to read from explicitly) into a properly-formatted read protocol message which tells the server exactly which bytes from the file to read. Upon a successful read, the client updates the current file position; subsequent reads are issued with the same file handle but a different offset.
Second, you may notice where server interactions occur. When the file is opened for the first time, the client-side file system sends a LOOKUP
request message. Indeed, if a long pathname must be traversed (e.g., /home/remzi/foo.txt
), the client would send three LOOKUPs: one to look up home in the directory /
, one to look up remzi
in home
, and finally, one to look up foo.txt
in remzi
.
Third, you may notice how each server request has all the information needed to complete the request in its entirety. This design point is critical to be able to gracefully recover from server failure, as we will discuss in more detail in the next lesson. It ensures that the server does not need a state to be able to respond to the request.
Get hands-on with 1400+ tech skills courses.