git: kernel - Fix deadlock assertion panic with mmap/read combos

Matthew Dillon dillon at crater.dragonflybsd.org
Wed Jan 19 14:19:12 PST 2011


commit 283b944850fbb3421a77ef06aa121d066f5c8cad
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Wed Jan 19 14:11:10 2011 -0800

    kernel - Fix deadlock assertion panic with mmap/read combos
    
    * Normally the uiomove() is called with the buffer locked.  When
      uiomove()ing into mmap'd memory this can cause a lock recursion and
      panic, or a deadlock.
    
    * Fix the problem by adding bqhold() and bqdrop() and adjusting the use
      of the b_refs field to prevent the buffer from being invalidated,
      allowing VFS VOP_READ operations to release the buffer prior to the
      uiomove() into user memory.
    
    * Adjust brelse() and getnewbuf() to do the right thing.  Note that there
      are two cases where b_refs can transition from 0->1.  The VFS
      release/uiomove case will only transition b_refs while the buffer is
      locked while findblk() will transition b_refs at any time (while holding
      the spin lock).  We only care about retaining the VM pages in the
      transition-during-locked case.
    
    * Original problem reproducable with
    
      grep -r --mmap SomeString /usr/pkgsrc
    
    Reported-by: YONETANI Tomokazu <qhwt.dfly at les.ath.cx>

Summary of changes:
 sys/kern/vfs_bio.c            |   92 ++++++++++++++++++++++++++++-------------
 sys/sys/buf.h                 |    7 ++-
 sys/vfs/hammer/hammer_vnops.c |   16 ++++++-
 3 files changed, 80 insertions(+), 35 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/283b944850fbb3421a77ef06aa121d066f5c8cad


-- 
DragonFly BSD source repository





More information about the Commits mailing list