From 50af04800a9ea1175d3fbb37276c6e26a5b2d138 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 8 Oct 2008 17:36:08 +0000 Subject: [PATCH] Cleanups git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@519 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 1 + scst/src/scst_cdbprobe.h | 16 ++++++++++++---- scst/src/scst_lib.c | 6 ++++++ scst/src/scst_targ.c | 39 +++++++++++++++++++++++++++++---------- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index a3286d5a9..e1f16c142 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -419,6 +419,7 @@ enum scst_cdb_flags { SCST_LONG_TIMEOUT = 0x04, SCST_UNKNOWN_LENGTH = 0x08, SCST_INFO_INVALID = 0x10, + SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED = 0x20, }; /* diff --git a/scst/src/scst_cdbprobe.h b/scst/src/scst_cdbprobe.h index c4b94e864..11f3555c9 100644 --- a/scst/src/scst_cdbprobe.h +++ b/scst/src/scst_cdbprobe.h @@ -174,7 +174,9 @@ static const struct scst_sdbops scst_scsi_op_table[] = { {0x12, "MMMMMMMMMMMMMMMM", "INQUIRY", SCST_DATA_READ, SCST_SMALL_TIMEOUT, 4, get_trans_len_1}, {0x13, "VOVVVV ", "VERIFY(6)", - SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED, 2, get_trans_len_3}, + SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED| + SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED, + 2, get_trans_len_3}, {0x14, "VOOVVV ", "RECOVER BUFFERED DATA", SCST_DATA_READ, SCST_TRANSFER_LEN_TYPE_FIXED, 2, get_trans_len_3}, {0x15, "OMOOOOOOOOOOOOOO", "MODE SELECT(6)", @@ -250,7 +252,9 @@ static const struct scst_sdbops scst_scsi_op_table[] = { {0x2E, "O OO O ", "WRITE AND VERIFY(10)", SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 7, get_trans_len_2}, {0x2F, "O OO O ", "VERIFY(10)", - SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED, 7, get_trans_len_2}, + SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED| + SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED, + 7, get_trans_len_2}, {0x33, "O OO O ", "SET LIMITS(10)", SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none}, {0x34, " O ", "READ POSITION", @@ -378,7 +382,9 @@ static const struct scst_sdbops scst_scsi_op_table[] = { {0x8E, "O OO O ", "WRITE AND VERIFY(16)", SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 10, get_trans_len_4}, {0x8F, "O OO O ", "VERIFY(16)", - SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED, 10, get_trans_len_4}, + SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED| + SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED, + 10, get_trans_len_4}, {0x90, "O OO O ", "PRE-FETCH(16)", SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none}, {0x91, "O OO O ", "SYNCHRONIZE CACHE(16)", @@ -442,7 +448,9 @@ static const struct scst_sdbops scst_scsi_op_table[] = { {0xAE, "O OO O ", "WRITE AND VERIFY(12)", SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 6, get_trans_len_4}, {0xAF, "O OO O ", "VERIFY(12)", - SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED, 6, get_trans_len_4}, + SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED| + SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED, + 6, get_trans_len_4}, /* No need to support at all. {0xB0, " OO O ", "SEARCH DATA HIGH(12)", SCST_DATA_WRITE, FLAG_NONE, 9, get_trans_len_1}, diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 22d5a8d60..3b30a137c 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1323,6 +1323,12 @@ void scst_sched_session_free(struct scst_session *sess) TRACE_ENTRY(); + if (sess->shut_phase != SCST_SESS_SPH_SHUTDOWN) { + PRINT_CRIT_ERROR("session %p is going to shutdown with unknown " + "shut phase %lx", sess, sess->shut_phase); + sBUG(); + } + spin_lock_irqsave(&scst_mgmt_lock, flags); TRACE_DBG("Adding sess %p to scst_sess_shut_list", sess); list_add_tail(&sess->sess_shut_list_entry, &scst_sess_shut_list); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 3629d4330..68196ac68 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -434,6 +434,31 @@ out_xmit: goto out; } +#ifndef CONFIG_SCST_USE_EXPECTED_VALUES +static bool scst_is_allowed_to_mismatch_cmd(struct scst_cmd *cmd) +{ + bool res = false; + + switch (cmd->cdb[0]) { + case TEST_UNIT_READY: + /* Crazy VMware people sometimes do TUR with READ direction */ + res = true; + break; + case VERIFY: + case VERIFY_6: + case VERIFY_12: + case VERIFY_16: + /* VERIFY commands with BYTCHK unset shouldn't fail here */ + if (((cmd->op_flags & SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED) != 0) && + (cmd->cdb[1] & BYTCHK) == 0) + res = true; + break; + } + + return res; +} +#endif + static int scst_parse_cmd(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_RES_CONT_SAME; @@ -513,12 +538,12 @@ static int scst_parse_cmd(struct scst_cmd *cmd) # ifdef CONFIG_SCST_EXTRACHECKS if ((cmd->data_direction != cmd->expected_data_direction) || (cmd->bufflen != cmd->expected_transfer_len)) { - PRINT_ERROR("Expected values don't match decoded ones: " + PRINT_WARNING("Expected values don't match decoded ones: " "data_direction %d, expected_data_direction %d, " "bufflen %d, expected_transfer_len %d", cmd->data_direction, cmd->expected_data_direction, cmd->bufflen, cmd->expected_transfer_len); - PRINT_BUFFER("Failed CDB", cmd->cdb, cmd->cdb_len); + PRINT_BUFFER("Suspicious CDB", cmd->cdb, cmd->cdb_len); } # endif cmd->data_direction = cmd->expected_data_direction; @@ -526,13 +551,8 @@ static int scst_parse_cmd(struct scst_cmd *cmd) #else if (unlikely(cmd->data_direction != cmd->expected_data_direction)) { if (((cmd->expected_data_direction != SCST_DATA_NONE) || - (cmd->bufflen != 0)) && - /* Crazy VMware people sometimes do TUR with READ direction */ - (!(cmd->cdb[0] == TEST_UNIT_READY) && - /* VERIFY commands with BYTCHK unset shouldn't fail here */ - !(((cmd->cdb[0] == VERIFY) || (cmd->cdb[0] == VERIFY_6) || - (cmd->cdb[0] == VERIFY_12) || (cmd->cdb[0] == VERIFY_16)) && - ((cmd->cdb[1] & BYTCHK) == 0)))) { + (cmd->bufflen != 0)) && + !scst_is_allowed_to_mismatch_cmd(cmd)) { PRINT_ERROR("Expected data direction %d for opcode " "0x%02x (handler %s, target %s) doesn't match " "decoded value %d", cmd->expected_data_direction, @@ -546,7 +566,6 @@ static int scst_parse_cmd(struct scst_cmd *cmd) } if (unlikely(cmd->bufflen != cmd->expected_transfer_len)) { static int repd; - if (repd < 100) { /* * Intentionally unlocked. Few messages more