Skip to content

Commit

Permalink
NFSv4: Fix second deadlock in nfs4_evict_inode()
Browse files Browse the repository at this point in the history
commit c3aba89 upstream.

If the inode is being evicted but has to return a layout first, then
that too can cause a deadlock in the corner case where the server
reboots.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Trond Myklebust authored and gregkh committed Jun 16, 2021
1 parent c3b6cf6 commit d973bd0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/nfs/nfs4proc.c
Expand Up @@ -9629,15 +9629,20 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
&task_setup_data.rpc_client, &msg);

dprintk("--> %s\n", __func__);
lrp->inode = nfs_igrab_and_active(lrp->args.inode);
if (!sync) {
lrp->inode = nfs_igrab_and_active(lrp->args.inode);
if (!lrp->inode) {
nfs4_layoutreturn_release(lrp);
return -EAGAIN;
}
task_setup_data.flags |= RPC_TASK_ASYNC;
}
nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, 0);
if (!lrp->inode)
nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1,
1);
else
nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1,
0);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
Expand Down

0 comments on commit d973bd0

Please sign in to comment.