X3T9.2/93-145R1 To: Membership of X3T9.2 From: Ralph O. Weber Digital Equipment Corporation Date: September 15, 1993 Subject: COPY Command Definition for SCSI-3 SPC At the May Working Group meeting, the two options were discussed for adding SCSI-3 Target Identifiers and LUNs to the third party commands (COMPARE, COPY, and COPY AND VERIFY). The expanded fields could be added to the header part of the COPY parameter list, or they could be added to the segment descriptors. The Working Group selected the second option. Using SCSI-2 Revision 10K as a base, this document shows the changes needed in the COPY command definition to implement the option selected by the Working Group. The effects of approved document 93-063R1 on the COPY function code numbers are also shown in this document. Because the definitions for the COMPARE and COPY AND VERIFY commands reference the COPY command definition, no changes are needed in those definitions. It is proposed that the changes shown in this document be incorporated in the SCSI-3 Primary Commands document, to extend third-party parameter data for the larger Target Identifier and LUN fields used by SCSI-3. As noted at the September Working Group meeting, handling of ACA by the copy manager must be performed before a CHECK CONDITION status is returned on the COPY command. This revision includes new text in Section 8.2.3.2 describing ACA handling. Changes from SCSI-2 are marked with change bars in the left-hand margin. In some cases, I propose removing existing text. Such text is marked with a strikeout line. Neither of these editing features is available in the ASCII text file (electronic mail) version of this document. 8.2.3 COPY command The COPY command (see table 35) provides a means to copy data from one logical unit to another or the same logical unit. The logical unit that receives and performs the COPY command is called the copy manager. The copy manager is responsible for copying data from a logical unit (source device) to a logical unit (destination device). These logical units may reside on different SCSI devices or the same SCSI device (in fact all three may be the same logical unit). Some SCSI devices that implement this command may not support copies to or from another SCSI device, or may not support third party copies (i.e. both the source and the destination logical units reside on other SCSI devices). Table 35 - COPY command +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | Operation code (18h) | +-----+--------------------------+-----------------------------------+--------+ | 1 | Logical unit number | Reserved | Pad | +-----+--------------------------+-----------------------------------+--------+ | 2 | (MSB) | +-----+--- ---+ | 3 | Parameter list length | +-----+--- ---+ | 4 | (LSB) | +-----+-----------------------------------------------------------------------+ | 5 | Control | +=====+=======================================================================+ The pad bit (8.2.3.7) is used in conjunction with the cat bit (8.2.3.7) in the segment descriptors to define what action should be taken when a segment of the copy does not fit exactly into an integer number of destination blocks. The parameter list length field specifies the length in bytes of the parameters that shall be sent during the DATA OUT phase of the command. A parameter list length of zero indicates that no data shall be transferred. This condition shall not be considered as an error. The COPY parameter list (see table 36) begins with a four-byte header that contains the COPY function code and priority. Following the header is one or more segment descriptors. Table 36 - COPY parameter list +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | COPY function code | Priority | +-----+--------------------------------------------+--------------------------+ | 1 | Vendor-specific | +-----+-----------------------------------------------------------------------+ | 2 | Reserved | +-----+-----------------------------------------------------------------------+ | 3 | Reserved | +=====+=======================================================================+ | | Segment descriptor(s) | +=====+=======================================================================+ | 0 | Segment descriptor 0 | +- - -+--- ---+ | n | (See specific table for length.) | +-----+-----------------------------------------------------------------------+ | | . | | | . | +-----+-----------------------------------------------------------------------+ | 0 | Segment descriptor x | +- - -+--- ---+ | n | (See specific table for length.) | +=====+=======================================================================+ The COPY function code field defines a specific format for the segment descriptors. The COPY function codes are defined in table 37. A target need not support all function codes for its device type. Table 37 - COPY function codes +===============================================+========+==========+========+ | Peripheral device type | COPY | Segment | | +-----------------------+-----------------------+function|descriptor| | | Source | Destination | code | table |Comments| +-----------------------+-----------------------+--------+----------+--------+ | Block devices | Stream devices | 0Ah | 38 | | | (Device types 0,4,5,7)| (Device types 1,2,3,9)| | | | | Stream devices | Block devices | 0Bh | 38 |(Note 5)| | (Device types 1,3,9) | (Device types 0,4,5,7)| | | | | Block devices | Block devices | 0Ch | 39 |(Note 5)| | (Device types 0,4,5,7)| (Device types 0,4,5,7)| | | | | Stream devices | Stream devices | 0Dh | 40 | | | (Device types 1,3,9) | (Device types 1,2,3,9)| | | | | Sequential-access | Sequential-access | 0Eh | 41 | Image | | (Device type 1) | (Device type 1) | | | copy | +-----------------------+-----------------------+--------+----------+--------+ | NOTES | | 1 COPY function code 0Fh is reserved for future standardization. | | 2 COPY function codes 00h - 04h are reserved for use as defined in the | | SCSI-2 Standard. | | 3 COPY function codes 05h - 09h are reserved for standardization after | | adoption of the SCSI-3 Standards. | | 4 COPY function codes 10h - 1Fh are vendor-specific. | | 5 When using the COMPARE command the destination block device may be a | | CD-ROM device or an optical-memory device that uses read-only media. | | 6 See 8.2.5.1 for peripheral device type definitions. | +============================================================================+ The priority field of the COPY parameter list establishes the relative priority of this COPY command to other commands being executed by the same target. All other commands are assumed to have a priority of 1. Priority 0 is the highest priority, with increasing values indicating lower priorities. The segment descriptor formats are determined by the COPY function code. The segment descriptor format used for block devices (i.e. write-once, CD-ROM, optical-memory, and direct-access devices) shall be the same. The segment descriptor format used for stream devices (i.e. printer, processor, communications, and sequential-access devices) shall be the same. Thus a copy operation from a write-once device to a printer device uses the same segment descriptor format as a copy operation from a direct-access device to a sequential-access device (see table 37). The segment descriptor formats are described in 8.2.3.3 through 8.2.3.6. A maximum of 256 segment descriptors are permitted. The segment descriptors are identified by ascending numbers beginning with zero. 8.2.3.1 Errors detected by the managing SCSI device Two classes of exception conditions may occur during execution of a COPY command. The first class consists of those exception conditions detected by the SCSI device that received the COPY command and is managing the execution of the command. These conditions include parity errors while transferring the COPY command and status byte, invalid parameters in the COPY command, invalid segment descriptors, and inability of the SCSI device controlling the COPY functions to continue operating. In the event of such an exception condition, the SCSI device managing the COPY shall: a) terminate the COPY command with CHECK CONDITION status. b) set the valid bit in the sense data to one. The segment number shall contain the number of the segment descriptor being processed at the time the exception condition is detected. The sense key shall contain the sense key code describing the exception condition (i.e. not COPY ABORTED). The information field shall contain the difference between the number of blocks field in the segment descriptor being processed at the time of the failure and the number of blocks successfully copied. This number is the residue of unprocessed blocks remaining for the segment descriptor. 8.2.3.2 Errors detected by a target The second class of errors consists of exception conditions detected by the SCSI device transferring data at the request of the SCSI device managing the transfer. The SCSI device managing the COPY command detects exception conditions by receiving CHECK CONDITION status from one of the SCSI devices it is managing. It then shall recover the sense data associated with the exception condition. After recovering the sense data, the copy manager shall clear the ACA associated with the CHECK CONDITION status. The SCSI device managing the COPY command may also be the source or destination SCSI device (or both). It shall distinguish between a failure of the management of the COPY and a failure of the data transfer being requested. It shall then create the appropriate sense data and manage the ACA condition internally. After recovering the sense data and clearing the ACA condition associated with the detected error, the SCSI device managing the COPY command shall: a) terminate the COPY command with CHECK CONDITION status. b) The valid bit in the sense data shall be set to one. The segment number shall contain the number of the segment descriptor being processed at the time the exception condition is detected. The sense key shall be set to COPY ABORTED. The information field shall contain the difference between the number of blocks field in the segment descriptor being processed at the time of the failure and the number of blocks successfully copied. This number is the residue of unprocessed blocks remaining for the segment descriptor. The first byte of the command-specific information field shall specify the starting byte number, relative to the first byte of sense data, of an area that contains (unchanged) the source logical unit's status byte and sense data. A zero value indicates that no status byte or sense data is being returned for the source logical unit. The second byte of the command-specific information field shall specify the starting byte number, relative to the first byte of sense data, of an area that contains (unchanged) the destination logical unit's status byte and sense data. A zero value indicates that no status byte or sense data is being returned for the destination logical unit. 8.2.3.3 COPY function codes 0Ah and 0Bh The format for the segment descriptors for COPY transfers between block and stream devices is specified in table 38. This format is required for COPY function codes 0Ah or 0Bh. The segment descriptor may be repeated up to 256 times within the parameter list length specified in the command descriptor block. Table 38 - Segment descriptor for COPY function codes 0Ah and 0Bh +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | Reserved | Cat | Reserved | +-----+-----------------------------------+--------+--------------------------+ | 1 | Reserved | +-----+-----------------------------------------------------------------------+ | 2 | (MSB) | +--- -+--- Source SCSI identifier - -+ | 9 | (LSB) | +-----+-----------------------------------------------------------------------+ | 10 | (MSB) | +--- -+--- Source SCSI LUN - -+ | 17 | (LSB) | +-----+-----------------------------------------------------------------------+ | 18 | (MSB) | +--- -+--- Destination SCSI identifier - -+ | 25 | (LSB) | +-----+-----------------------------------------------------------------------+ | 26 | (MSB) | +--- -+--- Destination SCSI LUN - -+ | 33 | (LSB) | +-----+-----------------------------------------------------------------------+ | 34 | (MSB) | +-----+--- Stream device block length ---+ | 35 | (LSB) | +-----+-----------------------------------------------------------------------+ | 36 | (MSB) | +--- -+--- Block device number of blocks - -+ | 39 | (LSB) | +-----+-----------------------------------------------------------------------+ | 40 | (MSB) | +--- -+--- Block device logical block address - -+ | 43 | (LSB) | +=====+=======================================================================+ The source SCSI identifier and source SCSI LUN fields specify the SCSI target identifier and logical unit of the device to copy the data from for this segment of the COPY command. The destination SCSI identifier and destination SCSI LUN fields specify the SCSI target identifier and logical unit to copy the data to for this segment of the COPY command. Some SCSI devices may not support third-party COPY in which the copying SCSI device is not the source or destination device. Some SCSI devices only support COPY within the SCSI device and not to other SCSI devices. If an unsupported COPY operation is requested, the command shall be terminated with CHECK CONDITION status and the sense key shall be set to ILLEGAL REQUEST with an additional sense code of INVALID FIELD IN PARAMETER LIST (see 8.2.3.1). A catenate (Cat) bit (optional) of one indicates that the COPY manager shall catenate the last source block of a segment with the first source block of the next segment if the last source block does not end exactly at the end of the destination block. The definition of a cat bit of zero depends on the setting of the pad bit in the command descriptor block (see 8.2.3.7). The stream device block-length field specifies the block length to be used on the stream device logical unit during this segment of the COPY command. If the SCSI device managing the COPY knows this block length is not supported, the command shall be terminated with CHECK CONDITION status and the sense key shall be set to ILLEGAL REQUEST with an additional sense code of INVALID FIELD IN PARAMETER LIST. If the block length is found to be invalid while executing a read or write operation to the stream device, the command shall be terminated with CHECK CONDITION status and the sense key shall be set to COPY ABORTED (see 8.2.3.2). The block device number of blocks field specifies the number of blocks in the current segment to be copied. A value of zero indicates that no blocks shall be transferred in this segment. The block device logical block address field specifies the starting logical block address on the logical unit for this segment. 8.2.3.4 COPY function code 0Ch The format for the segment descriptors for COPY transfers among block devices is specified in table 39. This format is required for COPY function code 0Ch. The segment descriptor may be repeated up to 256 times within the parameter list length specified in the command descriptor block. Table 39 - Segment descriptor for COPY function code 0Ch +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | Reserved | DC | Cat | Reserved | +-----+--------------------------+--------+--------+--------------------------+ | 1 | Reserved | +-----+-----------------------------------------------------------------------+ | 2 | (MSB) | +--- -+--- Source SCSI identifier - -+ | 9 | (LSB) | +-----+-----------------------------------------------------------------------+ | 10 | (MSB) | +--- -+--- Source SCSI LUN - -+ | 17 | (LSB) | +-----+-----------------------------------------------------------------------+ | 18 | (MSB) | +--- -+--- Destination SCSI identifier - -+ | 25 | (LSB) | +-----+-----------------------------------------------------------------------+ | 26 | (MSB) | +--- -+--- Destination SCSI LUN - -+ | 33 | (LSB) | +-----+-----------------------------------------------------------------------+ | 34 | Reserved | +-----+-----------------------------------------------------------------------+ | 35 | Reserved | +-----+-----------------------------------------------------------------------+ | 36 | (MSB) | +--- -+--- Number of blocks - -+ | 39 | (LSB) | +-----+-----------------------------------------------------------------------+ | 40 | (MSB) | +--- -+--- Source logical block address - -+ | 43 | (LSB) | +-----+-----------------------------------------------------------------------+ | 44 | (MSB) | +--- -+--- Destination logical block address - -+ | 47 | (LSB) | +=====+=======================================================================+ See 8.2.3.3 for definitions of the source SCSI identifier, the source SCSI LUN, the destination SCSI identifier, the destination SCSI LUN, and CAT fields. A destination count (DC) bit of zero indicates that the number of blocks field refers to the source logical unit. A DC bit of one indicates that the number of blocks field refers to the destination logical unit. The number of blocks field specifies the number of blocks to be transferred to or from (depending on the DC bit) the block device during this segment. A value of zero indicates that no blocks shall be transferred. The source logical block address field specifies the starting logical block address on the source block device. The destination logical block address field specifies the starting logical block address on the destination block device. 8.2.3.5 COPY function code 0Dh The format for the segment descriptors for COPY transfers among stream devices is specified by table 40. This format is required for COPY function code 0Dh. The segment descriptor may be repeated up to 256 times within the parameter list length specified in the command descriptor block. Table 40 - Segment descriptor for COPY function code 0Dh +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | Reserved | DC | Cat | Reserved | +-----+--------------------------+--------+--------+--------------------------+ | 1 | Reserved | +-----+-----------------------------------------------------------------------+ | 2 | (MSB) | +--- -+--- Source SCSI identifier - -+ | 9 | (LSB) | +-----+-----------------------------------------------------------------------+ | 10 | (MSB) | +--- -+--- Source SCSI LUN - -+ | 17 | (LSB) | +-----+-----------------------------------------------------------------------+ | 18 | (MSB) | +--- -+--- Destination SCSI identifier - -+ | 25 | (LSB) | +-----+-----------------------------------------------------------------------+ | 26 | (MSB) | +--- -+--- Destination SCSI LUN - -+ | 33 | (LSB) | +-----+-----------------------------------------------------------------------+ | 34 | Reserved | +-----+-----------------------------------------------------------------------+ | 35 | Reserved | +-----+-----------------------------------------------------------------------+ | 36 | (MSB) | +-----+--- Source block length ---+ | 37 | (LSB) | +-----+-----------------------------------------------------------------------+ | 38 | (MSB) | +-----+--- Destination block length ---+ | 39 | (LSB) | +-----+-----------------------------------------------------------------------+ | 40 | (MSB) | +--- -+--- Number of blocks - -+ | 43 | (LSB) | +=====+=======================================================================+ See 8.2.3.3 for definitions of the source SCSI identifier, the source SCSI LUN, the destination SCSI identifier, the destination SCSI LUN, and CAT fields. A destination count (DC) bit of zero indicates that the number of blocks field refers to the source logical unit. A DC bit of one indicates that the number of blocks field refers to the destination logical unit. The source block length field specifies the block-length of the source device for this segment of the COPY. A zero in this field indicates variable block-length. For non-zero values, this field shall match the logical unit's actual block-length. If block-length mismatches are detected prior to the beginning of the read operation by the SCSI device managing the COPY, the command shall be terminated with CHECK CONDITION status. The sense key shall be set to ILLEGAL REQUEST and the additional sense code shall be set to INVALID FIELD IN PARAMETER LIST (see 8.2.3.1). If the mismatches are detected during the read operation by the COPY manager, the command shall be terminated with CHECK CONDITION status. The sense key shall be set to COPY ABORTED (see 8.2.3.2). and the additional sense code shall be set to INVALID FIELD IN PARAMETER LIST. The destination block-length field specifies the block length to be used on the destination logical unit during the COPY. Destination block length mismatches are handled in an analogous manner as source block length mismatches. The number of blocks field specifies the number of blocks to be transferred to or from (depending on the DC bit) the device during this segment. A value of zero indicates that no blocks shall be transferred. 8.2.3.6 COPY function code 0Eh The format for the segment descriptors for image COPY transfers between sequential-access devices is specified in table 41. This format is required for COPY function code 0Eh. The segment descriptor may be repeated up to 256 times within the parameter list length specified in the command descriptor block. Table 41 - Segment descriptor for COPY function code 0Eh +=====+========+========+========+========+========+========+========+========+ | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |Byte | | | | | | | | | +=====+========+========+========+========+========+========+========+========+ | 0 | Reserved | +-----+-----------------------------------------------------------------------+ | 1 | Reserved | +-----+-----------------------------------------------------------------------+ | 2 | (MSB) | +--- -+--- Source SCSI identifier - -+ | 9 | (LSB) | +-----+-----------------------------------------------------------------------+ | 10 | (MSB) | +--- -+--- Source SCSI LUN - -+ | 17 | (LSB) | +-----+-----------------------------------------------------------------------+ | 18 | (MSB) | +--- -+--- Destination SCSI identifier - -+ | 25 | (LSB) | +-----+-----------------------------------------------------------------------+ | 26 | (MSB) | +--- -+--- Destination SCSI LUN - -+ | 33 | (LSB) | +-----+-----------------------------------------------------------------------+ | 34 | Count | +-----+-----------------------------------------------------------------------+ | 35 | | +--- -+--- Reserved - -+ | 39 | | +-----+-----------------------------------------------------------------------+ | 40 | | +--- -+--- Vendor-specific - -+ | 43 | | +=====+=======================================================================+ See 8.2.3.3 for definitions of the source SCSI identifier, the source SCSI LUN, the destination SCSI identifier, the destination SCSI LUN, and CAT fields. The image mode COPY command copies an exact image of the source device medium to the destination device medium, beginning at their current positions. The copy function terminates when the source device: a) encounters an end-of-partition as defined by the source device; b) encounters an end-of-data as defined by the source device (i.e. BLANK CHECK sense key); c) has copied the number of consecutive filemarks specified in the count field from the source device to the destination device; d) has copied the number of consecutive setmarks specified in the count field from the source device to the destination device, if the RSmk bit in the device configuration page (see 10.3.3.1) is one. A count field of zero indicates that the COPY command shall not terminate due to any number of consecutive filemarks or setmarks. Other error or exception conditions (e.g. early-warning end-of-partition on the destination device) may cause the COPY command to terminate prior to completion. In such cases, it is not possible to calculate a residue, so the information field in the sense data shall be set to zero. 8.2.3.7 Copies with unequal block lengths When copying data between two devices with unequal block lengths, it is possible for the last source block to not completely fill the last destination block for one or more segments in the COPY command. Two optional bits are defined to assist in controlling the copy manager's actions in this circumstance. The Pad bit (in the command descriptor block) and the Cat bit (in each applicable segment descriptor) are defined in table 42. Table 42 - Pad and cat bit definition +=====+=====+=================================================================+ | Pad | Cat | COPY manager's action | +-----+-----+-----------------------------------------------------------------+ | 0 | 0 | On inexact segments, it is device specific whether the COPY | | | | manager rejects the COPY command with CHECK CONDITION status and| | | | ILLEGAL REQUEST sense key, the COPY manager writes or accepts | | | | short blocks (variable-block mode on sequential-access devices),| | | | or the COPY manager adds pad characters (00h) to the destination| | | | block or strips pad characters from the source block. | | | | | | 1 | 0 | On inexact segments, the COPY manager shall add pad characters | | | | (00h) to the destination block to completely fill the block, or | | | | it shall strip pad characters from the source block, always | | | | stopping at the end of a complete block. | | | | | | X | 1 | The COPY manager shall always write or read complete blocks. On| | | | inexact segments, the remainder of the block contains data from | | | | the next segment. This code is not valid in the last segment of| | | | the COPY command. | +=====+=====+=================================================================+ NOTE 63 Use of pad characters is intended to assist in managing COPY commands between devices of different block lengths where partial-block residues may occur. The initiator who issued the COPY command is responsible for management of these pad areas (i.e. remembering where they are). One possible method is to write the COPY parameter list information to the destination medium prior to issuing the COPY command for backup and to read this information prior to issuing the COPY command for restore.