All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@primarydata.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 4/6] NFSv4.x: Fix up the global tracking of the callback server
Date: Mon, 29 Aug 2016 20:03:50 -0400	[thread overview]
Message-ID: <1472515432-54202-5-git-send-email-trond.myklebust@primarydata.com> (raw)
In-Reply-To: <1472515432-54202-4-git-send-email-trond.myklebust@primarydata.com>

Ensure that the nfs_callback_info[] array correctly tracks the
struct svc_serv.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/callback.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 08e16f9b3333..b125f02ddf8b 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -201,7 +201,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
 
 	svc_sock_update_bufs(serv);
 
-	cb_info->serv = serv;
 	cb_info->rqst = rqstp;
 	cb_info->task = kthread_create(serv->sv_ops->svo_function,
 				    cb_info->rqst,
@@ -300,7 +299,7 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
 	/*
 	 * Check whether we're already up and running.
 	 */
-	if (cb_info->task) {
+	if (cb_info->serv) {
 		/*
 		 * Note: increase service usage, because later in case of error
 		 * svc_destroy() will be called.
@@ -333,6 +332,7 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
 		printk(KERN_ERR "nfs_callback_create_svc: create service failed\n");
 		return ERR_PTR(-ENOMEM);
 	}
+	cb_info->serv = serv;
 	/* As there is only one thread we need to over-ride the
 	 * default maximum of 80 connections
 	 */
@@ -375,6 +375,8 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
 	 * thread exits.
 	 */
 err_net:
+	if (!cb_info->users)
+		cb_info->serv = NULL;
 	svc_destroy(serv);
 err_create:
 	mutex_unlock(&nfs_callback_mutex);
@@ -396,9 +398,11 @@ void nfs_callback_down(int minorversion, struct net *net)
 	mutex_lock(&nfs_callback_mutex);
 	nfs_callback_down_net(minorversion, cb_info->serv, net);
 	cb_info->users--;
-	if (cb_info->users == 0 && cb_info->task != NULL) {
-		kthread_stop(cb_info->task);
-		dprintk("nfs_callback_down: service stopped\n");
+	if (cb_info->users == 0) {
+		if (cb_info->task != NULL) {
+			kthread_stop(cb_info->task);
+			dprintk("nfs_callback_down: service stopped\n");
+		}
 		svc_exit_thread(cb_info->rqst);
 		dprintk("nfs_callback_down: service destroyed\n");
 		cb_info->serv = NULL;
-- 
2.7.4


  reply	other threads:[~2016-08-30  0:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30  0:03 [PATCH 0/6] NFSv4 backchannel improvements Trond Myklebust
2016-08-30  0:03 ` [PATCH 1/6] NFSv4.x: Fix a refcount leak in nfs_callback_up_net Trond Myklebust
2016-08-30  0:03   ` [PATCH 2/6] NFSv4.x: Set up struct svc_serv_ops for the callback channel Trond Myklebust
2016-08-30  0:03     ` [PATCH 3/6] SUNRPC: Initialise struct svc_serv backchannel fields during __svc_create() Trond Myklebust
2016-08-30  0:03       ` Trond Myklebust [this message]
2016-08-30  0:03         ` [PATCH 5/6] NFSv4.x: Switch to using svc_set_num_threads() to manage the callback threads Trond Myklebust
2016-08-30  0:03           ` [PATCH 6/6] NFSv4.x: Add kernel parameter to control the callback server Trond Myklebust

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=1472515432-54202-5-git-send-email-trond.myklebust@primarydata.com \
    --to=trond.myklebust@primarydata.com \
    --cc=linux-nfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.