Can NFS be forced to refresh stale files/directories when not using noac on the mount?
We mount without using noac. I have a file that I append to once every 20 minutes. Then it will be read with mmap about 5,000 times a minute. We only mmap a couple blocks for each read. Needless to say, noac just kills the access performance, so we don't use it.
I add data to the end of the file using a mount with noac and read from a mount without noac. The mounts that are reading are not seeing the new data.
I want to know if there is a function I can call from c to refresh the attributes of a path and all its files.
EDIT: I should add we cannot mount and unmount since there are 16 servers running on each system and they are constantly accessing the files. Well...maybe we could mount and unmount if each server used their own mount. I'd like to avoid that if possible.
thanks!
Hmmm.....try mounting the NFS filesystem with the 'sync' option.
And check out this extract of the man page: (man 5 nfs)
The sync mount option.
The NFS client treats the sync mount option differently than some other file systems (refer to mount(8) for a description of the generic sync and async mount options). If neither sync nor async is specified (or if the async option is specified), the NFS client delays sending application writes to the server until any of these events occur:
Memory pressure forces reclamation of system memory resources.
An application flushes file data explicitly with sync(2), msync(2), or fsync(3).
An application closes a file with close(2).
The file is locked/unlocked via fcntl(2).
In other words, under normal circumstances, data written by an application may not immediately appear on the server that hosts the file.
If the sync option is specified on a mount point, any system call that writes data to files on that mount point causes that data to be flushed to the server before the system call returns control to user space. This provides greater data cache coherence among clients, but at a significant performance cost.
Applications can use the O_SYNC open flag to force application writes to individual files to go to the server immediately without the use of the sync mount option.