public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andries.Brouwer@cwi.nl, stelian@popies.net, afafc@rnl.ist.utl.pt,
	Greg KH <greg@kroah.com>,
	SCSI Mailing List <linux-scsi@vger.kernel.org>,
	USB development list <linux-usb-devel@lists.sourceforge.net>,
	mike@hingston.demon.co.uk
Subject: Re: [example PATCH - not for applying] exclude certain commands
Date: 24 Apr 2003 11:26:47 -0400	[thread overview]
Message-ID: <1051198007.2010.21.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0304241042370.763-100000@ida.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

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


[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 2719 bytes --]

===== drivers/scsi/hosts.c 1.57 vs edited =====
--- 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 @@
 
 	shost->max_sectors = shost_tp->max_sectors;
 	shost->use_blk_tcq = shost_tp->use_blk_tcq;
+	shost->min_xfersize = shost_tp->min_xfersize;
 
 	spin_lock(&scsi_host_list_lock);
 	/*
===== drivers/scsi/hosts.h 1.58 vs edited =====
--- 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;
 
     /*
+     * 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;
+
+    /* 
+     * 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;
 
     /*
      * Host has requested that no further requests come through for the
===== drivers/scsi/sd.c 1.108 vs edited =====
--- 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 = sd_do_mode_sense6(sdp, SRpnt, 0, 0x3F, buffer, 4);
+	res = sd_do_mode_sense6(sdp, SRpnt, 0, 0x3F, buffer, 
+				max(sdp->host->min_xfersize, 4));
 
 	/*
 	 * 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 = sd_do_mode_sense6(sdp, SRpnt, 0, 0, buffer, 4);
+		res = sd_do_mode_sense6(sdp, SRpnt, 0, 0, buffer,
+					max(sdp->host->min_xfersize, 4));
 
 	/*
 	 * Third attempt: ask 255 bytes, as we did earlier.
@@ -1153,14 +1155,16 @@
 	const int modepage = 0x08; /* current values, cache page */
 
 	/* cautiously ask */
-	res = sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, 4);
+	res = sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer,
+				max(sdp->host->min_xfersize, 4));
 
 	if (res == 0) {
 		/* that went OK, now ask for the proper length */
 		len = buffer[0] + 1;
 		if (len > 128)
 			len = 128;
-		res = sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer, len);
+		res = sd_do_mode_sense6(sdp, SRpnt, dbd, modepage, buffer,
+					max(sdp->host->min_xfersize, len));
 	}
 
 	if (res == 0 && buffer[3] + 6 < len) {

  reply	other threads:[~2003-04-24 15:15 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24  9:46 [example PATCH - not for applying] exclude certain commands Andries.Brouwer
2003-04-24  9:56 ` Stelian Pop
2003-04-24 14:05 ` Alan Stern
2003-04-24 14:26   ` James Bottomley
2003-04-24 14:46     ` Alan Stern
2003-04-24 15:26       ` James Bottomley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-04-27  2:29 Andries.Brouwer
2003-04-27  4:32 ` James Bottomley
2003-04-26 21:44 Andries.Brouwer
2003-04-26 22:13 ` Matthew Dharm
2003-04-26 22:43   ` James Bottomley
2003-04-27  1:34     ` Matthew Dharm
2003-04-27  2:15       ` James Bottomley
2003-04-27  9:35         ` Matthew Dharm
2003-04-27 15:41           ` James Bottomley
2003-04-27 18:52             ` Kai Makisara
2003-04-27 19:52             ` Matthew Dharm
2003-04-28 19:05               ` Luben Tuikov
2003-04-28 19:12                 ` Luben Tuikov
2003-04-28 20:19                 ` Matthew Dharm
2003-04-28 21:33                   ` Luben Tuikov
2003-04-26 22:29 ` James Bottomley
2003-04-27  0:24   ` Patrick Mansfield
2003-04-27  1:39   ` Matthew Dharm
2003-04-25  0:43 Andries.Brouwer
2003-04-25  2:12 ` Matthew Dharm
2003-04-25 14:32 ` Alan Stern
2003-04-25 15:12   ` Oliver Neukum
2003-04-26  0:58     ` Alan Stern
2003-04-26  8:24       ` Oliver Neukum
2003-04-26 15:22         ` Alan Stern
2003-04-24 18:59 Andries.Brouwer
2003-04-24 19:14 ` Matthew Dharm
2003-04-24 20:20   ` James Bottomley
2003-04-24 20:59     ` Matthew Dharm
2003-04-24 21:43       ` Patrick Mansfield
2003-04-24 15:21 Andries.Brouwer
2003-04-24 15:56 ` Pete
2003-04-24 21:33 ` Stelian Pop
2003-04-24  9:08 Andries.Brouwer
2003-04-24 18:22 ` Matthew Dharm
2003-04-23 22:39 Andries.Brouwer
2003-04-24  0:10 ` Matthew Dharm
2003-04-24  8:05 ` André Cruz
2003-04-24  9:15 ` Stelian Pop
2003-04-24  9:22   ` Stelian Pop
2003-04-24 11:45 ` Mike Bursell
2003-04-24 12:44 ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1051198007.2010.21.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=afafc@rnl.ist.utl.pt \
    --cc=greg@kroah.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=mike@hingston.demon.co.uk \
    --cc=stelian@popies.net \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox