Commit 3e309914 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Clean up _nfs4_proc_open()

Use a flag instead of the 'data->rpc_status = -ENOMEM hack.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 1b370bc2
...@@ -226,6 +226,7 @@ struct nfs4_opendata { ...@@ -226,6 +226,7 @@ struct nfs4_opendata {
struct nfs4_state_owner *owner; struct nfs4_state_owner *owner;
struct iattr attrs; struct iattr attrs;
unsigned long timestamp; unsigned long timestamp;
unsigned int rpc_done : 1;
int rpc_status; int rpc_status;
int cancelled; int cancelled;
}; };
...@@ -620,6 +621,7 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) ...@@ -620,6 +621,7 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
memcpy(data->o_res.stateid.data, data->c_res.stateid.data, memcpy(data->o_res.stateid.data, data->c_res.stateid.data,
sizeof(data->o_res.stateid.data)); sizeof(data->o_res.stateid.data));
renew_lease(data->o_res.server, data->timestamp); renew_lease(data->o_res.server, data->timestamp);
data->rpc_done = 1;
} }
nfs_confirm_seqid(&data->owner->so_seqid, data->rpc_status); nfs_confirm_seqid(&data->owner->so_seqid, data->rpc_status);
nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid); nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid);
...@@ -634,7 +636,7 @@ static void nfs4_open_confirm_release(void *calldata) ...@@ -634,7 +636,7 @@ static void nfs4_open_confirm_release(void *calldata)
if (data->cancelled == 0) if (data->cancelled == 0)
goto out_free; goto out_free;
/* In case of error, no cleanup! */ /* In case of error, no cleanup! */
if (data->rpc_status != 0) if (!data->rpc_done)
goto out_free; goto out_free;
nfs_confirm_seqid(&data->owner->so_seqid, 0); nfs_confirm_seqid(&data->owner->so_seqid, 0);
state = nfs4_opendata_to_nfs4_state(data); state = nfs4_opendata_to_nfs4_state(data);
...@@ -660,11 +662,8 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data) ...@@ -660,11 +662,8 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
int status; int status;
kref_get(&data->kref); kref_get(&data->kref);
/* data->rpc_done = 0;
* If rpc_run_task() ends up calling ->rpc_release(), we data->rpc_status = 0;
* want to ensure that it takes the 'error' code path.
*/
data->rpc_status = -ENOMEM;
task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data); task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data);
if (IS_ERR(task)) if (IS_ERR(task))
return PTR_ERR(task); return PTR_ERR(task);
...@@ -725,6 +724,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata) ...@@ -725,6 +724,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
nfs_confirm_seqid(&data->owner->so_seqid, 0); nfs_confirm_seqid(&data->owner->so_seqid, 0);
} }
nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid); nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid);
data->rpc_done = 1;
} }
static void nfs4_open_release(void *calldata) static void nfs4_open_release(void *calldata)
...@@ -736,7 +736,7 @@ static void nfs4_open_release(void *calldata) ...@@ -736,7 +736,7 @@ static void nfs4_open_release(void *calldata)
if (data->cancelled == 0) if (data->cancelled == 0)
goto out_free; goto out_free;
/* In case of error, no cleanup! */ /* In case of error, no cleanup! */
if (data->rpc_status != 0) if (data->rpc_status != 0 || !data->rpc_done)
goto out_free; goto out_free;
/* In case we need an open_confirm, no cleanup! */ /* In case we need an open_confirm, no cleanup! */
if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM)
...@@ -768,11 +768,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) ...@@ -768,11 +768,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
int status; int status;
kref_get(&data->kref); kref_get(&data->kref);
/* data->rpc_done = 0;
* If rpc_run_task() ends up calling ->rpc_release(), we data->rpc_status = 0;
* want to ensure that it takes the 'error' code path.
*/
data->rpc_status = -ENOMEM;
data->cancelled = 0; data->cancelled = 0;
task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data); task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data);
if (IS_ERR(task)) if (IS_ERR(task))
...@@ -784,7 +781,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) ...@@ -784,7 +781,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
} else } else
status = data->rpc_status; status = data->rpc_status;
rpc_put_task(task); rpc_put_task(task);
if (status != 0) if (status != 0 || !data->rpc_done)
return status; return status;
if (o_arg->open_flags & O_CREAT) { if (o_arg->open_flags & O_CREAT) {
......
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