List Info

Thread: scsi_target witness lock error




scsi_target witness lock error
country flaguser name
United States
2007-12-11 18:53:15
While I was debugging some random stuff with the firewire
target, I
noted the following witness lock:

http
://www.consultcsg.com/scsitarget_witness.txt

It looks like there is some kind of conflict between the
locks in
sys/cam/scsi/scsi_target.c and the kern environment locks? 
I'm fairly
certain that this is an easy fix, but I just don't see how
to work
around it.

Sean

_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

Re: scsi_target witness lock error
country flaguser name
Japan
2007-12-11 19:31:41
Hi Sean,

At Tue, 11 Dec 2007 16:53:15 -0800,
Sean Bruno wrote:
> 
> While I was debugging some random stuff with the
firewire target, I
> noted the following witness lock:
> 
> http
://www.consultcsg.com/scsitarget_witness.txt
> 
> It looks like there is some kind of conflict between
the locks in
> sys/cam/scsi/scsi_target.c and the kern environment
locks?  I'm fairly
> certain that this is an easy fix, but I just don't see
how to work
> around it.
> 
> Sean

This a patch I sent Scott several months ago.
It may help you. (this is for -current at that time)

/ Hidetoshi Shimokawa
/  simokawaFreeBSD.ORG

Subject: scsi_target and WITNESS
From: Hidetoshi Shimokawa <simokawaFreeBSD.ORG>
Date: Fri, 01 Jun 2007 11:57:50 +0900
Message-ID: <86vee8pej5.wl%simokawaFreeBSD.ORG>

Hi Scott,

scsi_target seems to have several problems with WITNESS and
MPSAFE sim.

I applied the following patch to workaround
recurse/sleep/pagefault
problems. I think you should have a better fix.

=============================================
(cd /usr/src && patch -p6) < diff_to_current
=============================================
---
//depot/vendor/freebsd/src/sys/cam/scsi/scsi_target.c	2007/0
4/15 08:53:22
+++
//depot/user/simokawa/firewire_lock/sys/cam/scsi/scsi_target
.c	2007/05/21 14:31:55
 -372,10
+372,14 
 	int	retval;
 
 	softc = (struct targ_softc *)kn->kn_hook;
+#if 0
 	cam_periph_lock(softc->periph);
+#endif
 	retval = !TAILQ_EMPTY(&softc->user_ccb_queue) ||
 		 !TAILQ_EMPTY(&softc->abort_queue);
+#if 0
 	cam_periph_unlock(softc->periph);
+#endif
 	return (retval);
 }
 
 -585,12
+589,12 
 			cam_periph_unlock(softc->periph);
 			break;
 		default:
-			cam_periph_lock(softc->periph);
 			if ((func_code & XPT_FC_QUEUED) != 0) {
 				CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
 					  ("Sending queued ccb %#x (%p)n",
 					  func_code, user_ccb));
 				descr = targgetdescr(softc);
+				cam_periph_lock(softc->periph);
 				descr->user_ccb = user_ccb;
 				descr->priority = priority;
 				descr->func_code = func_code;
 -601,6
+605,7 
 				CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
 					  ("Sending inline ccb %#x (%p)n",
 					  func_code, user_ccb));
+				cam_periph_lock(softc->periph);
 				ccb = targgetccb(softc, func_code, priority);
 				descr = (struct targ_cmd_descr *)
 					 ccb->ccb_h.targ_descr;
 -762,7
+767,9 
 	    && ((ccb_h->flags & CAM_DIR_MASK) !=
CAM_DIR_NONE))
 	  || (ccb_h->func_code == XPT_DEV_MATCH))) {
 
+		cam_periph_unlock(softc->periph);
 		error = cam_periph_mapmem(ccb, mapinfo);
+		cam_periph_lock(softc->periph);
 
 		/*
 		 * cam_periph_mapmem returned an error, we can't
continue.
 -966,13
+973,16 
 	int ccb_len;
 
 	ccb_len = targccblen(type);
+	/* XXX */
+	cam_periph_unlock(softc->periph);
 	MALLOC(ccb, union ccb *, ccb_len, M_TARG, M_WAITOK);
+	ccb->ccb_h.targ_descr = targgetdescr(softc);
+	cam_periph_lock(softc->periph);
 	CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb
%pn", ccb));
 
 	xpt_setup_ccb(&ccb->ccb_h, softc->path,
priority);
 	ccb->ccb_h.func_code = type;
 	ccb->ccb_h.cbfcnp = targdone;
-	ccb->ccb_h.targ_descr = targgetdescr(softc);
 	return (ccb);
 }
 
 -1099,6
+1109,7 
 static void
 notify_user(struct targ_softc *softc)
 {
+        mtx_assert(softc->periph->sim->mtx,
MA_OWNED);
 	/*
 	 * Notify users sleeping via poll(), kqueue(), and
 	 * blocking read().


_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

Re: scsi_target witness lock error
country flaguser name
United States
2007-12-11 20:15:59
> ---
//depot/vendor/freebsd/src/sys/cam/scsi/scsi_target.c	2007/0
4/15 08:53:22
> +++
//depot/user/simokawa/firewire_lock/sys/cam/scsi/scsi_target
.c	2007/05/21 14:31:55
>  -372,10 +372,14 
>  	int	retval;
>  
>  	softc = (struct targ_softc *)kn->kn_hook;
> +#if 0
>  	cam_periph_lock(softc->periph);
> +#endif
>  	retval = !TAILQ_EMPTY(&softc->user_ccb_queue)
||
>  		 !TAILQ_EMPTY(&softc->abort_queue);
> +#if 0
>  	cam_periph_unlock(softc->periph);
> +#endif
>  	return (retval);
>  }
Are these two "if 0"'s supposed to be commented
out?  I'm leaving this
out of my RELENG_6 test for now unless you say otherwise.


Sean

_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

Re: scsi_target witness lock error
user name
2007-12-11 20:37:12
On 12/12/07, Sean Bruno <sbrunomiralink.com> wrote:
> > ---
//depot/vendor/freebsd/src/sys/cam/scsi/scsi_target.c    
2007/04/15 08:53:22
> > +++
//depot/user/simokawa/firewire_lock/sys/cam/scsi/scsi_target
.c    2007/05/21 14:31:55
> >  -372,10 +372,14 
> >       int     retval;
> >
> >       softc = (struct targ_softc
*)kn->kn_hook;
> > +#if 0
> >       cam_periph_lock(softc->periph);
> > +#endif
> >       retval =
!TAILQ_EMPTY(&softc->user_ccb_queue) ||
> >               
!TAILQ_EMPTY(&softc->abort_queue);
> > +#if 0
> >       cam_periph_unlock(softc->periph);
> > +#endif
> >       return (retval);
> >  }
> Are these two "if 0"'s supposed to be
commented out?  I'm leaving this
> out of my RELENG_6 test for now unless you say
otherwise.
>
>
> Sean

Yes, it is same as comment out.
The patch was for RELENG_7 or current. I'm not sure about
RELENG_6.

-- 
/ Hidetoshi Shimokawa
/  simokawaFreeBSD.ORG
_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

Re: scsi_target witness lock error
country flaguser name
United States
2007-12-11 21:32:57
Hidetoshi Shimokawa wrote:
> On 12/12/07, Sean Bruno <sbrunomiralink.com> wrote:
>   
>>> ---
//depot/vendor/freebsd/src/sys/cam/scsi/scsi_target.c    
2007/04/15 08:53:22
>>> +++
//depot/user/simokawa/firewire_lock/sys/cam/scsi/scsi_target
.c    2007/05/21 14:31:55
>>>  -372,10 +372,14 
>>>       int     retval;
>>>
>>>       softc = (struct targ_softc
*)kn->kn_hook;
>>> +#if 0
>>>       cam_periph_lock(softc->periph);
>>> +#endif
>>>       retval =
!TAILQ_EMPTY(&softc->user_ccb_queue) ||
>>>               
!TAILQ_EMPTY(&softc->abort_queue);
>>> +#if 0
>>>       cam_periph_unlock(softc->periph);
>>> +#endif
>>>       return (retval);
>>>  }
>>>       
>> Are these two "if 0"'s supposed to be
commented out?  I'm leaving this
>> out of my RELENG_6 test for now unless you say
otherwise.
>>
>>
>> Sean
>>     
>
> Yes, it is same as comment out.
> The patch was for RELENG_7 or current. I'm not sure
about RELENG_6.
>
>   
Ok, I merged the patch(RELENG_6) to the best of my ability. 
The system 
now panics and has the same witness error.

panic/witness/trace --> http://c
onsultcsg.com/scsitarget_witness.txt
scsi_target.c diff --> http://consu
ltcsg.com/scsi_target.c.diff

Sean
_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

Re: scsi_target witness lock error
country flaguser name
United States
2007-12-12 15:45:24
Hidetoshi Shimokawa wrote:
> Hi Sean,
> 
> At Tue, 11 Dec 2007 16:53:15 -0800,
> Sean Bruno wrote:
>> While I was debugging some random stuff with the
firewire target, I
>> noted the following witness lock:
>>
>> http
://www.consultcsg.com/scsitarget_witness.txt
>>
>> It looks like there is some kind of conflict
between the locks in
>> sys/cam/scsi/scsi_target.c and the kern environment
locks?  I'm fairly
>> certain that this is an easy fix, but I just don't
see how to work
>> around it.
>>
>> Sean
> 
> This a patch I sent Scott several months ago.
> It may help you. (this is for -current at that time)

Dang, sorry I forgot about this.  I'll try to review it
today.  If I
drop it again, please don't hesitate to just commit it.

Scott

_______________________________________________
freebsd-scsifreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-scsi

To unsubscribe, send any mail to
"freebsd-scsi-unsubscribefreebsd.org"

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )