0% found this document useful (0 votes)
2 views

Network File System (NFS)

NFS (Network File System) is a distributed file system protocol in Linux that allows users to share files and directories across a network as if they were local. It operates on a stateless model, meaning the server does not track client states, which simplifies recovery but can lead to consistency issues. Despite its limitations, NFS remains widely used due to its simplicity and effectiveness in enabling data sharing among multiple clients.

Uploaded by

MONALI DESHPANDE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Network File System (NFS)

NFS (Network File System) is a distributed file system protocol in Linux that allows users to share files and directories across a network as if they were local. It operates on a stateless model, meaning the server does not track client states, which simplifies recovery but can lead to consistency issues. Despite its limitations, NFS remains widely used due to its simplicity and effectiveness in enabling data sharing among multiple clients.

Uploaded by

MONALI DESHPANDE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Network File System

(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.

• Provides centralized administration.

• Provides security, i.e. one must only secure the servers to


secure data.
NFS Advanrages
• NFS Is Relevant
• Very successful, still widely used today
• Early result; much subsequent research in networked
filesystems “fixing shortcomings of NFS”
• NFS is a great substrate for cool distributed systems
research projects!
• NFS Is Relevant
• Original paper from 1985
• Very successful, still widely used today
• Early result; much subsequent research in networked
filesystems “fixing shortcomings of NFS”
• NFS is a great substrate for cool distributed systems
research projects!
• Even a simple client/server architecture involves more components than
the physical file systems discussed previously in OS. The architecture
consists of a client-side file system and a server-side file system. A
client application issues a system call (e.g. read(), write(), open(),
close() etc.) to access files on the client-side file system, which in turn
retrieves files from the server. It is interesting to note that to a client
application, the process seems no different than requesting data from a
physical disk, since there is no special API required to do so. This
phenomenon is known as transparency in terms of file access. It is the
client-side file system that executes commands to service these system
calls. For instance, assume that a client application issues the read()
system call. The client-side file system then messages the server-side file
system to read a block from the server’s disk and return the data back to
the client. Finally, it buffers this data into the read() buffer and completes
the system call.
• The server-side file system is also simply called the file server. Sun’s
Network File System: The earliest successful distributed system
could be attributed to Sun Microsystems, which developed the Network
File System (NFS). NFSv2 was the standard protocol followed for many
years, designed with the goal of simple and fast server crash recovery.
This goal is of utmost importance in multi-client and single-server
based network architectures because a single instant of server crash
means that all clients are unserviced. The entire system goes down.
Stateful protocols make things complicated when it comes to
crashes. Consider a client A trying to access some data from the server.
However, just after the first read, the server crashed. Now, when the
server is up and running, client A issues the second read request.
However, the server does not know which file the client is referring to,
since all that information was temporary and lost during the crash
• Stateless protocols come to our rescue. Such
protocols are designed so as to not store any state
information in the server. The server is unaware of what
the clients are doing — what blocks they are caching,
which files are opened by them and where their current
file pointers are. The server simply delivers all the
information that is required to service a client request. If
a server crash happens, the client would simply have to
retry the request. Because of their simplicity, NFS
implements a stateless protocol.
• File Handles: NFS uses file handles to uniquely identify a
file or a directory that the current operation is being
performed upon. This consists of the following components:
• Volume Identifier – An NFS server may have multiple file
systems or partitions. The volume identifier tells the server
which file system is being referred to.

• Inode Number – This number identifies the file within the


partition.

• Generation Number – This number is used while reusing an


inode number
• File Attributes: “File attributes” is a term commonly
used in NFS terminology. This is a collective term for the
tracked metadata of a file, including file creation time,
last modified, size, ownership permissions etc. This can
be accessed by calling stat() on the file.

• NFSv2 Protocol:
Why Build NFS?

• Why not just store your files on local disk?


• Sharing data: many users reading/writing same files
(e.g., code repository), but running on separate
machines
• Manageability: ease of backing up one server
• Disks may be expensive (true when NFS built; no
longer true)
• Displays may be expensive (true when NFS built; no
longer true)
Goals for NFS
• Work with existing, unmodified apps: – Same semantics
as local UNIX filesystem
• Easily deployed – Easy to add to existing UNIX systems
• Compatible with non-UNIX OSes – Wire protocol cannot
be too UNIX-specific
• Efficient “enough” – Needn’t offer same performance
as local UNIX filesystem
Goals for NFS
• Easily deployed – Easy to add to existing UNIX systems
• Compatible with non-UNIX OSes – Wire protocol
cannot be too UNIX-specific
NFS Architecture
NFS Architecture
NFS Architecture
How it Works ?

• NFS works on the client-server model, where one or


more NFS servers host the shared resources, and NFS
clients can access and mount these resources to access
the data. The working of NFS is through a combination
of protocols and services working together.
Protocols

• The RPC (Remote Procedure Call) protocol is used for


communication between programs running on different
machines and allows the client to perform operations
like reading, writing, and accessing files.

• The NFS protocol specifies the format of the data being


exchanged between the client and the server.
• NFS Server: The NFS server is used for hosting the
shared files and directories. There are multiple
configurations to be made in the server which allows
the directories to the used by clients on request from
clients.
• NFS Client: The NFS client is a machine
that accesses the shared resources from the NFS server.
When a client needs to access a file or directory on the
NFS server, it sends an RPC request to the server, which
then processes the request and returns the appropriate
data.
• The process of sharing files and directories with NFS
involves the following steps of exporting and mounting:
• On the NFS server, the configurations for the directories
to be shared along with client-specific permissions are
made.
• On the NFS client, the shared directories are mounted
onto local mount points.
• After mounting, the shared directories become an
integral part of the client's file system, and users can
access them just like any local file.
• Caching To optimize performance, NFS clients employ
caching mechanisms. When a file is read from the NFS
server, the client caches the data locally. Subsequent
read requests for the same file can be satisfied from the
cache, reducing the need for network communication.
• Required Services:
• Let's explore these services that are used by the NFS for sharing and accessing the
files in Linux systems:
• The NFS service is responsible for exporting directories and files to be shared with
NFS clients. It manages the access control and authentication mechanisms, allowing
clients to access shared resources securely over the network.
• The nfslock service provides file locking functionality for NFS clients. File locking is
crucial to ensure that multiple clients can work with shared files simultaneously
without data corruption or conflicts.
• The RPCbind service translates RPC program numbers into universal addresses, for
communication between NFS clients and servers. It resolving the port number for
specific RPC services for proper communication between clients and servers.
• The rpc.nfsd process is a kernel module that handles the actual NFS requests on the
server side. It listens for incoming NFS requests from clients, processes them, and
manages the file operations on shared directories.
• Several RPC processes are used by NFS to have smooth communication between NFS
clients and servers. These processes are:
• The rpc.mountd process is responsible for handling mount requests from NFS clients.
When an NFS client requests to mount a shared directory from the NFS server, the rpc.
mountd process is responsible for processing this request.
• The lockd process manages file locking for NFS clients to maintain data integrity in a
multi-client NFS environment.
• The rpc. statd process, also known as the NFS status monitor, is responsible for
monitoring the status of NFS clients.
• The rpc.rquotad process manages disk quotas for NFS clients. Quotas limit the amount of
disk space a user or group can consume on the NFS server.
• The rpc.idmapd process is responsible for mapping user and group IDs between the NFS
client and server.
• RPC program numbers are unique identifiers assigned to remote services and are used
for communication between different processes. Universal addresses are used by RPC
clients to identify the network location of a specific RPC service or program.
Limitations of NFS
• Security: what if untrusted users can be root on client
machines?
• Scalability: how many clients can share one server? –
Writes always go through to server – Some writes are to
“private,” unshared files that are deleted soon after
creation
• Can you run NFS on a large, complex network?
• Despite its limitations, NFS a huge success: Simple
enough to build for many OSes Correct enough and
performs well enough to be practically useful in
deployment
All About NFS
• NFS allows access to file systems on other machines
• ◆ Implementation uses RPC to access file server  RPC enables
transparent distribution of applications
• ◆ Also used on same node between applications  RPC islanguage
support for distributed programming
• ◆ Examples include DCOM, CORBA, Java RMI, etc.
• ◆ What else have we seen use language support?  Stub compiler
automatically generates client/server code from the IDL server
descriptions
• ◆ These stubs do the marshalling/unmarshalling, message
sending/receiving/replying
• ◆ Programmer just implements functions as before

You might also like