Subject: Re: panic: dequeued wrong buf in -current
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 09/08/2004 13:29:47
--Apple-Mail-1-404070239
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed


On Sep 8, 2004, at 9:14 AM, Manuel Bouyer wrote:

> On Tue, Sep 07, 2004 at 11:12:00PM +0200, Manuel Bouyer wrote:
>> 2) isn't doable without adding an extra argument to scsipi_command() 
>> either
>> (we need a pointer to the buf queue), so I've gone with 1).
>> I'm now running the attached patch on i386 with atapi devices, and 
>> sparc
>> with scsi drives (controller is a esp@sbus).
>>
>> I noone object I'll commit this in a couple of days, and request a 
>> pullup to
>> 2.0 of all commits related to dealing with scsipi_xfer shortage.
>
> Hi,
> here is a new diff with some changes after comments from Chuck (in 
> private
> mail) and Jason:
> - no argument names in prototypes
> - with a scsipi_xfer preallocated, scsipi_command() can't fail in the
>   ASYNC case. I've keep a check for this in the DIAGNOSTIC case.

+		/* with a scsipi_xfer preallocated, scsipi_command can't fail */
+		error = scsipi_command(periph, xs, cmdp, cmdlen,
+		    (u_char *)bp->b_data, bp->b_bcount,
+		    CDRETRIES, 30000, bp, flags);
+#ifdef DIAGNOSTIC
+		if (__predict_false(error)) {
+			disk_unbusy(&cd->sc_dk, 0, 0);
+			printf("%s: not queued, error %d\n",
+			    cd->sc_dev.dv_xname, error);
+			bp->b_flags |= B_ERROR;
+			bp->b_error = ENOMEM;
+			biodone(bp);
+		}
+#endif

If it can't fail in this case, then just do:

	KASSERT(error == 0);

Why bother recovering from something that can't happen? :-)

         -- Jason R. Thorpe <thorpej@wasabisystems.com>


--Apple-Mail-1-404070239
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFBP2u+OpVKkaBm8XkRAlnPAKCvDCxXhyJmBRYQeiaAQTBy1j6cswCeOVa1
AvvK+BCfYJf52XuVRnhNlXc=
=n69I
-----END PGP SIGNATURE-----

--Apple-Mail-1-404070239--