Linux NFS development
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@primarydata.com>
To: linux-nfs@vger.kernel.org
Cc: Peng Tao <tao.peng@primarydata.com>
Subject: [PATCH 1/5] NFSv4: Ensure we reference the inode for return-on-close in delegreturn
Date: Thu,  5 Feb 2015 17:37:07 -0500	[thread overview]
Message-ID: <1423175831-54558-1-git-send-email-trond.myklebust@primarydata.com> (raw)

If we have to do a return-on-close in the delegreturn code, then
we must ensure that the inode and super block remain referenced.

Cc: Peng Tao <tao.peng@primarydata.com>
Cc: stable@vger.kernel.org # 3.17.x
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/nfs4proc.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index cd4295d84d54..b803c1d363e7 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5175,9 +5175,16 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
 static void nfs4_delegreturn_release(void *calldata)
 {
 	struct nfs4_delegreturndata *data = calldata;
+	struct inode *inode = data->inode;
+
+	if (inode) {
+		struct super_block *sb = inode->i_sb;
 
-	if (data->roc)
-		pnfs_roc_release(data->inode);
+		if (data->roc)
+			pnfs_roc_release(inode);
+		iput(inode);
+		nfs_sb_deactive(sb);
+	}
 	kfree(calldata);
 }
 
@@ -5234,9 +5241,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
 	nfs_fattr_init(data->res.fattr);
 	data->timestamp = jiffies;
 	data->rpc_status = 0;
-	data->inode = inode;
-	data->roc = list_empty(&NFS_I(inode)->open_files) ?
-		    pnfs_roc(inode) : false;
+	data->inode = igrab(inode);
+	if (data->inode) {
+		nfs_sb_active(inode->i_sb);
+		data->roc = nfs4_roc(inode);
+	}
 
 	task_setup_data.callback_data = data;
 	msg.rpc_argp = &data->args;
-- 
2.1.0


             reply	other threads:[~2015-02-05 22:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 22:37 Trond Myklebust [this message]
2015-02-05 22:37 ` [PATCH 2/5] NFSv4.1: Pin the inode and super block in asynchronous layoutcommit Trond Myklebust
2015-02-05 22:37   ` [PATCH 3/5] NFSv4.1: Pin the inode and super block in asynchronous layoutreturns Trond Myklebust
2015-02-05 22:37     ` [PATCH 4/5] NFSv4.1: pnfs_send_layoutreturn should use GFP_NOFS Trond Myklebust
2015-02-05 22:37       ` [PATCH 5/5] NFSv4.1: Fix pnfs_put_lseg races Trond Myklebust
2015-02-06  2:03   ` [PATCH 2/5] NFSv4.1: Pin the inode and super block in asynchronous layoutcommit Peng Tao
2015-02-06  1:45 ` [PATCH 1/5] NFSv4: Ensure we reference the inode for return-on-close in delegreturn Peng Tao
2015-02-06  1:57   ` Peng Tao
2015-02-06  2:53     ` Trond Myklebust
2015-02-06  3:05       ` Peng Tao
2015-02-06  2:54     ` Peng Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423175831-54558-1-git-send-email-trond.myklebust@primarydata.com \
    --to=trond.myklebust@primarydata.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tao.peng@primarydata.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox