Commit 6dc9d57af9917f5c7faa13c17b770dce17c3972b
1 parent
0286001430
Exists in
master
and in
4 other branches
NFSv4: Callers to nfs4_get_renew_cred() need to hold nfs_client->cl_lock
Ditto for nfs4_get_setclientid_cred(). Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 3 changed files with 17 additions and 7 deletions Side-by-side Diff
fs/nfs/nfs4_fs.h
... | ... | @@ -202,7 +202,7 @@ |
202 | 202 | extern void nfs4_renew_state(struct work_struct *); |
203 | 203 | |
204 | 204 | /* nfs4state.c */ |
205 | -struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp); | |
205 | +struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp); | |
206 | 206 | |
207 | 207 | extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *); |
208 | 208 | extern void nfs4_put_state_owner(struct nfs4_state_owner *); |
fs/nfs/nfs4renewd.c
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | timeout = (2 * lease) / 3 + (long)last - (long)now; |
78 | 78 | /* Are we close to a lease timeout? */ |
79 | 79 | if (time_after(now, last + lease/3)) { |
80 | - cred = nfs4_get_renew_cred(clp); | |
80 | + cred = nfs4_get_renew_cred_locked(clp); | |
81 | 81 | if (cred == NULL) { |
82 | 82 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
83 | 83 | spin_unlock(&clp->cl_lock); |
fs/nfs/nfs4state.c
... | ... | @@ -71,14 +71,12 @@ |
71 | 71 | return status; |
72 | 72 | } |
73 | 73 | |
74 | -static struct rpc_cred *nfs4_get_machine_cred(struct nfs_client *clp) | |
74 | +static struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp) | |
75 | 75 | { |
76 | 76 | struct rpc_cred *cred = NULL; |
77 | 77 | |
78 | - spin_lock(&clp->cl_lock); | |
79 | 78 | if (clp->cl_machine_cred != NULL) |
80 | 79 | cred = get_rpccred(clp->cl_machine_cred); |
81 | - spin_unlock(&clp->cl_lock); | |
82 | 80 | return cred; |
83 | 81 | } |
84 | 82 | |
... | ... | @@ -94,7 +92,7 @@ |
94 | 92 | put_rpccred(cred); |
95 | 93 | } |
96 | 94 | |
97 | -struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp) | |
95 | +struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) | |
98 | 96 | { |
99 | 97 | struct nfs4_state_owner *sp; |
100 | 98 | struct rb_node *pos; |
101 | 99 | |
... | ... | @@ -110,13 +108,24 @@ |
110 | 108 | return cred; |
111 | 109 | } |
112 | 110 | |
111 | +static struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp) | |
112 | +{ | |
113 | + struct rpc_cred *cred; | |
114 | + | |
115 | + spin_lock(&clp->cl_lock); | |
116 | + cred = nfs4_get_renew_cred_locked(clp); | |
117 | + spin_unlock(&clp->cl_lock); | |
118 | + return cred; | |
119 | +} | |
120 | + | |
113 | 121 | static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp) |
114 | 122 | { |
115 | 123 | struct nfs4_state_owner *sp; |
116 | 124 | struct rb_node *pos; |
117 | 125 | struct rpc_cred *cred; |
118 | 126 | |
119 | - cred = nfs4_get_machine_cred(clp); | |
127 | + spin_lock(&clp->cl_lock); | |
128 | + cred = nfs4_get_machine_cred_locked(clp); | |
120 | 129 | if (cred != NULL) |
121 | 130 | goto out; |
122 | 131 | pos = rb_first(&clp->cl_state_owners); |
... | ... | @@ -125,6 +134,7 @@ |
125 | 134 | cred = get_rpccred(sp->so_cred); |
126 | 135 | } |
127 | 136 | out: |
137 | + spin_unlock(&clp->cl_lock); | |
128 | 138 | return cred; |
129 | 139 | } |
130 | 140 |