NFSv4.1: Pin the inode and super block in asynchronous layoutreturns
authorTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 5 Feb 2015 21:35:16 +0000 (16:35 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Fri, 6 Feb 2015 03:16:45 +0000 (22:16 -0500)
If we're sending an asynchronous layoutreturn, then we need to ensure
that the inode and the super block remain pinned.

Cc: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: Peng Tao <tao.peng@primarydata.com>
fs/nfs/nfs4proc.c
include/linux/nfs_xdr.h

index e092b8540e2e162b88b66c36c0e4e92668ea3cb8..2e7c9f7a6f7cc8369bfcefda7a202d34f7a9dbe5 100644 (file)
@@ -7856,6 +7856,7 @@ static void nfs4_layoutreturn_release(void *calldata)
        lo->plh_block_lgets--;
        spin_unlock(&lo->plh_inode->i_lock);
        pnfs_put_layout_hdr(lrp->args.layout);
+       nfs_iput_and_deactive(lrp->inode);
        kfree(calldata);
        dprintk("<-- %s\n", __func__);
 }
@@ -7880,23 +7881,25 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
                .rpc_message = &msg,
                .callback_ops = &nfs4_layoutreturn_call_ops,
                .callback_data = lrp,
-               .flags = RPC_TASK_ASYNC,
        };
        int status = 0;
 
        dprintk("--> %s\n", __func__);
+       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);
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return PTR_ERR(task);
-       if (sync == false)
-               goto out;
-       status = nfs4_wait_for_completion_rpc_task(task);
-       if (status != 0)
-               goto out;
-       status = task->tk_status;
+       if (sync)
+               status = task->tk_status;
        trace_nfs4_layoutreturn(lrp->args.inode, status);
-out:
        dprintk("<-- %s status=%d\n", __func__, status);
        rpc_put_task(task);
        return status;
index bb0d56f737e01b818fe87602d9f0ba0fb0da62de..38d96ba935c2d7fd91aaf444a598b832b1c0ee4e 100644 (file)
@@ -310,6 +310,7 @@ struct nfs4_layoutreturn {
        struct nfs4_layoutreturn_res res;
        struct rpc_cred *cred;
        struct nfs_client *clp;
+       struct inode *inode;
        int rpc_status;
 };