Commit 472e2594 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: Pin the inode and super block in asynchronous layoutcommit

If we're sending an asynchronous layoutcommit, then we need to ensure
that the inode and the super block remain pinned.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: default avatarPeng Tao <tao.peng@primarydata.com>
parent ea7c38fe
...@@ -7989,6 +7989,7 @@ static void nfs4_layoutcommit_release(void *calldata) ...@@ -7989,6 +7989,7 @@ static void nfs4_layoutcommit_release(void *calldata)
nfs_post_op_update_inode_force_wcc(data->args.inode, nfs_post_op_update_inode_force_wcc(data->args.inode,
data->res.fattr); data->res.fattr);
put_rpccred(data->cred); put_rpccred(data->cred);
nfs_iput_and_deactive(data->inode);
kfree(data); kfree(data);
} }
...@@ -8013,7 +8014,6 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) ...@@ -8013,7 +8014,6 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)
.rpc_message = &msg, .rpc_message = &msg,
.callback_ops = &nfs4_layoutcommit_ops, .callback_ops = &nfs4_layoutcommit_ops,
.callback_data = data, .callback_data = data,
.flags = RPC_TASK_ASYNC,
}; };
struct rpc_task *task; struct rpc_task *task;
int status = 0; int status = 0;
...@@ -8024,18 +8024,21 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) ...@@ -8024,18 +8024,21 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)
data->args.lastbytewritten, data->args.lastbytewritten,
data->args.inode->i_ino); data->args.inode->i_ino);
if (!sync) {
data->inode = nfs_igrab_and_active(data->args.inode);
if (data->inode == NULL) {
nfs4_layoutcommit_release(data);
return -EAGAIN;
}
task_setup_data.flags = RPC_TASK_ASYNC;
}
nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
task = rpc_run_task(&task_setup_data); task = rpc_run_task(&task_setup_data);
if (IS_ERR(task)) if (IS_ERR(task))
return PTR_ERR(task); return PTR_ERR(task);
if (sync == false) if (sync)
goto out;
status = nfs4_wait_for_completion_rpc_task(task);
if (status != 0)
goto out;
status = task->tk_status; status = task->tk_status;
trace_nfs4_layoutcommit(data->args.inode, status); trace_nfs4_layoutcommit(data->args.inode, status);
out:
dprintk("%s: status %d\n", __func__, status); dprintk("%s: status %d\n", __func__, status);
rpc_put_task(task); rpc_put_task(task);
return status; return status;
......
...@@ -285,6 +285,7 @@ struct nfs4_layoutcommit_data { ...@@ -285,6 +285,7 @@ struct nfs4_layoutcommit_data {
struct nfs_fattr fattr; struct nfs_fattr fattr;
struct list_head lseg_list; struct list_head lseg_list;
struct rpc_cred *cred; struct rpc_cred *cred;
struct inode *inode;
struct nfs4_layoutcommit_args args; struct nfs4_layoutcommit_args args;
struct nfs4_layoutcommit_res res; struct nfs4_layoutcommit_res res;
}; };
......
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