AFS Version 2
In this lesson, we learn how version 2 of the NFS addresses the issues in version 1.
We'll cover the following
Callback
AFSv2 introduced the notion of a callback to reduce the number of client/server interactions. A callback is simply a promise from the server to the client that the server will inform the client when a file that the client is caching has been modified. By adding this state to the system, the client no longer needs to contact the server to find out if a cached file is still valid. Rather, it assumes that the file is valid until the server tells it otherwise; notice the analogy to polling versus interrupts.
File identifier (FID)
AFSv2 also introduced the notion of a file identifier (FID) (similar to the NFS file handle) instead of pathnames to specify which file a client was interested in. An FID in AFS consists of a volume identifier, a file identifier, and a “uniquifier” (to enable reuse of the volume and file IDs when a file is deleted). Thus, instead of sending whole pathnames to the server and letting the server walk the pathname to find the desired file, the client would walk the pathname, one piece at a time, caching the results and thus hopefully reducing the load on the server.
For example, if a client accessed the file /home/remzi/notes.txt
, and home
was the AFS directory mounted onto /
(i.e., /
was the local root directory, but home
and its children were in AFS), the client would first Fetch the directory contents of home
, put them in the local-disk cache, and set up a callback on home
. Then, the client would Fetch the directory remzi
, put it in the local disk cache, and set up a callback on remzi
. Finally, the client would Fetch notes.txt
, cache this regular file in the local disk, set up a callback, and finally return a file descriptor to the calling application. See the figure below for a summary.
Difference from NFS
The key difference, however, from NFS, is that with each fetch of a directory or file, the AFS client would establish a callback with the server, thus ensuring that the server would notify the client of a change in its cached state. The benefit is obvious: although the first access to /home/remzi/notes.txt
generates many client-server messages (as described above), it also establishes callbacks for all the directories as well as the file notes.txt, and thus subsequent accesses are entirely local and require no server interaction at all. Thus, in the common case where a file is cached at the client, AFS behaves nearly identically to a local disk-based file system. If one accesses a file more than once, the second access should be just as fast as accessing a file locally.
Get hands-on with 1400+ tech skills courses.