Clean up a number of caching edge cases in NFS, rework the code to be
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 17 Mar 2005 17:28:46 +0000 (17:28 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 17 Mar 2005 17:28:46 +0000 (17:28 +0000)
commit5a9187cbcb515049916aabc8f3cd880e0eb9b239
treee42412528c5b12e6fcacbdf7f6a40102c6c08171
parentf015bdb1418a50842351de2c459a92860e4b5069
Clean up a number of caching edge cases in NFS, rework the code to be
a bit more readable, document some bits, and fix some cache coherency
detection issues.  The caching cleanups should allow the NFS client to
retain more of the NFS cache when doing complex operations on a file.

* Properly check and update the mtime using WCC records in the NFS response.
  This record gives us the 'before' and 'after' mtime.  The 'before' mtime
  must match our existing idea of the mtime, if it doesn't we flag the
  nfsnode as having been modified by the server.  Our notion of the mtime
  is then set to the 'after time.  This was not being done properly for
  several edge cases.

  This required extending the nfsm macros a bit in order to be able to tell
  loadattrcache how to handle the mtime data.  This also required rearranging
  (really fixing) the sequence in nfs_open(), nfs_write(), etc.

* Rearrange the flags a bit.  NSIZECHANGED -> NRMODIFIED (nfsnode modified
  by server), NMODIFIED -> NLMODIFIED (nfsnode modified by client).  Do
  not clear NRMODIFIED until we have actually invalidated the cache (this
  fixes a problem where programs using mmap() were not properly clearing
  the cache after a file was modified on the server).

* Don't code NRMODIFIED as an exception to NLMODIFIED.  Recode the flags so
  they (mostly) operate in tandem.

* When appending to a file, use nfs_flush() instead of nfs_vinvalbuf().
  There is no need to destroy our data cache for the file.  This makes
  appends considerably more efficient.

* Hopefully fix the last problem associated with attribute timeouts.

* Clear the attribute cache when a file is opened for write in nfs_open()
  BEFORE doing other checks rather then after.

* Document some of the nastier cache coherency hacks.
sys/vfs/nfs/nfs.h
sys/vfs/nfs/nfs_bio.c
sys/vfs/nfs/nfs_node.c
sys/vfs/nfs/nfs_nqlease.c
sys/vfs/nfs/nfs_subs.c
sys/vfs/nfs/nfs_vfsops.c
sys/vfs/nfs/nfs_vnops.c
sys/vfs/nfs/nfsm_subs.h
sys/vfs/nfs/nfsnode.h
usr.sbin/pstat/pstat.c