nfsd: ensure that the ol stateid hash reference is only put once
authorJeff Layton <jlayton@poochiereds.net>
Mon, 24 Aug 2015 16:41:47 +0000 (12:41 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 31 Aug 2015 20:32:15 +0000 (16:32 -0400)
commite85687393f3ee0a77ccca016f903d1558bb69258
tree6683eba3ed1b59e299f085ed56d98d2fc67530f6
parent051ac3848a94f21cfdec899cc9c65ce7f9f116fa
nfsd: ensure that the ol stateid hash reference is only put once

When an open or lock stateid is hashed, we take an extra reference to
it. When we unhash it, we drop that reference. The code however does
not properly account for the case where we have two callers concurrently
trying to unhash the stateid. This can lead to list corruption and the
hash reference being put more than once.

Fix this by having unhash_ol_stateid use list_del_init on the st_perfile
list_head, and then testing to see if that list_head is empty before
releasing the hash reference. This means that some of the unhashing
wrappers now become bool return functions so we can test to see whether
the stateid was unhashed before we put the reference.

Reported-by: Andrew W Elble <aweits@rit.edu>
Tested-by: Andrew W Elble <aweits@rit.edu>
Reported-by: Anna Schumaker <Anna.Schumaker@netapp.com>
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