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

ronnie sahlberg ronniesahlberg at gmail.com
Fri Jan 27 04:55:30 CET 2012


On Fri, Jan 27, 2012 at 2:35 PM, FUJITA Tomonori
<fujita.tomonori at lab.ntt.co.jp> wrote:
> On Fri, 27 Jan 2012 09:19:14 +1100
> ronnie sahlberg <ronniesahlberg at gmail.com> wrote:
>
>> From 697c5dacd9897b3b1b0bf2d8d70956d930f2d1a9 Mon Sep 17 00:00:00 2001
>> From: Ronnie Sahlberg <ronniesahlberg at gmail.com>
>> Date: Fri, 27 Jan 2012 09:18:00 +1100
>> Subject: [PATCH] SBC VERIFY: implement VERIFY 10/12/16 and check the arguments
>>
>> TGTD does not support formatting protection information so make
>> TGTD fail a VERIFY command requesting vprotect != 0 with a proper
>> check condition.
>>
>> 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.
>>
>> If BYTCHK==1 we must also verify the DATA-OUT buffer with the content of the media. Add a check that the data matches and return sense key:MISMATCH and the proper ASCQ if a mismatch is found.
>>
>> Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
>> ---
>>  usr/bs_rdwr.c |   26 ++++++++++++++++++++++++++
>>  usr/sbc.c     |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
>>  usr/scsi.c    |    6 +++---
>>  usr/scsi.h    |    5 ++++-
>>  4 files changed, 83 insertions(+), 6 deletions(-)
>>
>> diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c
>> index acee73c..c6f6845 100644
>> --- a/usr/bs_rdwr.c
>> +++ b/usr/bs_rdwr.c
>> @@ -62,6 +62,7 @@ static void bs_rdwr_request(struct scsi_cmd *cmd)
>>       int result = SAM_STAT_GOOD;
>>       uint8_t key;
>>       uint16_t asc;
>> +     char *tmpbuf;
>>
>>       ret = length = 0;
>>       key = asc = 0;
>> @@ -121,6 +122,31 @@ static void bs_rdwr_request(struct scsi_cmd *cmd)
>>               if (ret != 0)
>>                       set_medium_error(&result, &key, &asc);
>>               break;
>> +     case VERIFY_10:
>> +     case VERIFY_12:
>> +     case VERIFY_16:
>> +             length = scsi_get_out_length(cmd);
>> +
>> +             tmpbuf = malloc(length);
>> +             if (!tmpbuf) {
>> +                     result = SAM_STAT_CHECK_CONDITION;
>> +                     key = HARDWARE_ERROR;
>> +                     asc = ASC_INTERNAL_TGT_FAILURE;
>> +                     break;
>> +             }
>> +
>> +             ret = pread64(fd, tmpbuf, length, cmd->offset);
>> +
>> +             if (ret != length)
>> +                     set_medium_error(&result, &key, &asc);
>> +             else if (memcmp(scsi_get_out_buffer(cmd), tmpbuf, length)) {
>> +                     result = SAM_STAT_CHECK_CONDITION;
>> +                     key = MISCOMPARE;
>> +                     asc = ASC_MISCOMPARE_DURING_VERIFY_OPERATION;
>> +             }
>> +
>> +             free(tmpbuf);
>> +             break;
>>       default:
>>               break;
>>       }
>> diff --git a/usr/sbc.c b/usr/sbc.c
>> index 53e785b..d483732 100644
>> --- a/usr/sbc.c
>> +++ b/usr/sbc.c
>> @@ -265,7 +265,55 @@ sense:
>>
>>  static int sbc_verify(int host_no, struct scsi_cmd *cmd)
>>  {
>> +     struct scsi_lu *lu = cmd->dev;
>> +     unsigned char key;
>> +     uint16_t asc;
>> +     int vprotect, bytchk, ret;
>> +     uint64_t lba;
>> +     uint32_t tl;
>> +
>> +     vprotect = cmd->scb[1] & 0xe0;
>> +     if (!vprotect) {
>
> if (vprotect)
>
> ?
>
> I modified this part and applied the patch.
>
> Please make sure that the latest git tree works.


Yes  it should be if (vprotect)

Thanks.

I have compiled the latest git and have run my VERIFY10 test cases
against it and it all looks good!

thanks
ronnie sahlberg
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list