nfsd: clean up races in lock stateid searching and creation
authorJeff Layton <jlayton@primarydata.com>
Wed, 30 Jul 2014 01:34:13 +0000 (21:34 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 31 Jul 2014 18:20:07 +0000 (14:20 -0400)
commit356a95ece7aab38ae464e1041da26dcc1dff7ad2
treefad6d6096f39fe4d9aa2df803b6f2e7d21877916
parent1c755dc1ada95adc9aa41102baada73659397b80
nfsd: clean up races in lock stateid searching and creation

Preparation for removal of the client_mutex.

Currently, no lock aside from the client_mutex is held when calling
find_lock_state. Ensure that the cl_lock is held by adding a lockdep
assertion.

Once we remove the client_mutex, it'll be possible for another thread to
race in and insert a lock state for the same file after we search but
before we insert a new one. Ensure that doesn't happen by redoing the
search after allocating a new stid that we plan to insert. If one is
found just put the one that was allocated.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c