git: kernel - Add new bufcache/VM consolidated API, fsx fixes for NFS

Matthew Dillon dillon at
Tue Jan 19 15:08:05 PST 2010

commit 8452310f570a350179c13d0f8bf1d1e2e4bb2199
Author: Matthew Dillon <dillon at>
Date:   Tue Jan 19 14:45:46 2010 -0800

    kernel - Add new bufcache/VM consolidated API, fsx fixes for NFS
    * Add kern/vfs_vm.c with a new API for vtruncbuf() and vnode_pager_setsize()
      called nvtruncbuf(), nvextendbuf(), and nvnode_pager_setsize().  This
      API solves numerous problems with data coherency between the VM and
      buffer cache subsystems.
      Generally speaking what this API does is allow the VM pages backing the
      buffer straddling EOF in a file to remain valid instead of invalidating
      them.  Take NFS for example with 32K buffers and, say, a 16385 byte
      file.  The NFS buffer cache buffer is backed by 8 x 4K VM pages but
      the actual file only requires 5 x 4K pages.  This API keeps all 8 VM
      pages valid.
      This API also handles zeroing out portions of the buffer after truncation
      and zero-extending portions of the buffer after a file extension.
      NFS has been migrated to the new API.  HAMMER will soon follow.  UFS and
      EXT2FS are harder due to their far more complex buffer cache sizing
      operations (due to their fragment vs full-sized block handling).
    * Remodel the NFS client to use the new API.  This allows NFS to consolidate
      all truncation and extension operations into nfs_meta_setsize(), including
      all code which previously had to deal with special buffer cache / VM
      cases related to truncation and extension.
    * Fix a bug in kern/vfs_bio.c where NFS buffers requiring the clearing
      of B_NEEDCOMMIT failed to also clear B_CLUSTEROK, leading to occassional
      attempts by NFS to issue RPCs larger than the NFS I/O block size (resulting
      in a panic).
    * NFS now uses vop_stdgetpages() and vop_stdputpages().  The NFS-specific
      nfs_getpages() and nfs_putpages() has been removed.  Remove a vinvalbuf()
      in the nfs_bioread() code on remote-directory modification which was
      deadlocking getpages.  This needs more work.
    * Simplify the local-vs-remote modification tests in NFS.  This needs more
      work.  What was happening, generally, was that the larger number of
      RPCs inflight allowed by the NFS client was creating too much confusion
      in the attribute feedback in the RPC replies, causing the NFS client to
      lose track of the file's actual size during heavy modifying operations
      (aka fsx tests).

Summary of changes:
 sys/conf/files          |    1 +
 sys/kern/vfs_bio.c      |    5 +-
 sys/kern/vfs_vm.c       |  417 +++++++++++++++++++++++++++++++++++++++++++++++
 sys/sys/vnode.h         |    5 +
 sys/vfs/nfs/nfs.h       |    4 +-
 sys/vfs/nfs/nfs_bio.c   |  382 ++++---------------------------------------
 sys/vfs/nfs/nfs_subs.c  |   24 ++-
 sys/vfs/nfs/nfs_vnops.c |   35 +----
 sys/vfs/nfs/nfsnode.h   |    2 -
 sys/vm/vm_extern.h      |    1 -
 10 files changed, 481 insertions(+), 395 deletions(-)
 create mode 100644 sys/kern/vfs_vm.c

DragonFly BSD source repository

More information about the Commits mailing list