From 4a5b7bc8e6257e3a786aa05d8a52c7d89d4ebca1 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 21 Mar 2014 01:58:13 +0000 Subject: [PATCH] In VERIFY commands BYTCHK 1x is not supported (yet) git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5360 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_const.h | 1 - scst/src/dev_handlers/scst_vdisk.c | 2 +- scst/src/scst_lib.c | 40 +++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index afcbbf944..b9a6b0e38 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -560,7 +560,6 @@ enum scst_tg_sup { ** Misc SCSI constants *************************************************************/ #define SCST_SENSE_ASC_UA_RESET 0x29 -#define BYTCHK 0x02 #define POSITION_LEN_SHORT 20 #define POSITION_LEN_LONG 32 diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 582fe4380..111246e8b 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -4589,7 +4589,7 @@ static enum compl_status_e vdev_exec_verify(struct vdisk_cmd_params *p) */ compare = scst_cmd_get_data_direction(cmd) == SCST_DATA_WRITE; - TRACE_DBG("VERIFY with BYTCHK=%d at offset %lld and len %lld\n", + TRACE_DBG("VERIFY with compare %d at offset %lld and len %lld\n", compare, loff, (long long)data_len); mem_verify = vmalloc(LEN_MEM); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 8cdb20328..576df4778 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6478,8 +6478,16 @@ static int get_cdb_info_fmt(struct scst_cmd *cmd, static int get_cdb_info_verify10(struct scst_cmd *cmd, const struct scst_sdbops *sdbops) { + if (unlikely(cmd->cdb[1] & 4)) { + PRINT_ERROR("VERIFY(10): BYTCHK 1x not supported (dev %s)", + cmd->dev ? cmd->dev->virt_name : NULL); + scst_set_invalid_field_in_cdb(cmd, 1, + 2 | SCST_INVAL_FIELD_BIT_OFFS_VALID); + return 1; + } + cmd->lba = get_unaligned_be32(cmd->cdb + sdbops->info_lba_off); - if (cmd->cdb[1] & BYTCHK) { + if (cmd->cdb[1] & 2) { cmd->bufflen = get_unaligned_be16(cmd->cdb + sdbops->info_len_off); cmd->data_len = cmd->bufflen; cmd->data_direction = SCST_DATA_WRITE; @@ -6497,7 +6505,15 @@ static int get_cdb_info_verify6(struct scst_cmd *cmd, cmd->op_flags |= SCST_LBA_NOT_VALID; cmd->lba = 0; - if (cmd->cdb[1] & BYTCHK) { + if (unlikely(cmd->cdb[1] & 4)) { + PRINT_ERROR("VERIFY(6): BYTCHK 1x not supported (dev %s)", + cmd->dev ? cmd->dev->virt_name : NULL); + scst_set_invalid_field_in_cdb(cmd, 1, + 2 | SCST_INVAL_FIELD_BIT_OFFS_VALID); + return 1; + } + + if (cmd->cdb[1] & 2) { /* BYTCHK 01 */ cmd->bufflen = get_unaligned_be24(cmd->cdb + sdbops->info_len_off); cmd->data_len = cmd->bufflen; cmd->data_direction = SCST_DATA_WRITE; @@ -6512,8 +6528,16 @@ static int get_cdb_info_verify6(struct scst_cmd *cmd, static int get_cdb_info_verify12(struct scst_cmd *cmd, const struct scst_sdbops *sdbops) { + if (unlikely(cmd->cdb[1] & 4)) { + PRINT_ERROR("VERIFY(12): BYTCHK 1x not supported (dev %s)", + cmd->dev ? cmd->dev->virt_name : NULL); + scst_set_invalid_field_in_cdb(cmd, 1, + 2 | SCST_INVAL_FIELD_BIT_OFFS_VALID); + return 1; + } + cmd->lba = get_unaligned_be32(cmd->cdb + sdbops->info_lba_off); - if (cmd->cdb[1] & BYTCHK) { + if (cmd->cdb[1] & 2) { /* BYTCHK 01 */ cmd->bufflen = get_unaligned_be32(cmd->cdb + sdbops->info_len_off); if (unlikely(cmd->bufflen & SCST_MAX_VALID_BUFFLEN_MASK)) { PRINT_ERROR("Too big bufflen %d (op %x)", @@ -6534,8 +6558,16 @@ static int get_cdb_info_verify12(struct scst_cmd *cmd, static int get_cdb_info_verify16(struct scst_cmd *cmd, const struct scst_sdbops *sdbops) { + if (unlikely(cmd->cdb[1] & 4)) { + PRINT_ERROR("VERIFY(16): BYTCHK 1x not supported (dev %s)", + cmd->dev ? cmd->dev->virt_name : NULL); + scst_set_invalid_field_in_cdb(cmd, 1, + 2 | SCST_INVAL_FIELD_BIT_OFFS_VALID); + return 1; + } + cmd->lba = get_unaligned_be64(cmd->cdb + sdbops->info_lba_off); - if (cmd->cdb[1] & BYTCHK) { + if (cmd->cdb[1] & 2) { /* BYTCHK 01 */ cmd->bufflen = get_unaligned_be32(cmd->cdb + sdbops->info_len_off); if (unlikely(cmd->bufflen & SCST_MAX_VALID_BUFFLEN_MASK)) { PRINT_ERROR("Too big bufflen %d (op %x)",