From: Jeff Layton <jlayton@redhat.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 5/5] nfsd: just keep single lockd reference for nfsd
Date: Mon, 19 Jul 2010 16:50:08 -0400 [thread overview]
Message-ID: <1279572608-7234-6-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1279572608-7234-1-git-send-email-jlayton@redhat.com>
This patch should replace the other patches that I proposed to make
sure that each sv_permsock entry holds a lockd refrence.
Right now, nfsd keeps a lockd reference for each socket that it has
open. This is unnecessary and complicates the error handling on
startup and shutdown. Change it to just do a lockd_up when creating
the nfsd_serv and just do a single lockd_down when taking down the
last nfsd thread.
This patch also changes the error handling in nfsd_create_serv a
bit too. There doesn't seem to be any need to reset the nfssvc_boot
time if the nfsd startup failed.
Note though that this does change the user-visible behavior slightly.
Today when someone writes a text socktype and port to the portlist file
prior to starting nfsd, lockd is not started when nfsd threads are
brought up. With this change, it will be started any time that
the nfsd_serv is created. I'm making the assumption that that's not a
problem. If it is then we'll need to take a different approach to fixing
this.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/nfsd/nfsctl.c | 10 ----------
fs/nfsd/nfssvc.c | 25 ++++++++++---------------
2 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 9e8645a..b1c5be8 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -949,15 +949,8 @@ static ssize_t __write_ports_addfd(char *buf)
if (err != 0)
return err;
- err = lockd_up();
- if (err != 0) {
- svc_destroy(nfsd_serv);
- return err;
- }
-
err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
if (err < 0) {
- lockd_down();
svc_destroy(nfsd_serv);
return err;
}
@@ -982,9 +975,6 @@ static ssize_t __write_ports_delfd(char *buf)
if (nfsd_serv != NULL)
len = svc_sock_names(nfsd_serv, buf,
SIMPLE_TRANSACTION_LIMIT, toclose);
- if (len >= 0)
- lockd_down();
-
kfree(toclose);
return len;
}
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index a06ea99..6b59d32 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -183,9 +183,7 @@ int nfsd_nrthreads(void)
static void nfsd_last_thread(struct svc_serv *serv)
{
/* When last nfsd thread exits we need to do some clean-up */
- struct svc_xprt *xprt;
- list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list)
- lockd_down();
+ lockd_down();
nfsd_serv = NULL;
nfsd_racache_shutdown();
nfs4_state_shutdown();
@@ -264,13 +262,18 @@ int nfsd_create_serv(void)
nfsd_max_blksize /= 2;
}
+ err = lockd_up();
+ if (err != 0)
+ return err;
+
nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
nfsd_last_thread, nfsd, THIS_MODULE);
- if (nfsd_serv == NULL)
- err = -ENOMEM;
- else
- set_max_drc();
+ if (nfsd_serv == NULL) {
+ lockd_down();
+ return -ENOMEM;
+ }
+ set_max_drc();
do_gettimeofday(&nfssvc_boot); /* record boot time */
return err;
}
@@ -286,19 +289,11 @@ static int nfsd_init_socks(int port)
if (error < 0)
return error;
- error = lockd_up();
- if (error < 0)
- return error;
-
error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
SVC_SOCK_DEFAULTS);
if (error < 0)
return error;
- error = lockd_up();
- if (error < 0)
- return error;
-
return 0;
}
--
1.5.5.6
next prev parent reply other threads:[~2010-07-19 20:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-19 20:50 [PATCH 0/5] nfsd: fix error handling in write_ports interfaces (resend) Jeff Layton
2010-07-19 20:50 ` [PATCH 1/5] nfsd: don't try to shut down nfs4 state handling unless it's up Jeff Layton
2010-07-19 22:08 ` J. Bruce Fields
2010-07-20 0:54 ` Jeff Layton
2010-07-19 20:50 ` [PATCH 2/5] nfsd: fix error handling when starting nfsd with rpcbind down Jeff Layton
2010-07-19 20:50 ` [PATCH 3/5] nfsd: fix error handling in __write_ports_addxprt Jeff Layton
2010-07-19 20:50 ` [PATCH 4/5] nfsd: shut down NFSv4 state when nfsd_svc encounters an error Jeff Layton
2010-07-19 20:50 ` Jeff Layton [this message]
2010-07-20 15:02 ` [PATCH 5/5] nfsd: just keep single lockd reference for nfsd J. Bruce Fields
2010-07-20 15:43 ` Jeff Layton
2010-07-20 14:55 ` [PATCH 0/5] nfsd: fix error handling in write_ports interfaces (resend) J. Bruce Fields
2010-07-20 15:43 ` Jeff Layton
2010-07-20 15:56 ` J. Bruce Fields
2010-07-20 15:43 ` J. Bruce Fields
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=1279572608-7234-6-git-send-email-jlayton@redhat.com \
--to=jlayton@redhat.com \
--cc=bfields@fieldses.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;
as well as URLs for NNTP newsgroup(s).