pNFS: Always free the session slot on error in nfs4_layoutget_handle_exception
Right now, we can call nfs_commit_inode() while holding the session slot, which could lead to NFSv4 deadlocks. Ensure we only keep the slot if the server returned a layout that we have to process. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
d5681f59ee
commit
2dbf8dffbf
|
@ -8650,6 +8650,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
|
||||||
|
|
||||||
dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
|
dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
|
||||||
|
|
||||||
|
nfs4_sequence_free_slot(&lgp->res.seq_res);
|
||||||
|
|
||||||
switch (nfs4err) {
|
switch (nfs4err) {
|
||||||
case 0:
|
case 0:
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -8714,7 +8716,6 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfs4_sequence_free_slot(&lgp->res.seq_res);
|
|
||||||
err = nfs4_handle_exception(server, nfs4err, exception);
|
err = nfs4_handle_exception(server, nfs4err, exception);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
if (exception->retry)
|
if (exception->retry)
|
||||||
|
@ -8786,20 +8787,22 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout)
|
||||||
if (IS_ERR(task))
|
if (IS_ERR(task))
|
||||||
return ERR_CAST(task);
|
return ERR_CAST(task);
|
||||||
status = rpc_wait_for_completion_task(task);
|
status = rpc_wait_for_completion_task(task);
|
||||||
if (status == 0) {
|
if (status != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
|
||||||
|
if (task->tk_status < 0 || lgp->res.layoutp->len == 0) {
|
||||||
status = nfs4_layoutget_handle_exception(task, lgp, &exception);
|
status = nfs4_layoutget_handle_exception(task, lgp, &exception);
|
||||||
*timeout = exception.timeout;
|
*timeout = exception.timeout;
|
||||||
}
|
} else
|
||||||
|
lseg = pnfs_layout_process(lgp);
|
||||||
|
out:
|
||||||
trace_nfs4_layoutget(lgp->args.ctx,
|
trace_nfs4_layoutget(lgp->args.ctx,
|
||||||
&lgp->args.range,
|
&lgp->args.range,
|
||||||
&lgp->res.range,
|
&lgp->res.range,
|
||||||
&lgp->res.stateid,
|
&lgp->res.stateid,
|
||||||
status);
|
status);
|
||||||
|
|
||||||
/* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
|
|
||||||
if (status == 0 && lgp->res.layoutp->len)
|
|
||||||
lseg = pnfs_layout_process(lgp);
|
|
||||||
rpc_put_task(task);
|
rpc_put_task(task);
|
||||||
dprintk("<-- %s status=%d\n", __func__, status);
|
dprintk("<-- %s status=%d\n", __func__, status);
|
||||||
if (status)
|
if (status)
|
||||||
|
|
Loading…
Reference in New Issue