nfs delay causing broken files

Rick Macklem rmacklem at
Fri Feb 6 08:55:44 PST 2009

On Thu, 5 Feb 2009, Joe7 wrote:

> Hi there,
> I'd like to know how to tune NFS (or related kernel) settings so the NFS 
> client writes would have NO delay?
> I'm getting application level errors as NFS client writes data, then 
> application would read the data from NFS master just 1 second later and it's 
> not there yet, so outdated data is read.
You will have to enable synchronous writing (which will be a big 
performance hit, but...):
- either mount with the "sync" option
- have the apps open the files with O_SYNC (or O_FSYNC)

If the recent writes need to be visible on other clients (and not just the
NFS server), you will also have to bypass the client side caching for
readers. This can be done by setting nfs_directio_enable to non-zero
using sysctl and opening the files with O_DIRECT. (I think setting
acregmax=0 as a mount option should achieve the same result, if you can't
add O_DIRECT to the apps.) Again, a big performance hit, but...

As an historical aside, way back when (before NFSv3) I concocked something
callled not quite nfs, which included a cache coherency protocol, but it
didn't catch on. Cache coherency seems to have never been a priority for
the NFS crowd. Even in NFSv4, there isn't a cache coherency protocol, nor
any interest in adding one. (In fairness, coherency between multiple
clients can be achieved in NFSv4 for data by the clients putting byte
range locks on all the byte ranges.)


More information about the freebsd-fs mailing list