linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi_mid_low_api.txt recommend resid usage
@ 2010-12-24  2:40 Douglas Gilbert
  2010-12-24 17:46 ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Douglas Gilbert @ 2010-12-24  2:40 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Bottomley, Martin K. Petersen

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

As discussed in a thread on this list titled:
    "RFC: short reads on block devices"
this patch adds recommendations for LLDs to set resid
when there might be uncertainty about how much data
has been returned by a device.

This patch inline and attached] is against scsi-misc-2.6.git


Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>


diff --git a/Documentation/scsi/scsi_mid_low_api.txt 
b/Documentation/scsi/scsi_mid_low_api.txt
index df322c1..7bcdea7 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -1343,7 +1343,7 @@ Members of interest:
                     underruns (overruns should be rare). If possible an LLD
                     should set 'resid' prior to invoking 'done'. The most
                     interesting case is data transfers from a SCSI target
-                   device device (i.e. READs) that underrun.
+                   device (e.g. READs) that underrun.
      underflow    - LLD should place (DID_ERROR << 16) in 'result' if
                     actual number of bytes transferred is less than this
                     figure. Not many LLDs implement this check and some that
@@ -1351,6 +1351,18 @@ Members of interest:
                     report a DID_ERROR. Better for an LLD to implement
                     'resid'.

+It is recommended that a LLD set 'resid' on data transfers from a SCSI
+target device (e.g. READs). It is especially important that 'resid' is set
+when such data transfers have sense keys of MEDIUM ERROR and HARDWARE ERROR
+(and possibly RECOVERED ERROR). In these cases if a LLD is in doubt how much
+data has been received then the safest approach is to indicate no bytes have
+been received. For example: to indicate that no valid data has been received
+a LLD might use these helpers:
+    scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
+where 'SCpnt' is a pointer to a scsi_cmnd object. To indicate only three 512
+bytes blocks has been received 'resid' could be set like this:
+    scsi_set_resid(SCpnt, scsi_bufflen(SCpnt) - (3 * 512));
+
  The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h



[-- Attachment #2: scsi_mid_low_api_resid.patch --]
[-- Type: text/x-patch, Size: 1782 bytes --]

diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
index df322c1..7bcdea7 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -1343,7 +1343,7 @@ Members of interest:
                    underruns (overruns should be rare). If possible an LLD
                    should set 'resid' prior to invoking 'done'. The most
                    interesting case is data transfers from a SCSI target
-                   device device (i.e. READs) that underrun. 
+                   device (e.g. READs) that underrun. 
     underflow    - LLD should place (DID_ERROR << 16) in 'result' if
                    actual number of bytes transferred is less than this
                    figure. Not many LLDs implement this check and some that
@@ -1351,6 +1351,18 @@ Members of interest:
                    report a DID_ERROR. Better for an LLD to implement
                    'resid'.
 
+It is recommended that a LLD set 'resid' on data transfers from a SCSI
+target device (e.g. READs). It is especially important that 'resid' is set
+when such data transfers have sense keys of MEDIUM ERROR and HARDWARE ERROR
+(and possibly RECOVERED ERROR). In these cases if a LLD is in doubt how much
+data has been received then the safest approach is to indicate no bytes have
+been received. For example: to indicate that no valid data has been received
+a LLD might use these helpers:
+    scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
+where 'SCpnt' is a pointer to a scsi_cmnd object. To indicate only three 512
+bytes blocks has been received 'resid' could be set like this:
+    scsi_set_resid(SCpnt, scsi_bufflen(SCpnt) - (3 * 512));
+
 The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h
 
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-30 17:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-24  2:40 [PATCH] scsi_mid_low_api.txt recommend resid usage Douglas Gilbert
2010-12-24 17:46 ` Randy Dunlap
2010-12-24 20:17   ` Douglas Gilbert
2010-12-24 20:36     ` Randy Dunlap
2010-12-30 16:08   ` Douglas Gilbert
2010-12-30 17:50     ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).