public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, chris@cvine.freeserve.co.uk,
	linux-kernel@vger.kernel.org
Subject: [PATCH] nfsd: shut down transport in nfsd_init_socks if no lockd reference
Date: Thu, 17 Jun 2010 10:17:46 -0400	[thread overview]
Message-ID: <1276784267-28500-2-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1276784267-28500-1-git-send-email-jlayton@redhat.com>

nfsd_last_thread expects that any socket on sv_permsocks will hold a
lockd reference. Fix nfsd_init_socks to close down any transport that
it creates for which it can't get a lockd reference.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/nfsd/nfssvc.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index a06ea99..f83e6f9 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -278,28 +278,41 @@ int nfsd_create_serv(void)
 static int nfsd_init_socks(int port)
 {
 	int error;
+	char *transport;
+	struct svc_xprt *xprt;
+
 	if (!list_empty(&nfsd_serv->sv_permsocks))
 		return 0;
 
-	error = svc_create_xprt(nfsd_serv, "udp", PF_INET, port,
+	transport = "udp";
+	error = svc_create_xprt(nfsd_serv, transport, PF_INET, port,
 					SVC_SOCK_DEFAULTS);
 	if (error < 0)
 		return error;
 
 	error = lockd_up();
 	if (error < 0)
-		return error;
+		goto out_close_xprt;
 
-	error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
+	transport = "tcp";
+	error = svc_create_xprt(nfsd_serv, transport, PF_INET, port,
 					SVC_SOCK_DEFAULTS);
 	if (error < 0)
 		return error;
 
 	error = lockd_up();
 	if (error < 0)
-		return error;
+		goto out_close_xprt;
 
 	return 0;
+out_close_xprt:
+	/* shut down any transport that didn't get a lockd reference */
+	xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port);
+	if (xprt != NULL) {
+		svc_close_xprt(xprt);
+		svc_xprt_put(xprt);
+	}
+	return error;
 }
 
 int nfsd_nrpools(void)
-- 
1.5.5.6

  reply	other threads:[~2010-06-17 14:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 14:17 [PATCH] nfsd: make sure all sv_permsocks have lockd references Jeff Layton
2010-06-17 14:17 ` Jeff Layton [this message]
2010-06-17 14:17 ` [PATCH] nfsd: have __write_ports_add/delxprt get/put lockd references for transports Jeff Layton
2010-06-17 14:37   ` Jeff Layton

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=1276784267-28500-2-git-send-email-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=chris@cvine.freeserve.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox