提交 35156bff 编写于 作者: T Trond Myklebust 提交者: Anna Schumaker

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: NTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
上级 8b064946
...@@ -172,11 +172,15 @@ static int nfs_delegation_claim_opens(struct inode *inode, ...@@ -172,11 +172,15 @@ static int nfs_delegation_claim_opens(struct inode *inode,
* nfs_inode_reclaim_delegation - process a delegation reclaim request * nfs_inode_reclaim_delegation - process a delegation reclaim request
* @inode: inode to process * @inode: inode to process
* @cred: credential to use for request * @cred: credential to use for request
* @res: new delegation state from server * @type: delegation type
* @stateid: delegation stateid
* @pagemod_limit: write delegation "space_limit"
* *
*/ */
void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
struct nfs_openres *res) fmode_t type,
const nfs4_stateid *stateid,
unsigned long pagemod_limit)
{ {
struct nfs_delegation *delegation; struct nfs_delegation *delegation;
struct rpc_cred *oldcred = NULL; struct rpc_cred *oldcred = NULL;
...@@ -186,9 +190,9 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, ...@@ -186,9 +190,9 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
if (delegation != NULL) { if (delegation != NULL) {
spin_lock(&delegation->lock); spin_lock(&delegation->lock);
if (delegation->inode != NULL) { if (delegation->inode != NULL) {
nfs4_stateid_copy(&delegation->stateid, &res->delegation); nfs4_stateid_copy(&delegation->stateid, stateid);
delegation->type = res->delegation_type; delegation->type = type;
delegation->pagemod_limit = res->pagemod_limit; delegation->pagemod_limit = pagemod_limit;
oldcred = delegation->cred; oldcred = delegation->cred;
delegation->cred = get_rpccred(cred); delegation->cred = get_rpccred(cred);
clear_bit(NFS_DELEGATION_NEED_RECLAIM, clear_bit(NFS_DELEGATION_NEED_RECLAIM,
...@@ -196,14 +200,14 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, ...@@ -196,14 +200,14 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
spin_unlock(&delegation->lock); spin_unlock(&delegation->lock);
rcu_read_unlock(); rcu_read_unlock();
put_rpccred(oldcred); put_rpccred(oldcred);
trace_nfs4_reclaim_delegation(inode, res->delegation_type); trace_nfs4_reclaim_delegation(inode, type);
return; return;
} }
/* We appear to have raced with a delegation return. */ /* We appear to have raced with a delegation return. */
spin_unlock(&delegation->lock); spin_unlock(&delegation->lock);
} }
rcu_read_unlock(); rcu_read_unlock();
nfs_inode_set_delegation(inode, cred, res); nfs_inode_set_delegation(inode, cred, type, stateid, pagemod_limit);
} }
static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) static 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,11 +334,16 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation,
* nfs_inode_set_delegation - set up a delegation on an inode * nfs_inode_set_delegation - set up a delegation on an inode
* @inode: inode to which delegation applies * @inode: inode to which delegation applies
* @cred: cred to use for subsequent delegation processing * @cred: cred to use for subsequent delegation processing
* @res: new delegation state from server * @type: delegation type
* @stateid: delegation stateid
* @pagemod_limit: write delegation "space_limit"
* *
* Returns zero on success, or a negative errno value. * Returns zero on success, or a negative errno value.
*/ */
int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred,
fmode_t type,
const nfs4_stateid *stateid,
unsigned long pagemod_limit)
{ {
struct nfs_server *server = NFS_SERVER(inode); struct nfs_server *server = NFS_SERVER(inode);
struct nfs_client *clp = server->nfs_client; 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,9 +355,9 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
delegation = kmalloc(sizeof(*delegation), GFP_NOFS); delegation = kmalloc(sizeof(*delegation), GFP_NOFS);
if (delegation == NULL) if (delegation == NULL)
return -ENOMEM; return -ENOMEM;
nfs4_stateid_copy(&delegation->stateid, &res->delegation); nfs4_stateid_copy(&delegation->stateid, stateid);
delegation->type = res->delegation_type; delegation->type = type;
delegation->pagemod_limit = res->pagemod_limit; delegation->pagemod_limit = pagemod_limit;
delegation->change_attr = inode_peek_iversion_raw(inode); delegation->change_attr = inode_peek_iversion_raw(inode);
delegation->cred = get_rpccred(cred); delegation->cred = get_rpccred(cred);
delegation->inode = inode; delegation->inode = inode;
...@@ -393,7 +402,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct ...@@ -393,7 +402,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
rcu_assign_pointer(nfsi->delegation, delegation); rcu_assign_pointer(nfsi->delegation, delegation);
delegation = NULL; delegation = NULL;
trace_nfs4_set_delegation(inode, res->delegation_type); trace_nfs4_set_delegation(inode, type);
out: out:
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
......
...@@ -36,8 +36,10 @@ enum { ...@@ -36,8 +36,10 @@ enum {
NFS_DELEGATION_TEST_EXPIRED, NFS_DELEGATION_TEST_EXPIRED,
}; };
int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred,
void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
int nfs4_inode_return_delegation(struct inode *inode); int nfs4_inode_return_delegation(struct inode *inode);
int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
void nfs_inode_return_delegation_noreclaim(struct inode *inode); void nfs_inode_return_delegation_noreclaim(struct inode *inode);
......
...@@ -1754,12 +1754,16 @@ nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) ...@@ -1754,12 +1754,16 @@ nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state)
} }
if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0) if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0)
nfs_inode_set_delegation(state->inode, nfs_inode_set_delegation(state->inode,
data->owner->so_cred, data->owner->so_cred,
&data->o_res); data->o_res.delegation_type,
&data->o_res.delegation,
data->o_res.pagemod_limit);
else else
nfs_inode_reclaim_delegation(state->inode, nfs_inode_reclaim_delegation(state->inode,
data->owner->so_cred, data->owner->so_cred,
&data->o_res); data->o_res.delegation_type,
&data->o_res.delegation,
data->o_res.pagemod_limit);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册