Date: Wed, 11 Feb 2009 09:46:45 -0500 From: John Baldwin <jhb@freebsd.org> To: Sean Bruno <sean.bruno@dsl-only.net> Cc: freebsd-current@freebsd.org Subject: Re: [sysctl] New sysctl LoR today Message-ID: <200902110946.46153.jhb@freebsd.org> In-Reply-To: <1234332568.14556.11.camel@localhost.localdomain> References: <1234315393.14556.6.camel@localhost.localdomain> <1234332568.14556.11.camel@localhost.localdomain>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 11 February 2009 1:09:28 am Sean Bruno wrote:
> On Tue, 2009-02-10 at 17:23 -0800, Sean Bruno wrote:
> > I'm working on some items in the firewire stack and after a update, I
> > was greeted with a new LoR against the SYSCTL lock. I noted that some
> > things were changing in that space.
> >
> > Did I miss an interface change that I need to pickup in the firewire
> > stack?
> >
> > Sean
> >
> > lock order reversal: (sleepable after non-sleepable)
> > 1st 0xc471bbec sbp (sbp) @ dev/firewire/sbp.c:2253
> > 2nd 0xc0d3aea4 sysctl lock (sysctl lock) @ kern/kern_sysctl.c:250
> > KDB: stack backtrace:
> > _sx_xlock(c0d3aea4,0,c0be5d46,fa,c471a000,...) at _sx_xlock+0x85
> > sysctl_ctx_free(c471a2c0,c0b8f786,c0d0696c,0,c469fa0c,...) at
> > sysctl_ctx_free+0x30
> > dacleanup(c4c54700,c0b900bb,c480e000,c42aa410,246,...) at dacleanup+0x35
> > camperiphfree(c4c54700,c4c54700,c42aa694,c047763d,c4c54700,...) at
No, this is due to CAM calling sysctl_ctx_free() with a lock held. You can
try this change:
--- //depot/user/jhb/lock/cam/scsi/scsi_cd.c
+++ /home/jhb/work/p4/lock/cam/scsi/scsi_cd.c
@@ -401,11 +401,6 @@
xpt_print(periph->path, "removing device entry\n");
- if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
- && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
- xpt_print(periph->path, "can't remove sysctl context\n");
- }
-
/*
* In the queued, non-active case, the device in question
* has already been removed from the changer run queue. Since this
@@ -474,9 +469,14 @@
free(softc->changer, M_DEVBUF);
}
cam_periph_unlock(periph);
+ if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
+ && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
+ xpt_print(periph->path, "can't remove sysctl context\n");
+ }
+
disk_destroy(softc->disk);
+ free(softc, M_DEVBUF);
cam_periph_lock(periph);
- free(softc, M_DEVBUF);
}
static void
--- //depot/user/jhb/lock/cam/scsi/scsi_da.c
+++ /home/jhb/work/p4/lock/cam/scsi/scsi_da.c
@@ -995,6 +995,8 @@
softc = (struct da_softc *)periph->softc;
xpt_print(periph->path, "removing device entry\n");
+ cam_periph_unlock(periph);
+
/*
* If we can't free the sysctl tree, oh well...
*/
@@ -1003,11 +1005,10 @@
xpt_print(periph->path, "can't remove sysctl context\n");
}
- cam_periph_unlock(periph);
disk_destroy(softc->disk);
callout_drain(&softc->sendordered_c);
+ free(softc, M_DEVBUF);
cam_periph_lock(periph);
- free(softc, M_DEVBUF);
}
static void
--
John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902110946.46153.jhb>
