Document: X3T9.2/87-128 Date: 6 August 1987 To: X3T9.2 SCSI-2 Working Group and X3T9.2 Committee Members From: Paul R. Nitza - (714) 662-5600 Subj: Proposed Search Command Modification ============================================================================= Attached for your review is a proposal for modifying the Search command to provide an enhanced mode which better suites the needs of todays operating systems. In todays operating system environment the allocation of logical blocks is normally done using a first fit or first available algorithm. As the file system is used fragmentation occurs and blocks are not normally allocated on a contiguous basis. This proposal provides a means for the target to search logical blocks which are not contiguous on the device for a given pattern, yet maintains backwards compatibility with SCSI-1 and will not effect current products. SEARCH DATA Commands Peripheral Device Type: Direct Access, Write-Once Read-Multiple, and Read-Only Direct Access Operation Code Type: Optional SEARCH DATA Commands ============================================================================== Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | Byte | | | | | | | | | ============================================================================== 0 | Operation Code (30h 31h 32h) | -----|-----------------------------------------------------------------------| 1 | Logical Unit Number | Invert | LBAList|Reserved| SpnDat | RelAdr | -----|-----------------------------------------------------------------------| 2 | (MSB) | -----|--- ---| 3 | | -----|--- Logical Block Address ---| 4 | | -----|--- ---| 5 | (LSB) | -----|-----------------------------------------------------------------------| 6 | Reserved | -----|-----------------------------------------------------------------------| 7 | (MSB) | -----|--- Transfer Length | 8 | (LSB) | -----|-----------------------------------------------------------------------| 9 | Control Byte | ============================================================================== The SEARCH DATA commands (Table 8-38) search one or more logical blocks for equality or inequality to a data pattern. The concept of records within a logical block is used to allow multiple records within a logical block to be searched. A LBA List (LBAList) bit of one indicates that a logical block list shall be sent by the initiator during the DATA OUT phase. The target shall ignore the Logical Block Address and Transfer Length fields in the CDB and use the list of logical blocks in the parameter list to determine which logical blocks to perform the search operation on. A LBAList bit of zero indicates the no logical block list will be sent during the DATA OUT phase. The search operation starts at the Logical Block Address specified in the CDB and continues for the number of contiguous blocks specified in the Transfer Length field or until the number of specified records have been searched. The invert bit determines whether the search condition is to be inverted. See 8.1.17.1 through 8.1.17.3 for a description of the search conditions for the individual SEARCH DATA commands. A spanned data (SpnDat) bit of zero indicates that each record shall be wholly contained within a single block. Any space at the end of a block that is smaller than the record length is ignored by the SEARCH DATA commands. A SpnDat bit of one indicates that records span block boundaries. Thus, a record may start in one block and end in the next or a subsequent block. A transfer length of zero indicates that no data shall be searched. This condition shall be treated the same as an unsatisfied search. A link bit of zero indicates a nonlinked command and if the search is satisfied, the command shall be terminated with a CONDITION MET status. A REQUEST SENSE command can then be issued to determine the logical block address and record offset of the matching record. If the search is not satisfied and no error occurs, the command shall be terminated with GOOD status. A link bit of one indicates a command is linked to the SEARCH DATA command and if the search is satisfied, CONDITION MET status is returned and the next command is executed. If the RelAdr bit in the next command is one, the logical block address of the next command is used as a displacement from the logical block address at which the search was satisfied. If a linked search is not satisfied, the command is terminated with a CHECK CONDITION status. A REQUEST SENSE command may then be issued. A REQUEST SENSE command following a satisfied SEARCH DATA command shall: (1) Return a sense key of EQUAL if the search was satisfied by an exact match. If the search was satisfied by an inequality then a sense key of NO SENSE shall be returned. (2) Return the valid bit set to one. (3) Return the logical block address of the logical block containing the first matching record in the information bytes. (4) Return the record offset of the matching record in the first four bytes of additional sense bytes. A REQUEST SENSE command following an unsatisfied SEARCH DATA command shall: (1) Return a sense key of NO SENSE, if no errors occurred during the command execution. (2) Return the valid bit set to zero. The SEARCH DATA parameter list (Table 8-39) contains a fourteen-byte header, followed by one or more search argument descriptors and the optional logical block list if the LBAList bit is set to one. SEARCH DATA Parameter List ============================================================================== Byte | Parameter List Header | ============================================================================== 0 | (MSB) | - - -|- - Logical Record Length - -| 3 | (LSB) | -----|-----------------------------------------------------------------------| 4 | (MSB) | - - -|- - First Record Offset - -| 7 | (LSB) | -----|-----------------------------------------------------------------------| 8 | (MSB) | - - -|- - Number of Records - -| 11 | (LSB) | -----|-----------------------------------------------------------------------| 12 | (MSB) | -----|--- Search Argument Length ---| 13 | (LSB) | ============================================================================== | Search Argument Descriptor(s) | ============================================================================== 0 | (MSB) | - - -|- - Displacement - -| 3 | (LSB) | -----|-----------------------------------------------------------------------| 4 | (MSB) | -----|--- Pattern Length ---| 5 | (LSB) | -----|-----------------------------------------------------------------------| 6 - n| Pattern | ============================================================================== | Logical Block List (Optional) | ============================================================================== 0 | (MSB) | - - -|- - LBA List Length - -| 3 | (LSB) | -----|-----------------------------------------------------------------------| 4 | (MSB) | - - -|- - Logical Block Address 1 - -| 7 | (LSB) | -----|-----------------------------------------------------------------------| | . . | | . . | | . . | -----|-----------------------------------------------------------------------| n | (MSB) | - - -|- - Logical Block Address n - -| n+3 | (LSB) | ============================================================================== The logical record length field specifies the record length in bytes. The first record offset field specifies the number of bytes that shall be ignored in the first logical block before the search begins. The value in the first record offset field shall not exceed the length of the logical block. Subsequent logical blocks shall be searched beginning with the first byte in the logical block. This permits one or more records to be skipped initially. The number of records field specifies the maximum number of records that shall be searched by this command. An unsatisfied search shall terminate when the number of records or the number of blocks (from the command descriptor block) have been exhausted. The search argument length specifies the length in bytes of all the search argument descriptors that follow. Since the pattern length can vary, there is no fixed multiple of the search argument descriptor to determine the search argument length. The search argument descriptors specify one or more search conditions to execute within a single record in order to satisfy the search. Each search argument descriptor is made up of a displacement, a pattern length, and a pattern. The displacement field specifies the displacement in bytes of the first byte of the data to be compared from the start of the logical record. The pattern length field specifies the length in bytes of the pattern that follows. The pattern specifies the data to compare to the logical record. The optional Logical Block List allows the initiator to perform searches on blocks that are not contiguous. The list shall only be sent by the initiator when the LBAList bit in the CDB is set to one. The LBA List Length field specifies the length of the Logical Block List in bytes. The target can determine the number of logical blocks in the list by dividing the number in this field by four. Each Logical Block Address in the list specifies a single logical block the target shall perform the specified search operation on. The target shall start the search operation at the block specified in the first entry and shall continue the search operation through each logical block within the list. The operation shall continue until the Logical Block list is exhausted or the specified number of records have been searched. SEARCH DATA HIGH Command The SEARCH DATA HIGH command (Table 8-38, operation code 30h) shall be satisfied by the first logical record searched that contains data that satisfies all of the search argument descriptor(s). If the invert bit in the command descriptor block is zero, the search argument descriptor(s) shall be satisfied by data in the logical record being greater than the data in the pattern. If the invert bit is one, the search argument descriptor(s) shall be satisfied by data in the logical record being less than or equal to the data in the pattern. (See 8.1.17.) SEARCH DATA EQUAL Command The SEARCH DATA EQUAL command (Table 8-38, operation code 31h) shall be satisfied by the first logical record searched that contains data that satisfies all of the search argument descriptor(s). If the invert bit in the command descriptor block is zero, the search argument descriptor(s) shall be satisfied by data in the logical record being equal to the data in the pattern. If the invert bit is one, the search argument descriptor(s) shall be satisfied by data in the logical record being not equal to the data in the pattern. (See 8.1.17.) SEARCH DATA LOW Command The SEARCH DATA LOW command (Table 8-38, operation code 32h) shall be satisfied by the first logical record searched that contains data that satisfies all of the search argument descriptor(s). If the invert bit in the command descriptor block is zero, the search argument descriptor(s) shall be satisfied by data in the logical record being less than the data in the pattern. If the invert bit is one, the search argument descriptor(s) shall be satisfied by data in the logical record being greater than or equal to the data in the pattern. (See 8.1.17.)