The Sun Network File System (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. Basics Remote File Access Vs Transfer • Interconnected workstations viewed as a set of independent machines with independent file systems, • When an application accesses a file that resides on a which allows sharing among these file systems in a remote machine, the program’s operating system 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 block 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 independent of these media. • Specification of the remote directory for the mount 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 client and server systems name files, denote paths • Files in the remote directory can then be accessed in a through directories, and store information about files. transparent manner. • This independence is achieved through the use of RPC primitives. �
NFS and UNIX 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 implementation of NFS client code use an UNIX, and offers most of the same services. 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. local file systems. It considers the file hierarchy to be composed of 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 Protocol NFS Mount 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. – searching for a file within a directory – Export list – specifies local file systems that server exports for mounting, along with names of machines that are – reading a set of directory entries permitted to mount them. – manipulating links and directories • Following a mount request that conforms to its export – accessing file attributes list, the server returns a file handle—a key for further accesses. – reading and writing files • File handle – a file-system identifier, and an inode • Modified data must be committed to the server’s number to identify the mounted directory within the disk before results are returned to the client (lose exported file system. advantages of caching) • The mount operation changes only the user’s view • The NFS protocol does not provide concurrency- and does not affect the server side. 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. • In UNIX implementation, NFS uses the local file table to store • Because the server is stateless, disruption in service will the position for a remote file just as UNIX uses it to store not affect client operation. position in a local file. • A client will be able to continue file access after a • If the client calls lseek , the system records the new file position stateless server crashes and reboots; the application program, which runs on the client system, can remain in the table without sending a message to the server. unaware of the server reboot. • Any subsequent access operation extracts the file position from • Because a stateless server does not need to allocate the table and sends it to the server along with the access resources for each client, a stateless design can scale to request. handle more clients than a stateful design. ✁
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. • Virtual File System (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 – Calls the NFS protocol procedures for remote requests • To overcome this limitation, NFS server returns a position identifier when it answers a request for an entry from a • NFS service layer – bottom layer of the architecture directory. – 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. Summary NFS Path-Name Translation • For example, look up path name /a/b/c on a • To allow many clients to access a server and to keep the servers isolated from client crashes, NFS uses stateless server, it begins by obtaining information about 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 the server returns a handle. • To make lookup faster, a directory name lookup 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. ✂
Recommend
More recommend