# NFS client: write invalidates buffer cache



## Asok (Jan 23, 2009)

Have a linux box as nfs server and freebsd box as nfs client.
A process running on the freebsd box keeps appending data to the end of a file present on the nfs server. Periodically, another process running on freebsd nfs client box reads the same file. Every time read() is issued, the whole file is fetched from the Linux box over the network instead of from the local file system cache. If write()'s are stopped, subsequent read()'s are served out of the local cache itself. The moment another byte is appended to the file and a read() issued, the file is fetched from the NFS server again.

_Some info:_
- File is opened for writing with O_RDWR and for reading with O_RDONLY.
- There's a single nfs client.
- I am able to reproduce the problem trivially even with files few bytes long.
- Client: NFSv3 on FreeBSD6.2
- Server: Linux 2.6.24-23.

Interestingly, if I reverse the roles, i.e, use FreeBSD as server and Linux as NFS client, I see that issuing a read() on a dirtied buffer cache just results in the cache being flushed i.e, the new bytes appended are sent over to the FreeBSD server to be committed. However, the file is not read back from the server again as observed when using a FreeBSD client.

Am wondering how to avoid going to the server even if the local buffer cache is dirtied. Thanks for any pointers.


----------

