• NeilBrown's avatar
    nfsd: replace rp_mutex to avoid deadlock in move_to_close_lru() · eec76208
    NeilBrown authored
    move_to_close_lru() waits for sc_count to become zero while holding
    rp_mutex.  This can deadlock if another thread holds a reference and is
    waiting for rp_mutex.
    
    By the time we get to move_to_close_lru() the openowner is unhashed and
    cannot be found any more.  So code waiting for the mutex can safely
    retry the lookup if move_to_close_lru() has started.
    
    So change rp_mutex to an atomic_t with three states:
    
     RP_UNLOCK   - state is still hashed, not locked for reply
     RP_LOCKED   - state is still hashed, is locked for reply
     RP_UNHASHED - state is not hashed, no code can get a lock.
    
    Use wait_var_event() to wait for either a lock, or for the owner to be
    unhashed.  In the latter case, retry the lookup.
    Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    eec76208
nfs4state.c 231 KB