From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Bottomley Subject: Re: [example PATCH - not for applying] exclude certain commands Date: 24 Apr 2003 11:26:47 -0400 Sender: linux-scsi-owner@vger.kernel.org Message-ID: <1051198007.2010.21.camel@mulgrave> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-OF89imf+Wd348fLmnQk1" Return-path: Received: from nat9.steeleye.com ([65.114.3.137]:57861 "EHLO hancock.sc.steeleye.com") by vger.kernel.org with ESMTP id S263730AbTDXPP2 (ORCPT ); Thu, 24 Apr 2003 11:15:28 -0400 In-Reply-To: List-Id: linux-scsi@vger.kernel.org To: Alan Stern Cc: Andries.Brouwer@cwi.nl, stelian@popies.net, afafc@rnl.ist.utl.pt, Greg KH , SCSI Mailing List , USB development list , mike@hingston.demon.co.uk --=-OF89imf+Wd348fLmnQk1 Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2003-04-24 at 10:46, Alan Stern wrote: > I dislike the idea of avoidable meddling with with user-issued (sg) > commands. If the user wants to send a command, we should let him; if it > fails then it's up to the user to fix things. After all, probably lots of > devices _do_ support these 4-byte MODE-SENSE transfers. > > It would probably be enough to make sure that the commands generated by > sd.c end up working. OK, if we just want only this, then it's quite easy. The attached patch adds a min_xfersize to the host and template. If it's zero, the behaviour will be as before. James --=-OF89imf+Wd348fLmnQk1 Content-Disposition: attachment; filename=tmp.diff Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=tmp.diff; charset=ISO-8859-1 =3D=3D=3D=3D=3D drivers/scsi/hosts.c 1.57 vs edited =3D=3D=3D=3D=3D --- 1.57/drivers/scsi/hosts.c Tue Apr 15 13:20:37 2003 +++ edited/drivers/scsi/hosts.c Thu Apr 24 11:00:29 2003 @@ -427,6 +427,7 @@ =20 shost->max_sectors =3D shost_tp->max_sectors; shost->use_blk_tcq =3D shost_tp->use_blk_tcq; + shost->min_xfersize =3D shost_tp->min_xfersize; =20 spin_lock(&scsi_host_list_lock); /* =3D=3D=3D=3D=3D drivers/scsi/hosts.h 1.58 vs edited =3D=3D=3D=3D=3D --- 1.58/drivers/scsi/hosts.h Mon Mar 24 07:14:28 2003 +++ edited/drivers/scsi/hosts.h Thu Apr 24 11:04:40 2003 @@ -339,6 +339,12 @@ unsigned use_blk_tcq:1; =20 /* + * Minimum transfer length for the device. The mid-layer will + * not ask for fewer bytes than this (user issued commands may) + */ + unsigned char min_xfersize; + + /* * Name of proc directory */ char *proc_name; @@ -458,6 +464,12 @@ unsigned use_clustering:1; unsigned highmem_io:1; unsigned use_blk_tcq:1; + + /*=20 + * Minimum transfer length for the device. The mid-layer will + * not ask for fewer bytes than this (user issued commands may) + */ + unsigned char min_xfersize; =20 /* * Host has requested that no further requests come through for the =3D=3D=3D=3D=3D drivers/scsi/sd.c 1.108 vs edited =3D=3D=3D=3D=3D --- 1.108/drivers/scsi/sd.c Fri Apr 18 11:58:55 2003 +++ edited/drivers/scsi/sd.c Thu Apr 24 11:07:25 2003 @@ -1112,7 +1112,8 @@ * We have to start carefully: some devices hang if we ask * for more than is available. */ - res =3D sd_do_mode_sense6(sdp, SRpnt, 0, 0x3F, buffer, 4); + res =3D sd_do_mode_sense6(sdp, SRpnt, 0, 0x3F, buffer,=20 + max(sdp->host->min_xfersize, 4)); =20 /* * Second attempt: ask for page 0 @@ -1120,7 +1121,8 @@ * Sense Key 5: Illegal Request, Sense Code 24: Invalid field in CDB. */ if (res) - res =3D sd_do_mode_sense6(sdp, SRpnt, 0, 0, buffer, 4); + res =3D sd_do_mode_sense6(sdp, SRpnt, 0, 0, buffer, + max(sdp->host->min_xfersize, 4)); =20 /* * Third attempt: ask 255 bytes, as we did earlier. @@ -1153,14 +1155,16 @@ const int modepage =3D 0x08; /* current values, cache page */ =20 /* cautiously ask */ - res =3D sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, 4); + res =3D sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, + max(sdp->host->min_xfersize, 4)); =20 if (res =3D=3D 0) { /* that went OK, now ask for the proper length */ len =3D buffer[0] + 1; if (len > 128) len =3D 128; - res =3D sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, len); + res =3D sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, + max(sdp->host->min_xfersize, len)); } =20 if (res =3D=3D 0 && buffer[3] + 6 < len) { --=-OF89imf+Wd348fLmnQk1--