Client-side caching in NFS reduces the number of RPC requests sent to the server.
The NFS client can cache data, which can be read out of local memory instead of
from a remote disk. The caching scheme available for use depends on the file
system being accessed. Some caching schemes are prohibited because they
cannot guarantee the integrity and consistency of data that multiple clients
simultaneously change and update. The standard NFS cache policies ensure that
performance is acceptable while also preventing the introduction of state into the
client/server communication relationship.
There are two types of client caches: the directory and file attribute cache and
the data cache.
Directory and File Attribute Cache
Not all file system operations use the data in files and directories. Many operations
get or set the attributes of the file or directory, such as its length, owner,and
modification time. Because these attribute-only operations are frequent and do not
affect the data in a file or directory,they are prime candidates for using cached
information.
The client-side file and directory cache will store file attributes. The system does
this so that every operation that gets or sets attributes does not have to go through
the connection to the NFS server. When the system reads a file’s attributes, they
remain valid on the client for some minimum period of time, typically 30 seconds.
Youcan set this time period by using the acregmin option on the mount command.
If the client changes the file, he updates its attributes. This makes changes to the
local copy of the attributes and extends the cache validity period another minimum
time period. The attributes of a file remain static for some maximum period, typically
sixty seconds. Additionally,the system deletes file attributes from the cache, and
writes changed file attributes back to the server. Youcan set this time period with
the acregmax option on the mount command. Toforce a refresh of remote attributes
when opening a file, use the nocto option on the mount command. Specifying the
noac option suppresses all the local caching of attributes, negating the acregmin,
acregmax,acdirmin, and the acdirmax options on the mount command.
The same mechanism is used for directory attributes, although they are given a
longer minimum life-span. The minimum and maximum time period for directory
attribute flushing from the cache is set by the acdirmin and acdirmax options on the
mount command.
Attribute caching allows a client to make multiple changes to a file or directory
without having to constantly get and set attributes on the server. Intermediate
attributes are cached, and the sum total of all updates is later written to the server
when the maximum attribute cache period expires. Frequently accessed files and
directories have their attributes cached locally on the client so that some NFS
requests can be performed without having to make an RPC call. By preventing this
type of client/server interaction, caching attributes improves the performance of
NFS.
For more information on the ADDMFS and MOUNT commands, see “Chapter5.
Client Mounting of File Systems” on page39. For more information on the options
to the ADDMFS and MOUNT commands, see
CL Reference,
SC41-4722.
Chapter2. The Network File System Client/Server Model 13
|
|
|
|
|
|
|
|
|
|
|
|
|
|