Subject: iSCSI - Change - a neat s

From: "Julian Satran" <[email-masked]>
Date: Wed, 22 Aug 2001 20:18:03 +0300

Dear coleagues,

I owe an answer on this to both the design team, and lately to Robert
Griswold that raised the issue
of how can a target distinguish the reason for which the initiator issued a
command restart/retry (X bit 1).

This makes the life of the recovery implementor difficult and leaves some
ambiguity.
The three reasons to issue a restart are:

   plug-in a hole created by a command being dropped (e.g., bad digest)
   restart the command on another connection after the original is logged
   out
   replay a command

Out of the three only the first needs all the information from the command
(the command must be completely reissued).

On the other two the information from the command is not needed (the
command exists already at the target.

The current draft uses the restart/replay for all three of them and the
target may have a hard time
understanding unamiguously what the initiator meant.

Considering all those fact I suggest the following change to the current
draft:

1. Use the restart bit (X bit 1) only to indicate that the initiator thinks
he is doing a "plug-in-the-hole". The target can drop the PDU if it has
already the command
2.Use a different mechanism to accomplish the restart/replay

The mechanism for restart replay can be "transfered" easily to the task
management commands - as thhe tasks to be resumed or replyed already exist.

I  suggest  the following new text for the task management command and
response (with appropriate changes in the recovery sections):

1.1  Task Management Command

   Byte /    0       |       1       |       2       |       3       |
      /              |               |               |               |
     |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
     +---------------+---------------+---------------+---------------+
    0|X|I| x02       |0| Function    | Reserved (0)                  |
     +---------------+---------------+---------------+---------------+
    4| Reserved (0)                                                  |
     +---------------+---------------+---------------+---------------+
    8| Logical Unit Number (LUN) or Reserved (0)                     |
     +                                                               +
   12|                                                               |
     +---------------+---------------+---------------+---------------+
   16| Initiator Task Tag                                            |
     +---------------+---------------+---------------+---------------+
   20| Referenced Task Tag or Reserved (0xffffffff)                  |
     +---------------+---------------+---------------+---------------+
   24| CmdSN                                                         |
     +---------------+---------------+---------------+---------------+
   28| ExpStatSN                                                     |
     +---------------+---------------+---------------+---------------+
   32| RefCmdSN                                                      |
     +---------------+---------------+---------------+---------------+
   36/ Reserved (0)                                                  /
    +/                                                               /
     +---------------+---------------+---------------+---------------+
   48

1.1.1     Function

   The Task Management functions provide an initiator with a way to
   explicitly control the execution of one or more Tasks (SCSI and iSCSI
   tasks). The Task Management functions are summarized as follows (for a
   more detailed description of SCSI task management see the [SAM2]
   document):

      1    Abort Task - aborts the task identified by the Referenced Task
      Tag field.
      2    Abort Task Set - aborts all Tasks issued by this initiator on
      the Logical Unit.
      3    Clear ACA - clears the Auto Contingent Allegiance condition.
      4    Clear Task Set - Aborts all Tasks (from all initiators) for the
      Logical Unit.
      5    Logical Unit Reset
      6    Target Warm Reset
7    Target Cold Reset
8    Task Resume - restart the task identified by the Referenced Task Tag
field on this connection
9    Task Replay - replay the task identified by the Referenced Task Tag
field on this connection

   For all these functions, if executed, the Task Management Response MUST
   be returned using the Initiator Task Tag to identify the operation for
   which it is responding. All those functions apply to the referenced
   tasks regardless if they are proper SCSI tasks or tagged iSCSI
   operations.  Task management commands must be executed as if all the
   commands having a CmdSN lower or equal to the task management CmdSN have
   been received by the target (i.e., have to be executed as if received
   for ordered delivery even when marked for immediate delivery).  For all
   the tasks covered by the task management response (i.e., with CmdSN not
   higher than the task management command CmdSN), additional responses
   MUST NOT be delivered to the SCSI layer after the task management
   response.

   For the <Logical Unit Reset>, the target MUST behave as dictated by the
   Logical Unit Reset function in [SAM-2].

   The Target Reset function (Warm and Cold) implementation is OPTIONAL and
   when implemented they should act as described below.  Target Reset MAY
   be also subject to authorization of the requesting initiator.  When not
   implemented or when authorization fails at target, Target Reset
   functions should end as if the function was executed successfully and
   the response qualifier will detail what was executed.

   For the <Target Warm Reset> and <Target Cold Reset> functions, the
   target cancels all pending operations and are both equivalent to the
   Hard Reset as specified by [SAM-2].  They can both affect many other
   initiators.

   In addition, for the <Target Cold Reset> the target then MUST terminate
   all of its TCP connections to all initiators (all sessions are
   terminated). However, if the target finds that it cannot send the
   required response or AEN, it MUST continue the reset operation and it
   SHOULD log the condition for later retrieval in its internal management
   structures.

   Further actions on reset functions are specified in the relevant SCSI
   documents for the specific class of devices.

   For the <Task Resume> and <Task Replay> the target should resume
   executing the referenced task or replay it completely. <Task Replay>
   MUST be received by the target ONLY after the status for the command was
   issued. <Task Resume> MUST be received by the target ONLY after the
   connection on which the command was previously executing has been
   successfully logged-out.
   <Task Resume> and <Task Replay> MUST be issued as immediate commands.

1.1.2     LUN

   This field is required for functions addressing a specific LU (<abort
   task, clear task set, abort task set, clear ACA, Reset LU and is
   reserved in all others.

1.1.3     Referenced Task Tag

   Initiator Task Tag of the task to be aborted, restarted or replayed

1.1.4     RefCmdSN

   For abort-task the task CmdSN to enable task removal. If RefCmdSN does
   not match the CmdSN of the command to be aborted at the target
   The abort action MUST not be performed and the response MUST be function
   rejected.

1.2  Task Management Response

   Byte /    0       |       1       |       2       |       3       |
      /              |               |               |               |
     |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
     +---------------+---------------+---------------+---------------+
    0|1|1| 0x22      |1| Reserved (0)                                |
     +---------------+---------------+---------------+---------------+
    4/ Reserved (0)                                                  /
     /                                                               /
     +---------------+---------------+---------------+---------------+
   16| Initiator Task Tag                                            |
     +---------------+---------------+---------------+---------------+
   20| Referenced Task Tag or Reserved (0xffffffff)                  |
     +---------------+---------------+---------------+---------------+
   24| StatSN                                                        |
     +---------------+---------------+---------------+---------------+
   28| ExpCmdSN                                                      |
     +---------------+---------------+---------------+---------------+
   32| MaxCmdSN                                                      |
     +---------------+---------------+---------------+---------------+
   36| Response      | Qualifier     | Reserved (0)                  |
     +---------------+---------------+---------------+---------------+
   40/ Reserved (0)                                                  /
    +/                                                               /
     +---------------+---------------+---------------+---------------+
   48

   For the functions <Abort Task, Abort Task Set, Clear ACA, Clear Task
   Set, Logical Unit reset, Target Warm Reset>, the target performs the
   requested Task Management function and sends a Task Management Response
   back to the initiator. The target provides a Response, which may take on
   the following values:

       0    Function Complete
       1    Task was not in task set
       2    Command not received yet but placeholder marked for task abort
3    LUN does not exist
4    Task running on a connection that was not logged-out
5    Task failover not supported
6    Task in progress
7    Task replay not supported
      255   Function Rejected

   The Qualifier field details the Response.

   For Function Complete the valid Qualifiers are:

      0 - Function Executed
      1 - Function not implemented
      2 - Not Authorized

   For the <Target Cold Reset> and <Target Warm Reset> functions, the
   target cancels all pending operations.  For the <Target Cold Reset> the
   target MUST then close all of its TCP connections to all initiators
   (terminates all sessions).

   The mapping of the response code into a SCSI service response code, if
   needed, is outside the scope of this document.

1.2.1     Referenced Task Tag

   Initiator Task Tag of the task not found used in conjunction with
   responses referring to a specific task. It MUST be set to 0xffffffff in
   other cases.

   Julo