Re: Data Out residual overflow/underflow handling

Paul Hughes <[email protected]> Fri, 21 Sep 2012 09:45:16 -0600
Newsgroups gmane.ietf.ips
Message-ID <CAGBQytuQdSdUxgaMBPgaUp2mC1aJDy1y6ePy4JAmbJWDe7TDZQ@mail.gmail.com>
--===============2155279190718362581==
Content-Type: multipart/alternative; boundary=bcaec51d2e4453f30b04ca382056

--bcaec51d2e4453f30b04ca382056
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Thanks for the detailed response Fred.  I will post this question to the
T10 reflector to see what they have to say, but thought I'd start here.

One follow up question:  If the initiator didn't send any immediate data
(the iSCSI Command Request PDU EDTL=3D512, but the data segment length is 0
and the Final bit is set), would the target have the same options?  I
believe the only difference would be the Sense Key that is reported
(Illegal Request if no immediate data was transferred, and Aborted Command
if immediate data was transferred).  I expect the residual reporting would
remain the same regardless of whether any data was transferred or not,
correct?

Thanks,
Paul



On Fri, Sep 21, 2012 at 8:00 AM, Knight, Frederick <
[email protected]> wrote:

>  You have a couple of choices.****
>
> ** **
>
> For example, SBC makes several statements about non-deterministic outcome=
s
> such as:****
>
> ** **
>
> The device server may terminate the command before processing or after th=
e
> device server has transferred some or all of the data. (walking off the
> end of the device)****
>
> ** **
>
> The degree that the medium is altered by this command is vendor specific.=
(The format command)
> ****
>
> ** **
>
> But those aren=92t directly related.  However, as you mention, FCP provid=
es
> the following 3 choice:****
>
> If the command requested that data beyond the length specified by the FCP=
_DL
> field be transferred, then the device server shall set the FCP_RESID_OVER=
 bit
> (see 9.5.8) to one in the FCP_RSP IU and:****
>
> **a)       **process the command normally except that data beyond the FCP=
_DL
> count shall not be requested or transferred;****
>
> **b)       **transfer no data and return CHECK CONDITION status with the
> sense key set to ILLEGAL REQUEST and the additional sense code set to
> INVALID FIELD IN COMMAND INFORMATION UNIT; or****
>
> **c)           **may transfer data and return CHECK CONDITION status with
> the sense key set to ABORTED COMMAND and the additional sense code set to
> INVALID FIELD IN COMMAND INFORMATION UNIT.****
>
> ** **
>
> Case a) and c) allow the media to be modified.  Case b) implies no media
> alteration (since no data is transferred).  Choice b) and c) include SCSI
> layer sense data, but choice a) includes only an FCP layer notification (=
no
> SCSI sense data, so a broken host (one that ignores residual unless a che=
ck
> condition exists) will assume success).****
>
> ** **
>
> RFC5048 says:****
>
>    If SPDTL > EDTL for a task, iSCSI Overflow MUST be signaled in the****
>
>    SCSI Response PDU as specified in [RFC3720].  The Residual Count MUST*=
*
> **
>
>    be set to the numerical value of (SPDTL - EDTL).****
>
> ** **
>
> SPDTL =3D the SCSI layer transfer size; EDTL =3D the iSCSI layer transfer=
 size.
> ****
>
> ** **
>
> Since the SCSI layer transfer size in your example is 4096, and the iSCSI
> layer transfer size is 512, then you must report the OVERFLOW as defined =
in
> RFC3720 (bit 5 in the flags field of the SCSI response PDU).  I couldn=92=
t
> quickly find any suggestions in RFC3720/5048 for sense data, so I=92d sug=
gest
> you go with choice b) or c) that FCP is using (I=92d suggest staying away
> from choice a) since it has bad possibilities).  At least that is
> something hosts should already be familiar with.****
>
> ** **
>
> The other list you might use for these kinds of questions is the SCSI
> reflector: [email protected] (T10 defines the SCSI architecture and writes the
> various SCSI command standards).****
>
> ** **
>
>                 Fred Knight****
>
> ** **
>
> ** **
>
> *From:* [email protected] [mailto:[email protected]] *On Behalf Of =
*Paul
> Hughes
> *Sent:* Thursday, September 20, 2012 11:22 PM
> *To:* [email protected]
> *Subject:* [Ips] Data Out residual overflow/underflow handling****
>
> ** **
>
> Not sure if this is the best place to ask, but here goes...****
>
> ** **
>
> How should an iSCSI target (SCSI direct-access block device) handle the
> following scenario:****
>
> ** **
>
> An initiator issues an iSCSI Command Request PDU containing a SCSI Write
> CDB with a transfer length of 1 block.  The iSCSI Command Request PDU has
> an Expected Data Transfer Length of 512 bytes, a Data Segment Length of 5=
12
> bytes (immediate data), and the Final flag is set.  This would be a
> perfectly normal single block write, except that the target's logical uni=
t
> is formatted with 4096-byte block size.  So it appears the initiator is
> confused and sending a single 512-byte block write to a logical unit that
> is formatted to 4KB block size.****
>
> ** **
>
> Here are my thoughts:****
>
> ** **
>
> 1) The target could write the 512 bytes of immediate data plus 3584 bytes
> (4096 minus 512) of whatever it wants to the media, and then send an iSCS=
I
> Command Response PDU with SCSI status of Good and reporting an Overflow
> with a residual count of 3584.  This seems to be the most correct way of
> handling this scenario, but it seems dangerous to allow an apparently
> confused initiator to essentially corrupt data on the logical unit.****
>
> ** **
>
> 2) The target could send an iSCSI Command Response PDU with SCSI status o=
f
> Check Condition, with sense data of Aborted Command, Invalid Field in
> Command Information Unit (0x0E03).  This sense code is apparently intende=
d
> for FCP (I found it mentioned in FCP-4) but it seems appropriate in this
> case.  Assuming the target can fail the SCSI Write command this way (or
> some other way), should the target also report an Underflow with a residu=
al
> count of 512?****
>
> ** **
>
> Are there any other alternatives?****
>
> ** **
>
> Thanks,****
>
> Paul****
>
> ** **
>
> ** **
>
> ** **
>

--bcaec51d2e4453f30b04ca382056
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Thanks for the detailed response Fred. =A0I will post this question to the =
T10 reflector to see what they have to say, but thought I&#39;d start here.=
<div><br></div><div>One follow up question:=A0=A0If the initiator didn&#39;=
t send any immediate data (the iSCSI Command Request PDU EDTL=3D512, but th=
e data segment length is 0 and the Final bit is set), would the target have=
 the same options? =A0I believe the only difference would be the Sense Key =
that is reported (Illegal Request if no immediate data was transferred, and=
 Aborted Command if immediate data was transferred). =A0I expect the residu=
al reporting would remain the same regardless of whether any data was trans=
ferred or not, correct?</div>
<div><br></div><div>Thanks,</div><div>Paul<br><div><br></div><div><br><br><=
div class=3D"gmail_quote">On Fri, Sep 21, 2012 at 8:00 AM, Knight, Frederic=
k <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" targ=
et=3D"_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">







<div lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">You have a couple of choi=
ces.<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">For example, SBC makes se=
veral statements about non-deterministic outcomes such as:<u></u><u></u></s=
pan></p>

<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">The device =
server may terminate the command before processing or after the device serv=
er has transferred some or all
 of the data. </span><span style=3D"font-size:11.0pt;font-family:&quot;Cali=
bri&quot;,&quot;sans-serif&quot;;color:#1f497d">(<span>walking</span> off t=
he end of the device)<u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><u></u>=A0<=
u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">The degree =
that the medium is altered by this command is vendor specific.</span><span =
style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&=
quot;;color:#1f497d">
 (The format command)<u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f4=
97d"><u></u>=A0<u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f4=
97d">But those aren=92t directly related.<span>=A0
</span>However, as you mention, FCP provides the following 3 choice:</span>=
<span style><u></u><u></u></span></p>
<p style=3D"margin-right:0in;margin-bottom:5.0pt;margin-left:0in;text-align=
:justify">
<span><span style=3D"font-size:10.0pt">If the command requested that data b=
eyond the length specified by the
</span></span><span><span style=3D"font-size:8.0pt">FCP</span></span><span>=
<span style=3D"font-size:10.0pt">_</span></span><span><span style=3D"font-s=
ize:8.0pt">DL
</span></span><span><span style=3D"font-size:10.0pt">field be transferred, =
then the device server shall set the
</span></span><span><span style=3D"font-size:8.0pt">FCP_RESID_OVER
</span></span><span><span style=3D"font-size:10.0pt">bit (see 9.5.8) to one=
 in the FCP_RSP IU and:</span></span><span style=3D"font-size:10.0pt"><u></=
u><u></u></span></p>
<p style=3D"margin-left:60.35pt;text-align:justify">
<u></u><span style=3D"font-size:10.0pt"><span>a)<span style=3D"font:7.0pt &=
quot;Times New Roman&quot;">=A0=A0=A0=A0=A0=A0
</span></span></span><u></u><span><span style=3D"font-size:10.0pt">process =
the command normally except that data beyond the
</span></span><span><span style=3D"font-size:8.0pt">FCP</span></span><span>=
<span style=3D"font-size:10.0pt">_</span></span><span><span style=3D"font-s=
ize:8.0pt">DL
</span></span><span><span style=3D"font-size:10.0pt">count shall not be req=
uested or transferred;</span></span><span style=3D"font-size:10.0pt"><u></u=
><u></u></span></p>
<p style=3D"margin-left:60.35pt;text-align:justify">
<u></u><span style=3D"font-size:10.0pt"><span>b)<span style=3D"font:7.0pt &=
quot;Times New Roman&quot;">=A0=A0=A0=A0=A0=A0
</span></span></span><u></u><span><span style=3D"font-size:10.0pt">transfer=
 no data and return CHECK CONDITION status with the sense key set to ILLEGA=
L REQUEST and the additional sense code set to INVALID FIELD IN COMMAND INF=
ORMATION UNIT;
 or</span></span><span style=3D"font-size:10.0pt"><u></u><u></u></span></p>
<p style=3D"margin-left:60.35pt;text-autospace:none">
<u></u><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quo=
t;sans-serif&quot;;color:#1f497d"><span>c)<span style=3D"font:7.0pt &quot;T=
imes New Roman&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
</span></span></span><u></u><span><span><span style=3D"font-size:10.0pt">ma=
y</span></span></span><span><span style=3D"font-size:10.0pt"> transfer data=
 and return CHECK CONDITION status with the sense key set to
 ABORTED COMMAND and the additional sense code set to INVALID FIELD IN COMM=
AND INFORMATION UNIT.</span></span><span style=3D"font-size:11.0pt;font-fam=
ily:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u><u></u=
></span></p>

<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">Case a) and c) allow the =
media to be modified.<span>=A0
</span>Case b) implies no media alteration (since no data is transferred).<=
span>=A0
</span>Choice b) and c) include SCSI layer sense data, but choice a) includ=
es only an FCP layer notification (no SCSI sense data, so a broken host (on=
e that ignores residual unless a check condition exists) will assume succes=
s).<u></u><u></u></span></p>

<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">RFC5048 says:<u></u><u></=
u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;"><span>=A0=A0
</span>If SPDTL &gt; EDTL for a task, iSCSI Overflow MUST be signaled in th=
e<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;"><span>=A0=A0
</span>SCSI Response PDU as specified in [RFC3720].<span>=A0
</span>The Residual Count MUST<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;"><span>=A0=A0
</span><span>be</span> set to the numerical value of (SPDTL - EDTL).<u></u>=
<u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">SPDTL =3D the SCSI layer =
transfer size; EDTL =3D the iSCSI layer transfer size.<u></u><u></u></span>=
</p>

<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">Since the SCSI layer tran=
sfer size in your example is 4096, and the iSCSI layer transfer size is 512=
, then you must report
 the OVERFLOW as defined in RFC3720 (bit 5 in the flags field of the SCSI r=
esponse PDU).<span>=A0
</span>I couldn=92t quickly find any suggestions in RFC3720/5048 for sense =
data, so I=92d suggest you go with choice b) or c) that FCP is using (I=92d=
 suggest staying away from choice a) since it has bad possibilities).<span>=
=A0
</span>At least that is something hosts should already be familiar with.<u>=
</u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">The other list you might =
use for these kinds of questions is the SCSI reflector:
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a> (T10 defin=
es the SCSI architecture and writes the various SCSI command standards).<u>=
</u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><span>=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
</span>Fred Knight<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot=
;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href=
=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>
 [mailto:<a href=3D"mailto:[email protected]" target=3D"_blank">ips-boun=
[email protected]</a>] <b>On Behalf <span>Of</span> </b>Paul Hughes<br>
<b>Sent:</b> Thursday, September 20, 2012 11:22 PM<br>
<b>To:</b> <a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</=
a><br>
<b>Subject:</b> [Ips] Data Out residual overflow/underflow handling<u></u><=
u></u></span></p><div><div class=3D"h5">
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
<p class=3D"MsoNormal">Not sure if this is the best place to ask, but here =
goes...<u></u><u></u></p>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">How should an iSCSI target (SCSI direct-access block=
 device) handle the following scenario:<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">An initiator issues an iSCSI Command Request PDU con=
taining a SCSI Write CDB with a transfer length of 1 block. =A0The iSCSI Co=
mmand Request PDU has an Expected Data Transfer Length of 512 bytes, a Data=
 Segment Length of 512 bytes (immediate
 data), and the Final flag is set. =A0This would be a perfectly normal sing=
le block write, except that the target&#39;s logical unit is formatted with=
 4096-byte block size. =A0So it appears the initiator is confused and sendi=
ng a single 512-byte block write to a logical
 unit that is formatted to 4KB block size.<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">Here are my thoughts:<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">1) The target could write the 512 bytes of immediate=
 data plus 3584 bytes (4096 minus 512) of whatever it wants to the media, a=
nd then send an iSCSI Command Response PDU with SCSI status of Good and rep=
orting an Overflow with a residual
 count of 3584. =A0This seems to be the most correct way of handling this s=
cenario, but it seems dangerous to allow an apparently confused initiator t=
o essentially corrupt data on the logical unit.<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">2) The target could send an iSCSI=A0Command Response=
 PDU with SCSI status of Check Condition, with sense data of Aborted Comman=
d, Invalid Field in Command Information Unit (0x0E03). =A0This sense code i=
s apparently intended for FCP (I found
 it mentioned in FCP-4) but it seems appropriate in this case. =A0Assuming =
the target can fail the SCSI Write command this way (or some other way), sh=
ould the target also report an Underflow with a residual count of 512?<u></=
u><u></u></p>

</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">Are there any other alternatives?<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal">Paul<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div></div>

--bcaec51d2e4453f30b04ca382056--

--===============2155279190718362581==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ips mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/ips

--===============2155279190718362581==--