]> asedeno.scripts.mit.edu Git - linux.git/commit
NFSv4: ensure __nfs4_find_lock_state returns consistent result.
authorNeilBrown <neilb@suse.com>
Mon, 19 Dec 2016 00:33:13 +0000 (11:33 +1100)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 19 Dec 2016 22:29:50 +0000 (17:29 -0500)
commit3f8f25489fa62437530f654041504936d377d204
tree0b77bc80edabba6f29d65a574e22919273779d7f
parentcfd278c280f997cf2fe4662e0acab0fe465f637b
NFSv4: ensure __nfs4_find_lock_state returns consistent result.

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: Jeff Layton <jlayton@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4state.c