From: "J. Bruce Fields" <bfields@fieldses.org>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Jeff Layton <jlayton@redhat.com>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: sunrpc: what prevents an xprt from being freed before task_cleanup runs?
Date: Tue, 3 Aug 2010 14:48:56 -0400 [thread overview]
Message-ID: <20100803184856.GA31579@fieldses.org> (raw)
In-Reply-To: <1280860815.9771.25.camel@heimdal.trondhjem.org>
On Tue, Aug 03, 2010 at 02:40:15PM -0400, Trond Myklebust wrote:
> On Tue, 2010-08-03 at 13:24 -0400, Jeff Layton wrote:
> > We got a report recently about a panic in RHEL5 (2.6.18 based kernel).
> > The problem appears to be that a task_cleanup workqueue job ran and got
> > passed a pointer to an xprt that had been freed. The bug is here in
> > case anyone is interested in the details:
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=611938
> >
> > The situation seems to be pretty difficult to reproduce, but I don't
> > see anything that's intended to ensure that this doesn't occur in RHEL5
> > or mainline. The task_cleanup workqueue job doesn't hold a reference to
> > the xprt, and the job isn't canceled when the xprt is torn down.
> >
> > Bruce had a look and suggested that we may need something like the
> > patch below (pasted in, so it probably won't apply correctly). I've
> > tested a backported version of it on RHEL5 and it seems to work fine.
> >
> > Is it reasonable to cancel task_cleanup when destroying the xprt? Or,
> > am I missing something that should prevent this situation in mainline
> > (and perhaps isn't in RHEL5's kernel).
> >
> > Any help is appreciated...
> >
> > -----------------------------[snip]---------------------------------
> > diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> > index dcd0132..2a1f664 100644
> > --- a/net/sunrpc/xprt.c
> > +++ b/net/sunrpc/xprt.c
> > @@ -1129,6 +1129,7 @@ static void xprt_destroy(struct kref *kref)
> > rpc_destroy_wait_queue(&xprt->sending);
> > rpc_destroy_wait_queue(&xprt->resend);
> > rpc_destroy_wait_queue(&xprt->backlog);
> > + cancel_work_sync(&xprt->task_cleanup);
> > /*
> > * Tear down transport state and free the rpc_xprt
> > */
> > -----------------------------[snip]---------------------------------
> >
> > Thanks,
>
> How about doing a wait_on_bit_lock(&xprt->state, XPRT_LOCKED,...)
> instead?
I'll believe you, but I don't get it: what guarantees that XPRT_LOCKED
isn't cleared while xprt_autoclose autoclose is still running?
--b.
next prev parent reply other threads:[~2010-08-03 18:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 17:24 sunrpc: what prevents an xprt from being freed before task_cleanup runs? Jeff Layton
[not found] ` <20100803132453.4fa18444-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-08-03 18:40 ` Trond Myklebust
2010-08-03 18:48 ` J. Bruce Fields [this message]
[not found] ` <20100803184856.GA31579-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-03 18:56 ` Trond Myklebust
2010-08-03 19:18 ` J. Bruce Fields
[not found] ` <1280860815.9771.25.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-08-03 18:49 ` Trond Myklebust
[not found] ` <1280861363.12283.2.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-08-03 21:22 ` [PATCH] SUNRPC: prevent task_cleanup running on freed xprt J. Bruce Fields
[not found] ` <20100803212220.GI31579-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-03 21:32 ` Trond Myklebust
2010-08-03 18:59 ` sunrpc: what prevents an xprt from being freed before task_cleanup runs? 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=20100803184856.GA31579@fieldses.org \
--to=bfields@fieldses.org \
--cc=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=trond.myklebust@fys.uio.no \
/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).