From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-nfs@vger.kernel.org, nfsv4@linux-nfs.org, neilb@suse.de,
gnb-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org
Subject: Re: [PATCH 4/5] knfsd: convert knfsd to kthread API
Date: Fri, 6 Jun 2008 15:13:14 -0400 [thread overview]
Message-ID: <20080606191314.GD761@fieldses.org> (raw)
In-Reply-To: <20080606150537.14c9537c-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
On Fri, Jun 06, 2008 at 03:05:37PM -0400, Jeff Layton wrote:
> On Fri, 6 Jun 2008 14:16:12 -0400
> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>
> > On Fri, Jun 06, 2008 at 02:11:16PM -0400, Jeff Layton wrote:
> > > I think I've goofed this part, actually. I was thinking that we didn't
> > > need to bump the refcount here, and that the kernel would realize that
> > > nfsd() hadn't returned and would prevent unloading until it had. This
> > > doesn't seem to be the case. I'll need to go back and add refcounting
> > > back in.
> >
> > OK. If you decide it is needed here, could you double-check the lockd
> > conversion as well? Looks like some refcounting logic might have gotten
> > lost there too.
> >
> > --b.
>
> Full disclosure:
>
> I don't completely understand module refcounts and when we need to take
> a reference. So feel free to set me straight if my comments below are
> wrong :-)
>
> The change to lockd was deliberate and was suggested by Neil Brown, when
> I was working on an earlier version of the lockd-kthread patch:
>
> --------------[snip]------------------
>
> > - module_put_and_exit(0);
> > + module_put(THIS_MODULE);
> > + return 0;
>
> This changes bothers me. Putting the last ref to a module in code
> inside that module is not safe, which is why module_put_and_exit
> exists.
>
> So this module_put is either unsafe or not needed. I think the
> latter.
>
> As you say in the comment, lockd_down now blocks until lockd actually
> exits. As every caller for lockd_down will own a reference to the
> lockd module, the lockd thread no longer needs to own a reference too.
> So I think it is safe to remove the module_put, and also remove the
> __module_get at the top of the lockd function.
>
> --------------[snip]------------------
>
> So I followed his advice and everything seems to be OK. I don't see a way
> to yank out the lockd module while lockd is actually up, since the
> callers of lockd_up() have to have a reference to the lockd module, and
> if those modules go away, then lockd should be down anyway.
Yes, thanks for the reminder--that makes sense.
> This is what led me to think that we didn't need this for nfsd either,
> but that seems to be incorrect. I think nfsd is different because it's
> started directly from userspace. We don't have any persistent module
> references so we need to take them explicitly.
Right.
--b.
next prev parent reply other threads:[~2008-06-06 19:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-06 15:12 [PATCH 0/5] Convert knfsd to kthread API and fix startup/shutdown races (try #3) Jeff Layton
2008-06-06 15:12 ` [PATCH 1/5] knfsd: Replace lock_kernel with a mutex for nfsd thread startup/shutdown locking Jeff Layton
2008-06-06 15:12 ` [PATCH 2/5] knfsd: clean up nfsd filesystem interfaces Jeff Layton
2008-06-06 15:12 ` [PATCH 3/5] knfsd: remove special handling for SIGHUP Jeff Layton
2008-06-06 15:12 ` [PATCH 4/5] knfsd: convert knfsd to kthread API Jeff Layton
2008-06-06 15:12 ` [PATCH 5/5] sunrpc: remove unneeded fields from svc_serv struct Jeff Layton
2008-06-06 17:24 ` [PATCH 4/5] knfsd: convert knfsd to kthread API J. Bruce Fields
2008-06-06 18:11 ` Jeff Layton
2008-06-06 18:16 ` J. Bruce Fields
2008-06-06 19:05 ` Jeff Layton
[not found] ` <20080606150537.14c9537c-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-06 19:13 ` J. Bruce Fields [this message]
2008-06-06 19:49 ` Jeff Layton
[not found] ` <20080606154948.303aba28-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-09 13:08 ` J. Bruce Fields
2008-06-09 13:19 ` Jeff Layton
[not found] ` <20080609091948.0b2b19a9-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-09 18:39 ` J. Bruce Fields
2008-06-09 18:54 ` Jeff Layton
[not found] ` <20080609145459.1adda51a-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-10 10:50 ` Greg Banks
-- strict thread matches above, loose matches on Subject: below --
2008-06-10 12:40 [PATCH 0/5] Convert knfsd to kthread API and fix startup/shutdown races (try #4) Jeff Layton
2008-06-10 12:40 ` [PATCH 1/5] knfsd: Replace lock_kernel with a mutex for nfsd thread startup/shutdown locking Jeff Layton
2008-06-10 12:40 ` [PATCH 2/5] knfsd: clean up nfsd filesystem interfaces Jeff Layton
2008-06-10 12:40 ` [PATCH 3/5] knfsd: remove special handling for SIGHUP Jeff Layton
2008-06-10 12:40 ` [PATCH 4/5] knfsd: convert knfsd to kthread API Jeff Layton
2008-06-10 16:24 ` J. Bruce Fields
2008-06-10 16:25 ` J. Bruce Fields
2008-06-10 17:06 ` Jeff Layton
2008-06-10 20:05 ` J. Bruce Fields
2008-06-10 20:19 ` 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=20080606191314.GD761@fieldses.org \
--to=bfields@fieldses.org \
--cc=gnb-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org \
--cc=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=nfsv4@linux-nfs.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