From: Jeff Layton <jlayton@redhat.com>
To: NeilBrown <neilb@suse.de>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/3] nfsd: don't take nfsd_mutex twice when setting number of threads.
Date: Thu, 11 Jun 2009 13:52:55 -0400 [thread overview]
Message-ID: <20090611135255.0fa2f728@barsoom.rdu.redhat.com> (raw)
In-Reply-To: <20090528063303.15937.55202.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
On Thu, 28 May 2009 16:33:03 +1000
NeilBrown <neilb@suse.de> wrote:
> Currently when we right a number to 'threads' in nfsdfs,
> we take the nfsd_mutex, update the number of threads, then take the
> mutex again to read the number of threads.
>
> Mostly this isn't a big deal. However if we are write '0', and
> portmap happens to be dead, then we can get unpredictable behaviour.
> If the nfsd threads all got killed quickly and the last thread is
> waiting for portmap to respond, then the second time we take the mutex
> we will block waiting for the last thread.
> However if the nfsd threads didn't die quite that fast, then there
> will be no contention when we try to take the mutex again.
>
> Unpredictability isn't fun, and waiting for the last thread to exit is
> pointless, so avoid taking the lock twice.
> To achieve this, get nfsd_svc return a non-negative number of active
> threads when not returning a negative error.
>
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>
> fs/nfsd/nfsctl.c | 13 +++++++++----
> fs/nfsd/nfssvc.c | 2 ++
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index af16849..1ddd4f9 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -207,10 +207,14 @@ static struct file_operations pool_stats_operations = {
> static ssize_t write_svc(struct file *file, char *buf, size_t size)
> {
> struct nfsctl_svc *data;
> + int err;
> if (size < sizeof(*data))
> return -EINVAL;
> data = (struct nfsctl_svc*) buf;
> - return nfsd_svc(data->svc_port, data->svc_nthreads);
> + err = nfsd_svc(data->svc_port, data->svc_nthreads);
> + if (err < 0)
> + return err;
> + return 0;
> }
>
> /**
> @@ -692,10 +696,11 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
> if (newthreads < 0)
> return -EINVAL;
> rv = nfsd_svc(NFS_PORT, newthreads);
> - if (rv)
> + if (rv < 0)
> return rv;
> - }
> - sprintf(buf, "%d\n", nfsd_nrthreads());
> + } else
> + rv = nfsd_nrthreads();
> + sprintf(buf, "%d\n", rv);
> return strlen(buf);
> }
>
> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> index cbba4a9..df6c59e 100644
> --- a/fs/nfsd/nfssvc.c
> +++ b/fs/nfsd/nfssvc.c
> @@ -413,6 +413,8 @@ nfsd_svc(unsigned short port, int nrservs)
> goto failure;
>
> error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
> + if (error == 0)
> + error = nfsd_serv->sv_nrthreads - 1;
^^^^
Why -1 here? I thought you wanted nfsd_svc to return the number of
threads?
Also, looks like Bruce's tree has changed a bit recently and I don't
think this patch will apply cleanly now. You may need to respin...
> failure:
> svc_destroy(nfsd_serv); /* Release server */
> out:
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2009-06-11 17:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 6:33 [nfsd PATCH 0/3] address issues with shutdown while portmap is dead NeilBrown
[not found] ` <20090528062730.15937.70579.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-05-28 6:33 ` [PATCH 3/3] sunrpc: reduce timeout when unregistering rpcbind registrations NeilBrown
[not found] ` <20090528063303.15937.62423.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-05-28 13:07 ` Tom Talpey
2009-06-11 4:49 ` Neil Brown
[not found] ` <18992.36038.267957.467326-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-06-11 15:02 ` Chuck Lever
2009-05-28 13:43 ` Chuck Lever
2009-06-11 4:48 ` Neil Brown
[not found] ` <18992.35996.986951.556723-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-06-11 15:44 ` Chuck Lever
2009-07-02 20:04 ` Chuck Lever
2009-07-06 12:42 ` Suresh Jayaraman
2009-07-06 14:30 ` Chuck Lever
2009-07-06 16:08 ` Suresh Jayaraman
2009-07-06 16:22 ` Trond Myklebust
2009-07-06 16:31 ` Chuck Lever
2009-07-06 16:40 ` Trond Myklebust
[not found] ` <1246898450.11267.12.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-07-06 16:57 ` Chuck Lever
2009-07-06 17:14 ` Trond Myklebust
[not found] ` <1246900456.11267.34.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-07-06 17:51 ` Chuck Lever
2009-07-06 17:58 ` Trond Myklebust
[not found] ` <1246903105.23966.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-07-06 18:32 ` Chuck Lever
2009-05-28 6:33 ` [PATCH 2/3] nfsd: optimise the starting of zero threads when none are running NeilBrown
[not found] ` <20090528063303.15937.57966.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-06-11 17:26 ` Jeff Layton
2009-05-28 6:33 ` [PATCH 1/3] nfsd: don't take nfsd_mutex twice when setting number of threads NeilBrown
[not found] ` <20090528063303.15937.55202.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2009-06-11 17:52 ` Jeff Layton [this message]
[not found] ` <20090611135255.0fa2f728-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2009-06-11 18:01 ` 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=20090611135255.0fa2f728@barsoom.rdu.redhat.com \
--to=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
/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