Recall from our discussion earlier in this chapter that applications that use the lock arbitration method (called file lock arbitration or dotlocking) check for a dotlock file[10] as a means of arbitrating access to a data file. Because NFS clients are normally configured to use locally cached data that may not be the same as the data stored on the NFS server, the dotlock file arbitration method must be implemented to work over NFS.
In order to use dotlock file arbitration, the programmer must use a method of creating dotlock files that ensures that the dotlock file has been stored on the NFS server and is not just sitting in the local NFS client's cache. This is accomplished (as described on the "open" man page) by creating the dotlock file, linking to it, and then checking to make sure that the link command worked or that the count of the number of links associated with the dotlock file has increased to 2.
Apache, sendmail, and LPRng all use dotlock file lock arbitration. However, none of these use dotlock arbitration to share writable data in a normal Linux Enterprise Cluster configuration.
Note | A CGI program running under Apache on a cluster node may share access to writable data with a CGI program running on another cluster node, but the CGI programs can implement their own locking method independent of the dotlock method used by Apache and thus avoid the complexity of implementing dotlock file locking over NFS. For an example, search CPAN[11] for "File::NFSLock." |
[10]Or they check the contents of the dotlock file to see if a conflicting PID already owns the dotlock file.
[11]See Chapter 15 for how to search and download CPAN modules.