nfsd: ensure that delegation stateid hash references are only put once
authorJeff Layton <jlayton@poochiereds.net>
Mon, 24 Aug 2015 16:41:48 +0000 (12:41 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 31 Aug 2015 20:32:16 +0000 (16:32 -0400)
commit3fcbbd244ed1d20dc0eb7d48d729503992fa9b7d
treeac901181a7228f5534a4b013c522cc2064beba8d
parente85687393f3ee0a77ccca016f903d1558bb69258
nfsd: ensure that delegation stateid hash references are only put once

It's possible that a DELEGRETURN could race with (e.g.) client expiry,
in which case we could end up putting the delegation hash reference more
than once.

Have unhash_delegation_locked return a bool that indicates whether it
was already unhashed. In the case of destroy_delegation we only
conditionally put the hash reference if that returns true.

The other callers of unhash_delegation_locked call it while walking
list_heads that shouldn't yet be detached. If we find that it doesn't
return true in those cases, then throw a WARN_ON as that indicates that
we have a partially hashed delegation, and that something is likely very
wrong.

Tested-by: Andrew W Elble <aweits@rit.edu>
Tested-by: Anna Schumaker <Anna.Schumaker@netapp.com>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c