For When You Can't Have The Real Thing
[ start | index | login ]
start > CentOS > 5 > NFS File Creation Cache Problems

NFS File Creation Cache Problems

Created by dave. Last edited by dave, 12 years and 333 days ago. Viewed 6,400 times. #2
[diff] [history] [edit] [rdf]
labels
attachments

Problem

If I create a file on an nfs-mounted filesystem on one machine, the file may not be immediately visible to another machine looking at the same nfs-mounted filesystem.

In our case this happened with a compute farm environment, where a job was dispatched to a remote machine to write some file, then when that job finished the dispatching machine tried immediately read that file. This would regularly fail and the immediate work-around was a sleep(10) step in between the dispatched-job-finish and the subsequent read-the-created-file step.

Solution

$ man nfs
[...]

lookupcache=type This option dictates how directories and files should be cached when they are accessed -- i.e. "looked up" -- on the server. A lookup can be either positive (directory/file was found) or negative (directory/file was not found); both types of lookups can be cached.

By default, both positive and negative lookups are cached ( lookupcache=all ). lookupcache=pos prevents negative lookups from being cached, while lookupcache=none prevents all lookups from being cached.

Note: lookupcache=none can adversely affect performance, but may be necessary if shared files created or deleted on the server need to be immediately visible to any applications running on NFS clients.

I added the option lookupcache=pos to the automount options for this filesystem and the problem went away.

Availability

This appears to be added for the RedHat/CentOS >>5.4 release cycle and should be available in those or later releases.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt