As mentioned in the introduction to this chapter, AFS uses client-side data caching and callbacks to reduce the amount of network traffic in your cell. The Cache Manager also tries to make its use of the network as efficient as possible by assigning preference ranks to server machines based on their network proximity to the local machine. The ranks bias the Cache Manager to fetch information from the server machines that are on its own subnetwork or network rather than on other networks, if possible. Reducing the network distance that data travels between client and server machine tends to reduce network traffic and speed the Cache Manager's delivery of data to applications.
The Cache Manager stores two separate sets of preference ranks in kernel memory. The first set of ranks applies to machines that run the Volume Location (VL) Server process, hereafter referred to as VL Server machines. The second set of ranks applies to machines that run the File Server process, hereafter referred to as file server machines. This section explains how the Cache Manager sets default ranks, how to use the fs setserverprefs command to change the defaults or set new ranks, and how to use the fs getserverprefs command to display the current set of ranks.
As the afsd program initializes the Cache Manager, it assigns a preference rank of 10,000 to each of the VL Server machines listed in the local /usr/vice/etc/CellServDB file. It then randomizes the ranks by adding an integer randomly chosen from the range 0 (zero) to 126. It avoids assigning the same rank to machines in one cell, but it is possible for machines from different cells to have the same rank. This does not present a problem in use, because the Cache Manager compares the ranks of only one cell's database server machines at a time. Although AFS supports the use of multihomed database server machines, the Cache Manager only uses the single address listed for each database server machine in the local /usr/vice/etc/CellServDB file. Only Ubik can take advantage of a multihomed database server machine's multiple interfaces.
The Cache Manager assigns preference ranks to a file server machine when it obtains the server's VLDB record from the VL Server, the first time that it accesses a volume that resides on the machine. If the machine is multihomed, the Cache Manager assigns a distinct rank to each of its interfaces (up to the number of interfaces that the VLDB can store for each machine, which is specified in the OpenAFS Release Notes). The Cache Manager compares the interface's IP address to the local machine's address and applies the following algorithm:
If the local machine is a file server machine, the base rank for each of its interfaces is 5,000.
If the file server machine interface is on the same subnetwork as the local machine, its base rank is 20,000.
If the file server machine interface is on the same network as the local machine, or is at the distant end of a point-to-point link with the local machine, its base rank is 30,000.
If the file server machine interface is on a different network than the local machine, or the Cache Manager cannot obtain network information about it, its base rank is 40,000.
If the client machine has only one interface, the Cache Manager compares it to the server interface's IP address and sets a rank according to the algorithm. If the client machine is multihomed, the Cache Manager compares each of the local interface addresses to the server interface, and assigns to the server interface the lowest rank that results from comparing it to all of the client interfaces.
After assigning a base rank to a file server machine interface, the Cache Manager adds to it a number randomly chosen from the range 0 (zero) to 15. As an example, a file server machine interface in the same subnetwork as the local machine receives a base rank of 20,000, but the Cache Manager records the actual rank as an integer between 20,000 and 20,015. This process reduces the number of interfaces that have exactly the same rank. As with VL Server machine ranks, it is possible for file server machine interfaces from foreign cells to have the same rank as interfaces in the local cell, but this does not present a problem. Only the relative ranks of the interfaces that house a specific volume are relevant, and AFS supports storage of a volume in only one cell at a time.
Each preference rank pairs an interface's IP address with an integer that can range from 1 to 65,534. A lower rank (lower number) indicates a stronger preference. Once set, a rank persists until the machine reboots, or until you use the fs setserverprefs command to change it.
The Cache Manager uses VL Server machine ranks when it needs to fetch volume location information from a cell. It compares the ranks for the cell's VL Server machines and attempts to contact the VL Server process on the machine with the best (lowest integer) rank. If it cannot reach that VL Server, it tries to contact the VL Server with the next best rank, and so on. If all of a cell's VL Server machines are inaccessible, the Cache Manager cannot fetch data from the cell.
Similarly, when the Cache Manager needs to fetch data from a volume, it compares the ranks for the interfaces of machines that house the volume, and attempts to contact the interface that has the best rank. If it cannot reach the fileserver process via that interface, it tries to contact the interface with the next best integer rank, and so on. If it cannot reach any of the interfaces for machines that house the volume, it cannot fetch data from the volume.
To display the file server machine ranks that the Cache Manager is using, use the fs getserverprefs command. Include the -vlservers flag to display VL Server machine ranks instead. By default, the output appears on the standard output stream (stdout), but you can write it to a file instead by including the -file argument.
The Cache Manager stores IP addresses rather than hostnames in its kernel list of ranks, but by default the output identifies interfaces by hostname after calling a translation routine that refers to either the cell's name service (such as the Domain Name Server) or the local host table. If an IP address appears in this case, it is because the translation attempt failed. To bypass the translation step and display IP addresses rather than hostnames, include the -numeric flag. This can significantly speed up the output.
You can use the fs setserverprefs command to reset an existing preference rank, or to set the initial rank of a file server machine interface or VL Server machine for which the Cache Manager has no rank. The ranks you set persist until the machine reboots or until you issue the fs setserverprefs command again. To make a rank persist across a reboot, place the appropriate fs setserverprefs command in the machine's AFS initialization file.
As with default ranks, the Cache Manager adds a randomly chosen integer to each rank range that you assign. For file server machine interfaces, the randomizing number is from the range 0 (zero) to 15; for VL Server machines, it is from the range 0 (zero) to 126. For example, if you assign a rank of 15,000 to a file server machine interface, the Cache Manager stores an integer between 15,000 to 15,015.
To assign VL Server machine ranks, list them after the -vlserver argument to the fs setserverprefs command.
To assign file server machine ranks, use or more of the three possible methods:
List them after the -servers argument on the command line.
Record them in a file and name it with the -file argument. You can easily generate a file with the proper format by including the -file argument to the fs getserverprefs command.
Provide them via the standard input stream, by including the -stdin flag. This enables you to feed in values directly from a command or script that generates preferences using an algorithm appropriate for your cell. It must generate them in the proper format, with one or more spaces between each pair and between the two parts of the pair. The AFS distribution does not include such a script, so you must write one if you want to use this method.
You can combine any of the -servers, -file, and -stdin options on the same command line if you wish. If more than one of them specifies a rank for the same interface, the one assigned with the -servers argument takes precedence. You can also provide the -vlservers argument on the same command line to set VL Server machine ranks at the same time as file server machine ranks.
The fs command interpreter does not verify hostnames or IP addresses, and so willingly stores ranks for hostnames and addresses that don't actually exist. The Cache Manager never uses such ranks unless the same VLDB record for a server machine records the same incorrect information.
Issue the fs getserverprefs command to display the Cache Manager's preference ranks for file server machines or VL Server machines.
% fs getserverprefs [-file <
output to named file>] [-numeric] [-vlservers]
Is an acceptable alias for getserverprefs (gets is the shortest acceptable abbreviation).
Specifies the pathname of the file to which to write the list of ranks. Omit this argument to display the list on the standard output stream (stdout).
Displays the IP address, rather than the hostname, of each ranked machine interface. Omit this flag to have the addresses translated into hostnames, which takes longer.
Displays ranks for VL Server machines rather than file server machines.
The following example displays file server machine ranks. The -numeric flag is not used, so the appearance of an IP address indicates that is not currently possible to translate it to a hostname.
% fs gp fs5.example.com 20000 fs1.example.com 30014 server1.example.org 40011 fs3.example.com 20001 fs4.example.com 30001 184.108.40.206 40002 220.127.116.11 40001 . . . . . . .
Become the local superuser root on the machine, if you are not already, by issuing the su command.
% su root Password: <
Issue the fs setserverprefs command to set the Cache Manager's preference ranks for one or more file server machines or VL Server machines.
# fs setserverprefs [-servers <
fileserver names and ranks>+] \ [-vlservers <
VL server names and ranks>+] \ [-file <
input from named file>] [-stdin]
Is an acceptable alias for setserverprefs (sets is the shortest acceptable abbreviation).
Specifies one or more pairs of file server machine interface and rank. Identify each interface by its fully-qualified hostname or IP address in dotted decimal format. Acceptable ranks are the integers from 1 to 65534. Separate the parts of a pair, and the pairs from one another, with one or more spaces.
Specifies one or more pairs of VL Server machine and rank. Identify each machine by its fully-qualified hostname or IP address in dotted decimal format. Acceptable ranks are the integers from 1 to 65534.
Specifies the pathname of a file that contains one more pairs of file server machine interface and rank. Place each pair on its own line in the file. Use the same format for interfaces and ranks as with the -servers argument.
Indicates that pairs of file server machine interface and rank are being provided via the standard input stream (stdin). The program or script that generates the pairs must format them in the same manner as for the -servers argument.