[stgt] [PATCH] Implement error checking in VERIFY10/12/16

ronnie sahlberg ronniesahlberg at gmail.com
Thu Jan 26 06:29:11 CET 2012


Tomo, List

Please find attached a patch for VERIFY 10/12/16
It adds support for VERIFY12/16

It also adds verification that the arguments passed from the initiator
are correct (we do not support protection infomatiom)
and return error for invalid requests.

If BYTECHK == 1  we also verify the data with the content of the medium.
If there is a mismatch we return check-condition with key==MISCOMPARE
and the proper ASCQ



Please also find a small capture file showing TGTD returning proper
MISCOMPARE when a VERIFY10 request comes in with bad data (one byte
modified in one of the blocks)


To test VERIFY10 failure I created VERIFY10 test cases for the
libiscsi test tool to verify that a target responds GOOD when VERIFY10
matches the data on the medium and that the target responds MISMATCH
if the data is known to be bad.



regards
ronnie sahlberg


On Thu, Jan 26, 2012 at 12:00 PM, FUJITA Tomonori
<fujita.tomonori at lab.ntt.co.jp> wrote:
> On Thu, 26 Jan 2012 11:17:39 +1100
> ronnie sahlberg <ronniesahlberg at gmail.com> wrote:
>
>> From dfb19f35441d137ef4b82cec924a8746cb1c040d Mon Sep 17 00:00:00 2001
>> From: Ronnie Sahlberg <ronniesahlberg at gmail.com>
>> Date: Thu, 26 Jan 2012 10:35:22 +1100
>> Subject: [PATCH] SBC VERIFY: Update VERIFY to check vprotect argument
>>
>> TGTD does not support formatting protection information so make
>> TGTD fail a VERIFY command requesting vprotect != 0 with a proper
>> check condition.
>>
>> Add VERIFY12/VERIFY16. These are both identical to the already existing VERIFY10 as far as we are converned.
>>
>> See SBC 5.22 VERIFY 10 COMMAND,  tables 65 and 66
>> If the media is not formatted with protection information (as in TGTD)
>> any value of vprotect other than 000b is an error condition and the device h
>>
>> Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
>> ---
>>  usr/sbc.c |   25 ++++++++++++++++++++++---
>>  1 files changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/usr/sbc.c b/usr/sbc.c
>> index 53e785b..23b1778 100644
>> --- a/usr/sbc.c
>> +++ b/usr/sbc.c
>> @@ -265,7 +265,26 @@ sense:
>>
>>  static int sbc_verify(int host_no, struct scsi_cmd *cmd)
>>  {
>> -     return SAM_STAT_GOOD;
>> +     unsigned char key;
>> +     uint16_t asc;
>> +     int vprotect;
>> +
>> +     vprotect = cmd->scb[1] & 0xe0;
>> +     if (vprotect != 0) {
>> +             /* we dont support formatting with protection information,
>> +              * so all verify with vprotect!=0 is an error condition
>> +              */
>> +             key = ILLEGAL_REQUEST;
>> +             asc = ASC_INVALID_FIELD_IN_CDB;
>> +             goto sense;
>> +     }
>> +
>> +     return SAM_STAT_GOOD;
>
> Hmm, should we implement VERIFY (such as data comparison) instead of
> returning GOOD if we replace illegal_op?
>
>
>> +sense:
>> +     scsi_set_in_resid_by_actual(cmd, 0);
>> +     sense_data_build(cmd, key, asc);
>> +     return SAM_STAT_CHECK_CONDITION;
>>  }
>>
>>  static int sbc_service_action(int host_no, struct scsi_cmd *cmd)
>> @@ -506,7 +525,7 @@ static struct device_type_template sbc_template = {
>>               {spc_illegal_op,},
>>               {spc_illegal_op,},
>>               {spc_illegal_op,},
>> -             {spc_illegal_op,},
>> +             {sbc_verify, NULL, PR_EA_FA|PR_EA_FN},
>>
>>               /* 0x90 */
>>               {sbc_rw, NULL, PR_EA_FA|PR_EA_FN}, /*PRE_FETCH_16 */
>> @@ -544,7 +563,7 @@ static struct device_type_template sbc_template = {
>>               {spc_illegal_op,},
>>               {spc_illegal_op,},
>>               {spc_illegal_op,},
>> -             {spc_illegal_op,},
>> +             {sbc_verify, NULL, PR_EA_FA|PR_EA_FN},
>>
>>               [0xb0 ... 0xff] = {spc_illegal_op},
>>       }
>> --
>> 1.7.3.1
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SBC-VERIFY-implement-VERIFY-10-12-16-and-check-the-a.patch
Type: text/x-diff
Size: 5480 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20120126/e53ae287/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SBC-VERIFY-implement-VERIFY-10-12-16-and-check-the-a.patch.gz
Type: application/x-gzip
Size: 2162 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20120126/e53ae287/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VERIFY10-miscompare.cap
Type: application/cap
Size: 2600 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20120126/e53ae287/attachment-0004.bin>


More information about the stgt mailing list