• NeilBrown's avatar
    NFSv4: ensure __nfs4_find_lock_state returns consistent result. · 3f8f2548
    NeilBrown authored
    If a file has both flock locks and OFD locks, then it is possible that
    two different nfs4 lock states could apply to file accesses from a
    single process.
    
    It is not possible to know, efficiently, which one is "correct".
    Presumably the state which represents a lock that covers the region
    undergoing IO would be the "correct" one to use, but finding that has
    a non-trivial cost and would provide miniscule value.
    
    Currently we just return whichever is first in the list, which could
    result in inconsistent behaviour if an application ever put it self in
    this position.  As consistent behaviour is preferable (when perfectly
    correct behaviour is not available), change the search to return a
    consistent result in this circumstance.
    Specifically: if there is both a flock and OFD lock state, always return
    the flock one.
    Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
    Signed-off-by: default avatarNeilBrown <neilb@suse.com>
    Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
    3f8f2548
nfs4state.c 65.7 KB