The Sun Network (NFS) • An implementation and a specification of a software system for accessing remote files across LANs .

NFS • The implementation is part of the Solaris and SunOS operating systems running on Sun workstations using an unreliable datagram protocol (UDP/IP protocol and Ethernet), which has become widely accepted throughout the computer industry, known as NFS.

• The mechanism allows a computer to run a server that makes some or all of its files available for remote access, and allow applications on other computers to access those files.

Remote File Access Vs Transfer Basics • Interconnected workstations viewed as a set of • When an application accesses a file that resides on a independent machines with independent file systems, which allows sharing among these file systems in a remote machine, the program’s transparent manner. invokes client software that contacts a file server on the remote machine and performs the requested operations • Subject to access-rights, potentially any file system (or on the file. directory within a file system), can be mounted remotely on top of any local directory. • Unlike a file transfer, the application’s system does not • A remote directory is mounted over a local file system retrieve or store an entire file at once; instead, it requests director. The mounted directory looks like an integral transfer of one small of data at a time. sub tree of the local file system, replacing the sub tree descending from the local directory.

File Access Among Basics (Cont) Heterogeneous Computers • The NFS specification distinguishes between the services provided by a mount mechanism and the actual • NFS is designed to operate in a heterogeneous remote-file-access services. environment of different machines, operating systems, and network architectures; the NFS specifications • Specification of the remote directory for the mount independent of these media. operation is nontransparent; the host name of the remote directory has to be provided. • Because a remote file access service connects two machines, it must handle differences in the way the • Files in the remote directory can then be accessed in a client and server systems name files, denote paths transparent manner. through directories, and store information about files.

• This independence is achieved through the use of RPC

primitives.

NFS and File Semantics NFS Mount Protocol • In UNIX, the mount mechanism construct a single, • The NFS designers adopted UNIX file system semantics unified naming hierarchy from individual file systems on when defining the meaning of individual operations. multiple disks.

• It honors the same open-read-write-close paradigm as UNIX, and offers most of the same services. • UNIX implementation of NFS client code use an extended version of the mount mechanism to integrate remote file systems into the naming hierarchy along with • Like UNIX, NFS assumes a hierarchical naming system. It considers the file hierarchy to be composed of local file systems. directories and files. • The chief advantage of using the mount mechanism is consistency : all file names have the same form.

• An application program cannot tell whether a file is local or remote from the name syntax alone.

NFS Mount Protocol NFS Protocol • Mount operation includes name of remote directory to • Provides a set of remote procedure calls for be mounted and name of server machine storing it remote file operations. The procedures support – Mount request is mapped to corresponding RPC and the following operations: forwarded to mount server running on server machine. – Export list – specifies local file systems that server exports – searching for a file within a directory for mounting, along with names of machines that are – reading a set of directory entries permitted to mount them. • Following a mount request that conforms to its export – manipulating links and directories list, the server returns a file handle—a key for further – accessing file attributes accesses. – reading and writing files • File handle – a file-system identifier, and an • Modified data must be committed to the server’s number to identify the mounted directory within the exported file system. disk before results are returned to the client (lose advantages of caching) • The mount operation changes only the user’s view and does not affect the server side. • The NFS protocol does not provide concurrency- control mechanisms

File Positioning with A Stateless Server Stateless Servers • Because NFS uses a stateless server design, the client stores all file position information and each request sent to the server • The NFS design stores state information at the client must specify the file position to use. site, allowing servers to remain stateless.

• Because the server is stateless, disruption in service will • In UNIX implementation, NFS uses the local file table to store not affect client operation. the position for a remote file just as UNIX uses it to store position in a local file. • A client will be able to continue file access after a stateless server crashes and reboots; the application • If the client calls lseek , the system records the new file position program, which runs on the client system, can remain in the table without sending a message to the server. unaware of the server reboot.

• Because a stateless server does not need to allocate • Any subsequent access operation extracts the file position from resources for each client, a stateless design can scale to the table and sends it to the server along with the access

handle more clients than a stateful design. request. ¡ Three Major Layers of NFS Reading a Directory Statelessly Architecture • Because directories can be arbitrarily large and communication • UNIX file-system interface (based on the open, read, networks impose a fixed limit on the size of a single message, write , and close calls, and file descriptors ) reading the contents of a directory may require multiple requests. • (VFS) layer – distinguishes local files from remote ones, and local files are further • Because NFS servers are stateless, the server cannot keep a distinguished according to their file-system types record of each client’s position in the directory. – The VFS activates file-system-specific operations to handle local requests according to their file-system types • To overcome this limitation, NFS server returns a position – Calls the NFS protocol procedures for remote requests identifier when it answers a request for an entry from a directory. • NFS service layer – bottom layer of the architecture – Implements the NFS protocol

Schematic View of NFS NFS Path-Name Translation Architecture • The path name syntax used by the remote file system may differ from that of the client machine;

• To keep applications on client machines independent of file locations and server computer systems, NFS requires that only clients interpret full path names.

• A client traces a path through the server’s hierarchy by sending the server one component at a time and receiving information about the file or directory it names.

NFS Path-Name Translation Summary • For example, look up path name /a/b/c on a • To allow many clients to access a server and to keep the server, it begins by obtaining information about servers isolated from client crashes, NFS uses stateless the server’s root directory, then look up name a in servers. that directory, then look up name b in that directory a, then look up name c in b . • To accommodate heterogeneity, NFS requires the client to parse path names and look up each component individually and • To make lookup faster, a directory name lookup the server returns a handle. cache on the client’s side holds the vnodes for remote directory names. • NFS adopted the open-read-write-close paradigm used in

UNIX, along with basic file types and file protection modes. ¢