diff options
author | Jeff Layton <jlayton@primarydata.com> | 2014-07-29 21:34:38 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-07-31 14:20:27 -0400 |
commit | a819ecc1bbb0c795184c80afeec0e7a6ef508ef5 (patch) | |
tree | a7e671d2cf830fb2b47c09ad086b20cc199f478c /fs/nfsd | |
parent | 882e9d25e11d644b24e578866c688d3f8f0d3712 (diff) |
nfsd: add locking to stateowner release
Once we remove the client_mutex, we'll need to properly protect
the stateowner reference counts using the cl_lock.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cd7d7df03afa..9b342e164407 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -937,9 +937,14 @@ release_all_access(struct nfs4_ol_stateid *stp) | |||
937 | 937 | ||
938 | static void nfs4_put_stateowner(struct nfs4_stateowner *sop) | 938 | static void nfs4_put_stateowner(struct nfs4_stateowner *sop) |
939 | { | 939 | { |
940 | if (!atomic_dec_and_test(&sop->so_count)) | 940 | struct nfs4_client *clp = sop->so_client; |
941 | |||
942 | might_lock(&clp->cl_lock); | ||
943 | |||
944 | if (!atomic_dec_and_lock(&sop->so_count, &clp->cl_lock)) | ||
941 | return; | 945 | return; |
942 | sop->so_ops->so_unhash(sop); | 946 | sop->so_ops->so_unhash(sop); |
947 | spin_unlock(&clp->cl_lock); | ||
943 | kfree(sop->so_owner.data); | 948 | kfree(sop->so_owner.data); |
944 | sop->so_ops->so_free(sop); | 949 | sop->so_ops->so_free(sop); |
945 | } | 950 | } |
@@ -3078,11 +3083,7 @@ static void hash_openowner(struct nfs4_openowner *oo, struct nfs4_client *clp, u | |||
3078 | 3083 | ||
3079 | static void nfs4_unhash_openowner(struct nfs4_stateowner *so) | 3084 | static void nfs4_unhash_openowner(struct nfs4_stateowner *so) |
3080 | { | 3085 | { |
3081 | struct nfs4_client *clp = so->so_client; | ||
3082 | |||
3083 | spin_lock(&clp->cl_lock); | ||
3084 | unhash_openowner_locked(openowner(so)); | 3086 | unhash_openowner_locked(openowner(so)); |
3085 | spin_unlock(&clp->cl_lock); | ||
3086 | } | 3087 | } |
3087 | 3088 | ||
3088 | static void nfs4_free_openowner(struct nfs4_stateowner *so) | 3089 | static void nfs4_free_openowner(struct nfs4_stateowner *so) |
@@ -4842,11 +4843,7 @@ find_lockowner_str(clientid_t *clid, struct xdr_netobj *owner, | |||
4842 | 4843 | ||
4843 | static void nfs4_unhash_lockowner(struct nfs4_stateowner *sop) | 4844 | static void nfs4_unhash_lockowner(struct nfs4_stateowner *sop) |
4844 | { | 4845 | { |
4845 | struct nfs4_client *clp = sop->so_client; | ||
4846 | |||
4847 | spin_lock(&clp->cl_lock); | ||
4848 | unhash_lockowner_locked(lockowner(sop)); | 4846 | unhash_lockowner_locked(lockowner(sop)); |
4849 | spin_unlock(&clp->cl_lock); | ||
4850 | } | 4847 | } |
4851 | 4848 | ||
4852 | static void nfs4_free_lockowner(struct nfs4_stateowner *sop) | 4849 | static void nfs4_free_lockowner(struct nfs4_stateowner *sop) |