From 40d6dbbe6c4b04399dae2aad80c8e3ba3725f351 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 2 Nov 2006 12:10:53 +0000 Subject: [PATCH] Serving commands, whose expected data len is less, than maximum, fixed. Particularly, it affected READ CAPACITY(16) from Linux initiators git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@26 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_cdbprobe.h | 4 ++-- scst/src/scst_lib.c | 5 ++--- scst/src/scst_targ.c | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/scst/src/scst_cdbprobe.h b/scst/src/scst_cdbprobe.h index f16a63077..ad56345d7 100644 --- a/scst/src/scst_cdbprobe.h +++ b/scst/src/scst_cdbprobe.h @@ -385,8 +385,8 @@ static const struct scst_sdbops scst_scsi_op_table[] = { SCST_DATA_WRITE, 4, SCST_UNKNOWN_LENGTH, 1, 0}, /*N2! */ {0x93, " M ", "ERASE(16)", SCST_DATA_NONE, 0, SCST_LONG_TIMEOUT, 0, 0}, - {0x9E, "M ", "SERVICE ACTION IN", - SCST_DATA_READ, 4, 0, 0, 0}, + {0x9E, "O ", "SERVICE ACTION IN", + SCST_DATA_READ, 0, 0, 0, 0}, /* 12-bytes length CDB */ {0xA0, "VVVVVVVVVV M ", "REPORT LUN", diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 43497c34c..d87dcdd22 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1485,9 +1485,8 @@ int scst_get_cdb_info(const uint8_t *cdb_p, int dev_type, } } if (!info_p->transfer_len) { - TRACE(TRACE_SCSI, - "Warning! transfer_len 0, direction %d change on " "%d", - info_p->direction, SCST_DATA_NONE); + TRACE_DBG("Warning! transfer_len 0, direction %d change on %d", + info_p->direction, SCST_DATA_NONE); info_p->direction = SCST_DATA_NONE; } diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 26e9ef050..b90bf64b3 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -374,15 +374,25 @@ static int scst_parse_cmd(struct scst_cmd *cmd) TRACE_DBG("Dev handler %s parse() returned %d", dev->handler->name, state); - if (cmd->data_len == -1) - cmd->data_len = cmd->bufflen; - if (state == SCST_CMD_STATE_DEFAULT) state = SCST_CMD_STATE_PREPARE_SPACE; } else state = SCST_CMD_STATE_PREPARE_SPACE; + if (scst_cmd_is_expected_set(cmd)) { + if (cmd->expected_transfer_len < cmd->bufflen) { + TRACE(TRACE_SCSI, "cmd->expected_transfer_len(%d) < " + "cmd->bufflen(%d), using expected_transfer_len " + "instead", cmd->expected_transfer_len, + cmd->bufflen); + cmd->bufflen = cmd->expected_transfer_len; + } + } + + if (cmd->data_len == -1) + cmd->data_len = cmd->bufflen; + #ifdef EXTRACHECKS if (state != SCST_CMD_STATE_NEED_THREAD_CTX) { if (((cmd->data_direction == SCST_DATA_UNKNOWN) &&