Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

mutex: force serialization on mutex_exit() to fix races #421

Closed
wants to merge 1 commit into from

Commits on Dec 19, 2014

  1. mutex: force serialization on mutex_exit() to fix races

    It is known that mutex in Linux is not safe when using it to synchronize
    the freeing of object in which the mutex is embedded:
    http://lwn.net/Articles/575477/
    
    The known places in ZFS which are suspected to suffer from the race condition
    are zio->io_lock and dbuf->db_mtx:
      zio uses zio->io_lock and zio->io_cv to synchronize freeing between zio_wait()
      and zio_done().
      dbuf uses dbuf->db_mtx to protect reference counting.
    
    Add it's been reported multiple time that zio->io_lock and dbuf->db_mtx suffer
    from corruption, which is exactly the symptom of the race.
    openzfs/zfs#2523
    openzfs/zfs#2897
    
    This patch fix this kind of race by forcing serializaion on mutex_exit() with
    a spinlock, making the mutex safer by sacrificing a bit of performance and
    memory overhead.
    
    Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
    tuxoko committed Dec 19, 2014
    Configuration menu
    Copy the full SHA
    a5249cc View commit details
    Browse the repository at this point in the history