Commit 7cca0e96 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFSv4: Refactor nfs4_opendata_check_deleg()

Modify it to no longer depend directly on the struct opendata.
This will enable sharing with WANT_DELEGATION.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarLance Shelton <lance.shelton@hammerspace.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 82062051
...@@ -1954,51 +1954,39 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) ...@@ -1954,51 +1954,39 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
} }
static void static void
nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) nfs4_process_delegation(struct inode *inode, const struct cred *cred,
enum open_claim_type4 claim,
const struct nfs4_open_delegation *delegation)
{ {
struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client; switch (delegation->open_delegation_type) {
struct nfs_delegation *delegation;
int delegation_flags = 0;
switch (data->o_res.delegation.open_delegation_type) {
case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_READ:
case NFS4_OPEN_DELEGATE_WRITE: case NFS4_OPEN_DELEGATE_WRITE:
break; break;
default: default:
return; return;
}; }
rcu_read_lock(); switch (claim) {
delegation = rcu_dereference(NFS_I(state->inode)->delegation);
if (delegation)
delegation_flags = delegation->flags;
rcu_read_unlock();
switch (data->o_arg.claim) {
default:
break;
case NFS4_OPEN_CLAIM_DELEGATE_CUR: case NFS4_OPEN_CLAIM_DELEGATE_CUR:
case NFS4_OPEN_CLAIM_DELEG_CUR_FH: case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
pr_err_ratelimited("NFS: Broken NFSv4 server %s is " pr_err_ratelimited("NFS: Broken NFSv4 server %s is "
"returning a delegation for " "returning a delegation for "
"OPEN(CLAIM_DELEGATE_CUR)\n", "OPEN(CLAIM_DELEGATE_CUR)\n",
clp->cl_hostname); NFS_SERVER(inode)->nfs_client->cl_hostname);
return; break;
case NFS4_OPEN_CLAIM_PREVIOUS:
nfs_inode_reclaim_delegation(inode, cred,
delegation->type,
&delegation->stateid,
delegation->pagemod_limit);
break;
default:
nfs_inode_set_delegation(inode, cred,
delegation->type,
&delegation->stateid,
delegation->pagemod_limit);
} }
if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0) if (delegation->do_recall)
nfs_inode_set_delegation(state->inode, nfs_async_inode_return_delegation(inode, &delegation->stateid);
data->owner->so_cred,
data->o_res.delegation.type,
&data->o_res.delegation.stateid,
data->o_res.delegation.pagemod_limit);
else
nfs_inode_reclaim_delegation(state->inode,
data->owner->so_cred,
data->o_res.delegation.type,
&data->o_res.delegation.stateid,
data->o_res.delegation.pagemod_limit);
if (data->o_res.delegation.do_recall)
nfs_async_inode_return_delegation(state->inode,
&data->o_res.delegation.stateid);
} }
/* /*
...@@ -2022,7 +2010,10 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) ...@@ -2022,7 +2010,10 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
nfs4_opendata_check_deleg(data, state); nfs4_process_delegation(state->inode,
data->owner->so_cred,
data->o_arg.claim,
&data->o_res.delegation);
if (!update_open_stateid(state, &data->o_res.stateid, if (!update_open_stateid(state, &data->o_res.stateid,
NULL, data->o_arg.fmode)) NULL, data->o_arg.fmode))
...@@ -2089,8 +2080,11 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) ...@@ -2089,8 +2080,11 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data)
if (IS_ERR(state)) if (IS_ERR(state))
goto out; goto out;
if (data->o_res.delegation.type != 0) nfs4_process_delegation(state->inode,
nfs4_opendata_check_deleg(data, state); data->owner->so_cred,
data->o_arg.claim,
&data->o_res.delegation);
if (!update_open_stateid(state, &data->o_res.stateid, if (!update_open_stateid(state, &data->o_res.stateid,
NULL, data->o_arg.fmode)) { NULL, data->o_arg.fmode)) {
nfs4_put_open_state(state); nfs4_put_open_state(state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment