Re: [sysctl] New sysctl LoR today

From: Sean Bruno <sean.bruno_at_dsl-only.net>
Date: Wed, 11 Feb 2009 08:26:23 -0800
On Wed, 2009-02-11 at 09:46 -0500, John Baldwin wrote:
> 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) _at_ dev/firewire/sbp.c:2253
> > >  2nd 0xc0d3aea4 sysctl lock (sysctl lock) _at_ 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
> _at__at_ -401,11 +401,6 _at__at_
>  
>  	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
> _at__at_ -474,9 +469,14 _at__at_
>  		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
> _at__at_ -995,6 +995,8 _at__at_
>  	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...
>  	 */
> _at__at_ -1003,11 +1005,10 _at__at_
>  		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
> 
> 


Yup.  Thanks for the quick fix!

Sean
Received on Wed Feb 11 2009 - 15:26:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:42 UTC