aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2018-03-20 17:03:13 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-04-10 16:06:22 -0400
commit35156bfff3c0cd44d0e2e674530e0817fd22b313 (patch)
tree976cd84abca95e267ed4596b6a59e6b17f3ef2f7
parent8b0649462407ec4192cacd0f283627b38f24aa5c (diff)
NFSv4: Fix the nfs_inode_set_delegation() arguments
Neither nfs_inode_set_delegation() nor nfs_inode_reclaim_delegation() are generic code. They have no business delving into NFSv4 OPEN xdr structures, so let's replace the "struct nfs_openres" parameter. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--fs/nfs/delegation.c35
-rw-r--r--fs/nfs/delegation.h6
-rw-r--r--fs/nfs/nfs4proc.c12
3 files changed, 34 insertions, 19 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index a5cb44375100..1819d0d0ba4b 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -172,11 +172,15 @@ again:
172 * nfs_inode_reclaim_delegation - process a delegation reclaim request 172 * nfs_inode_reclaim_delegation - process a delegation reclaim request
173 * @inode: inode to process 173 * @inode: inode to process
174 * @cred: credential to use for request 174 * @cred: credential to use for request
175 * @res: new delegation state from server 175 * @type: delegation type
176 * @stateid: delegation stateid
177 * @pagemod_limit: write delegation "space_limit"
176 * 178 *
177 */ 179 */
178void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, 180void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
179 struct nfs_openres *res) 181 fmode_t type,
182 const nfs4_stateid *stateid,
183 unsigned long pagemod_limit)
180{ 184{
181 struct nfs_delegation *delegation; 185 struct nfs_delegation *delegation;
182 struct rpc_cred *oldcred = NULL; 186 struct rpc_cred *oldcred = NULL;
@@ -186,9 +190,9 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
186 if (delegation != NULL) { 190 if (delegation != NULL) {
187 spin_lock(&delegation->lock); 191 spin_lock(&delegation->lock);
188 if (delegation->inode != NULL) { 192 if (delegation->inode != NULL) {
189 nfs4_stateid_copy(&delegation->stateid, &res->delegation); 193 nfs4_stateid_copy(&delegation->stateid, stateid);
190 delegation->type = res->delegation_type; 194 delegation->type = type;
191 delegation->pagemod_limit = res->pagemod_limit; 195 delegation->pagemod_limit = pagemod_limit;
192 oldcred = delegation->cred; 196 oldcred = delegation->cred;
193 delegation->cred = get_rpccred(cred); 197 delegation->cred = get_rpccred(cred);
194 clear_bit(NFS_DELEGATION_NEED_RECLAIM, 198 clear_bit(NFS_DELEGATION_NEED_RECLAIM,
@@ -196,14 +200,14 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
196 spin_unlock(&delegation->lock); 200 spin_unlock(&delegation->lock);
197 rcu_read_unlock(); 201 rcu_read_unlock();
198 put_rpccred(oldcred); 202 put_rpccred(oldcred);
199 trace_nfs4_reclaim_delegation(inode, res->delegation_type); 203 trace_nfs4_reclaim_delegation(inode, type);
200 return; 204 return;
201 } 205 }
202 /* We appear to have raced with a delegation return. */ 206 /* We appear to have raced with a delegation return. */
203 spin_unlock(&delegation->lock); 207 spin_unlock(&delegation->lock);
204 } 208 }
205 rcu_read_unlock(); 209 rcu_read_unlock();
206 nfs_inode_set_delegation(inode, cred, res); 210 nfs_inode_set_delegation(inode, cred, type, stateid, pagemod_limit);
207} 211}
208 212
209static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) 213static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
@@ -330,11 +334,16 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation,
330 * nfs_inode_set_delegation - set up a delegation on an inode 334 * nfs_inode_set_delegation - set up a delegation on an inode
331 * @inode: inode to which delegation applies 335 * @inode: inode to which delegation applies
332 * @cred: cred to use for subsequent delegation processing 336 * @cred: cred to use for subsequent delegation processing
333 * @res: new delegation state from server 337 * @type: delegation type
338 * @stateid: delegation stateid
339 * @pagemod_limit: write delegation "space_limit"
334 * 340 *
335 * Returns zero on success, or a negative errno value. 341 * Returns zero on success, or a negative errno value.
336 */ 342 */
337int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) 343int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred,
344 fmode_t type,
345 const nfs4_stateid *stateid,
346 unsigned long pagemod_limit)
338{ 347{
339 struct nfs_server *server = NFS_SERVER(inode); 348 struct nfs_server *server = NFS_SERVER(inode);
340 struct nfs_client *clp = server->nfs_client; 349 struct nfs_client *clp = server->nfs_client;
@@ -346,9 +355,9 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
346 delegation = kmalloc(sizeof(*delegation), GFP_NOFS); 355 delegation = kmalloc(sizeof(*delegation), GFP_NOFS);
347 if (delegation == NULL) 356 if (delegation == NULL)
348 return -ENOMEM; 357 return -ENOMEM;
349 nfs4_stateid_copy(&delegation->stateid, &res->delegation); 358 nfs4_stateid_copy(&delegation->stateid, stateid);
350 delegation->type = res->delegation_type; 359 delegation->type = type;
351 delegation->pagemod_limit = res->pagemod_limit; 360 delegation->pagemod_limit = pagemod_limit;
352 delegation->change_attr = inode_peek_iversion_raw(inode); 361 delegation->change_attr = inode_peek_iversion_raw(inode);
353 delegation->cred = get_rpccred(cred); 362 delegation->cred = get_rpccred(cred);
354 delegation->inode = inode; 363 delegation->inode = inode;
@@ -393,7 +402,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
393 rcu_assign_pointer(nfsi->delegation, delegation); 402 rcu_assign_pointer(nfsi->delegation, delegation);
394 delegation = NULL; 403 delegation = NULL;
395 404
396 trace_nfs4_set_delegation(inode, res->delegation_type); 405 trace_nfs4_set_delegation(inode, type);
397 406
398out: 407out:
399 spin_unlock(&clp->cl_lock); 408 spin_unlock(&clp->cl_lock);
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index dcc8a783a6e1..bb1ef8c37af4 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -36,8 +36,10 @@ enum {
36 NFS_DELEGATION_TEST_EXPIRED, 36 NFS_DELEGATION_TEST_EXPIRED,
37}; 37};
38 38
39int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 39int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred,
40void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 40 fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
41void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
42 fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
41int nfs4_inode_return_delegation(struct inode *inode); 43int nfs4_inode_return_delegation(struct inode *inode);
42int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 44int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
43void nfs_inode_return_delegation_noreclaim(struct inode *inode); 45void nfs_inode_return_delegation_noreclaim(struct inode *inode);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 924238db5983..3eb53d7784e2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1754,12 +1754,16 @@ nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state)
1754 } 1754 }
1755 if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0) 1755 if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0)
1756 nfs_inode_set_delegation(state->inode, 1756 nfs_inode_set_delegation(state->inode,
1757 data->owner->so_cred, 1757 data->owner->so_cred,
1758 &data->o_res); 1758 data->o_res.delegation_type,
1759 &data->o_res.delegation,
1760 data->o_res.pagemod_limit);
1759 else 1761 else
1760 nfs_inode_reclaim_delegation(state->inode, 1762 nfs_inode_reclaim_delegation(state->inode,
1761 data->owner->so_cred, 1763 data->owner->so_cred,
1762 &data->o_res); 1764 data->o_res.delegation_type,
1765 &data->o_res.delegation,
1766 data->o_res.pagemod_limit);
1763} 1767}
1764 1768
1765/* 1769/*