From: Neil Brown <neilb@suse.de>
To: Neil Brown <neilb@suse.de>
Cc: "J. Bruce Fields" <bfields@fieldses.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1.5/6] Fix race in new request delay code.
Date: Tue, 21 Sep 2010 18:35:21 +1000 [thread overview]
Message-ID: <20100921183521.4510af63@notabene> (raw)
In-Reply-To: <20100830093608.5936a554@notabene>
On Mon, 30 Aug 2010 09:36:08 +1000
Neil Brown <neilb@suse.de> wrote:
> On Thu, 26 Aug 2010 17:08:00 -0400
> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>
> > On Tue, Aug 17, 2010 at 03:15:09PM +1000, NeilBrown wrote:
> > > If the 'wait_for_completion_interruptible_timeout' completes due
> > > to interrupt or timeout, just before cache_revisit request gets around
> > > to calling ->revisit and thus the completion, we have a race with bad
> > > consequences.
> > >
> > > cache_defer_req will see that sleeper.handle.hash is empty (because
> > > cache_revisit_request has already done the list_del_init), and that
> > > CACHE_PENDING is clear, and so will exit that function leaving any
> > > local variables such as 'sleeper' undefined.
> > >
> > > Meanwhile cache_revisit_request could delete sleeper.handle.recent
> > > from the 'pending' list, and call sleeper.hande.revisit, any of which
> > > could have new garbage values and so could trigger a BUG.
> >
> > Thanks, this looks correct to me!
> >
> > I wish it were simpler, but don't see how right now.
>
> I think the way to make it simpler is to get rid of the deferral altogether.
> The more I think about it the less I like it :-)
I was in the process of doing this "getting rid of deferral" when I
discovered that lockd now uses deferral too (and has done for 4 years! I am
out of touch!!). This is for NFS exporting cluster filesystems where 'lock'
might take a while, but returns a 'grant'.
As lockd is single-threads we cannot just let it wait for the grant
in-process.
So I guess I cannot rip all that code out after all :-(
NeilBrown
>
> The deferral code effectively gives you DFR_MAX extra virtual threads. They
> each are processing one request but have (supposedly) much lower over-head
> than creating real threads. So there are two groups of threads:
> - those that can wait a longish time for a reply to an upcall
> - those that only wait for IO.
>
> This distinction could well still be useful as we don't really want all
> threads to be tied up waiting on upcalls so that no really work can be done.
> However we don't really need the deferral mechanism to achieve this.
>
> Instead we impose a limit on the number of threads that can be in waiting on
> a completion (in cache_wait_req in your revised code).
> If the number of such threads ever reaches - say - half the total, then we
> start dropping requests and closing TCP connections (or start new threads if
> we ever work out a good way to dynamically manage the thread pool).
>
> So I would suggest:
> - putting in a counter and limiting the number of waiting threads to
> half the pool size
> - removing all the deferral code
> - looking at cleaning up what is left to make it more readable.
>
> ???
>
> NeilBrown
next prev parent reply other threads:[~2010-09-21 8:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 7:04 [PATCH 0/6] Cache deferral improvements - try N+2 NeilBrown
2010-08-12 7:04 ` [PATCH 2/6] nfsd/idmap: drop special request deferal in favour of improved default NeilBrown
[not found] ` <20100812070406.11459.89468.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-09-21 21:08 ` J. Bruce Fields
2010-08-12 7:04 ` [PATCH 1/6] sunrpc/cache: allow threads to block while waiting for cache update NeilBrown
2010-08-12 7:04 ` [PATCH 5/6] svcauth_gss: replace a trivial 'switch' with an 'if' NeilBrown
2010-08-12 7:04 ` [PATCH 3/6] sunrpc: close connection when a request is irretrievably lost NeilBrown
2010-09-21 20:53 ` J. Bruce Fields
2010-09-21 23:37 ` Neil Brown
2010-09-22 2:13 ` J. Bruce Fields
2010-08-12 7:04 ` [PATCH 4/6] nfsd: disable deferral for NFSv4 NeilBrown
[not found] ` <20100812070407.11459.2929.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-09-21 21:01 ` J. Bruce Fields
2010-08-12 7:04 ` [PATCH 6/6] sunrpc/cache: change deferred-request hash table to use hlist NeilBrown
[not found] ` <20100812065722.11459.18978.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-08-12 12:03 ` [PATCH 0/6] Cache deferral improvements - try N+2 J. Bruce Fields
2010-08-17 5:15 ` [PATCH 1.5/6] Fix race in new request delay code NeilBrown
2010-08-26 21:08 ` J. Bruce Fields
2010-08-29 23:36 ` Neil Brown
2010-09-01 11:31 ` J. Bruce Fields
2010-09-21 8:35 ` Neil Brown [this message]
2010-09-22 2:15 ` 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=20100921183521.4510af63@notabene \
--to=neilb@suse.de \
--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 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.