Skip to content
  • Guoqing Jiang's avatar
    md-cluster: Protect communication with mutexes · 8b9277c8
    Guoqing Jiang authored
    
    
    Communication can happen through multiple threads. It is possible that
    one thread steps over another threads sequence. So, we use mutexes to
    protect both the send and receive sequences.
    
    Send communication is locked through state bit, MD_CLUSTER_SEND_LOCK.
    Communication is locked with bit manipulation in order to allow
    "lock and hold" for the add operation. In case of an add operation,
    if the lock is held, MD_CLUSTER_SEND_LOCKED_ALREADY is set.
    When md_update_sb() calls metadata_update_start(), it checks
    (in a single statement to avoid races), if the communication
    is already locked. If yes, it merely returns zero, else it
    locks the token lockresource.
    
    Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
    Signed-off-by: default avatarNeilBrown <neilb@suse.com>
    8b9277c8