git: kernel - Fix SMP races with vnode cluster fields

Matthew Dillon dillon at crater.dragonflybsd.org
Tue Dec 3 18:03:54 PST 2013


commit 38a4b3080c769f150fdc231473133e141c4a24f7
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Tue Dec 3 17:42:46 2013 -0800

    kernel - Fix SMP races with vnode cluster fields
    
    * The better concurrency we have due to the recent buffer cache work has
      revealed a SMP race in the vfs_cluster code.  Various fields used by
      cluster_write() can race and cause the wrong buffers to be clustered to
      the wrong disk offset, resulting in disk corruption.
    
    * Rip the v_lastw, v_cstart, v_lasta, and v_clen fields out of struct vnode
      and replace with a global cluster state cache in vfs_cluster.c.
    
      The cache is implemented as a 512-entry hash table, 4-way set associative,
      and is more advanced than the original implementation in that it allows
      up to four different seek zones to be tracked on each vnode, instead of
      only one.  This should make buffered device I/O (used by filesystems)
      work better.
    
      Cache elements are heuristically locked with an atomic_swap_int().  If
      the code is unable to instantly acquire a lock on an element it will
      simply not cluster that particular I/O (instead of blocking).  Even though
      this is a global hash table, operations will have a tendancy to be
      localized to cache elements.
    
    * Remove some manual clearing of fields in UFS's ffs_truncate() routine.
      It should have no material effect.

Summary of changes:
 sys/kern/vfs_cluster.c  | 191 ++++++++++++++++++++++++++++++++++++++----------
 sys/sys/vnode.h         |   4 -
 sys/vfs/ufs/ffs_inode.c |   1 -
 3 files changed, 154 insertions(+), 42 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/38a4b3080c769f150fdc231473133e141c4a24f7


-- 
DragonFly BSD source repository


More information about the Commits mailing list