Minor pass-through related fixes and logging improvelemnts

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@217 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2007-11-02 19:20:59 +00:00
parent 9fbca126b3
commit 602b9a8c58
4 changed files with 119 additions and 24 deletions
+4 -4
View File
@@ -1696,10 +1696,10 @@ int scst_get_cdb_info(const uint8_t *cdb_p, int dev_type,
#ifdef EXTRACHECKS
if (unlikely((info_p->transfer_len == 0) &&
(info_p->direction != SCST_DATA_NONE)) &&
!(info_p->flags & SCST_UNKNOWN_LENGTH)) {
PRINT_ERROR("transfer_len 0, direction %d change on %d",
info_p->direction, SCST_DATA_NONE);
(info_p->direction != SCST_DATA_NONE) &&
((info_p->flags & SCST_UNKNOWN_LENGTH) == 0))) {
PRINT_ERROR("transfer_len 0, direction %d, flags %x, changing "
"direction on NONE", info_p->direction, info_p->flags);
info_p->direction = SCST_DATA_NONE;
}
#endif
+73
View File
@@ -1369,6 +1369,77 @@ static struct class_interface scst_interface = {
.remove = scst_remove,
};
static void __init scst_print_config(void)
{
char buf[128];
int i, j;
i = snprintf(buf, sizeof(buf), "Enabled features: ");
j = i;
#ifdef STRICT_SERIALIZING
i += snprintf(&buf[i], sizeof(buf) - i, "Strict serializing");
#endif
#ifdef EXTRACHECKS
i += snprintf(&buf[i], sizeof(buf) - i, "%sEXTRACHECKS",
(j == i) ? "" : ", ");
#endif
#ifdef TRACING
i += snprintf(&buf[i], sizeof(buf) - i, "%sTRACING",
(j == i) ? "" : ", ");
#endif
#ifdef DEBUG
i += snprintf(&buf[i], sizeof(buf) - i, "%sDEBUG",
(j == i) ? "" : ", ");
#endif
#ifdef DEBUG_TM
i += snprintf(&buf[i], sizeof(buf) - i, "%sDEBUG_TM",
(j == i) ? "" : ", ");
#endif
#ifdef DEBUG_RETRY
i += snprintf(&buf[i], sizeof(buf) - i, "%sDEBUG_RETRY",
(j == i) ? "" : ", ");
#endif
#ifdef DEBUG_OOM
i += snprintf(&buf[i], sizeof(buf) - i, "%sDEBUG_OOM",
(j == i) ? "" : ", ");
#endif
#ifdef DEBUG_SN
i += snprintf(&buf[i], sizeof(buf) - i, "%sDEBUG_SN",
(j == i) ? "" : ", ");
#endif
#ifdef USE_EXPECTED_VALUES
i += snprintf(&buf[i], sizeof(buf) - i, "%sUSE_EXPECTED_VALUES",
(j == i) ? "" : ", ");
#endif
#ifdef ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ
i += snprintf(&buf[i], sizeof(buf) - i, "%sALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ",
(j == i) ? "" : ", ");
#endif
#ifdef SCST_STRICT_SECURITY
i += snprintf(&buf[i], sizeof(buf) - i, "%sSCST_STRICT_SECURITY",
(j == i) ? "" : ", ");
#endif
#ifdef SCST_HIGHMEM
i += snprintf(&buf[i], sizeof(buf) - i, "%sSCST_HIGHMEM",
(j == i) ? "" : ", ");
#endif
if (j != i)
PRINT_INFO("%s", buf);
}
static int __init init_scst(void)
{
int res = 0, i;
@@ -1501,6 +1572,8 @@ static int __init init_scst(void)
PRINT_INFO("SCST version %s loaded successfully (max mem for "
"commands %ld Mb)", SCST_VERSION_STRING, scst_max_cmd_mem >> 20);
scst_print_config();
out:
TRACE_EXIT_RES(res);
return res;
+16
View File
@@ -1638,6 +1638,22 @@ static int scst_version_info_show(struct seq_file *seq, void *v)
seq_printf(seq, "DEBUG_SN\n");
#endif
#ifdef USE_EXPECTED_VALUES
seq_printf(seq, "USE_EXPECTED_VALUES\n");
#endif
#ifdef ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ
seq_printf(seq, "ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ\n");
#endif
#ifdef SCST_STRICT_SECURITY
seq_printf(seq, "SCST_STRICT_SECURITY\n");
#endif
#ifdef SCST_HIGHMEM
seq_printf(seq, "SCST_HIGHMEM\n");
#endif
TRACE_EXIT();
return 0;
}
+26 -20
View File
@@ -356,12 +356,13 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
if (scst_cmd_is_expected_set(cmd)) {
/*
* Command data length can't be easily
* determined from the CDB. Get it from
* determined from the CDB. ToDo, that should
* be fixed. Until it's fixed, get it from
* the supplied expected value, but
* limit it to some reasonable value (50MB).
* limit it to some reasonable value (15MB).
*/
cmd->bufflen = min(cmd->expected_transfer_len,
50*1024*1024);
15*1024*1024);
} else
cmd->bufflen = 0;
} else
@@ -428,24 +429,18 @@ call_parse:
goto out_error;
}
if (unlikely(state == SCST_CMD_STATE_XMIT_RESP))
goto set_res;
#ifdef EXTRACHECKS
if ((state != SCST_CMD_STATE_XMIT_RESP) &&
(((cmd->data_direction == SCST_DATA_UNKNOWN) &&
(state != SCST_CMD_STATE_DEV_PARSE)) ||
((cmd->bufflen != 0) &&
(cmd->data_direction == SCST_DATA_NONE) &&
(cmd->status == 0)) ||
((cmd->bufflen == 0) &&
(cmd->data_direction != SCST_DATA_NONE)) ||
((cmd->bufflen != 0) && (cmd->sg == NULL) &&
(state > SCST_CMD_STATE_PREPARE_SPACE))))
{
if ((cmd->bufflen != 0) &&
((cmd->data_direction == SCST_DATA_NONE) ||
((cmd->sg == NULL) && (state > SCST_CMD_STATE_PREPARE_SPACE)))) {
PRINT_ERROR("Dev handler %s parse() returned "
"invalid cmd data_direction %d, "
"bufflen %d or state %d (opcode 0x%x)",
dev->handler->name,
cmd->data_direction, cmd->bufflen,
state, cmd->cdb[0]);
"invalid cmd data_direction %d, bufflen %d, state %d "
"or sg %p (opcode 0x%x)", dev->handler->name,
cmd->data_direction, cmd->bufflen, state, cmd->sg,
cmd->cdb[0]);
goto out_error;
}
#endif
@@ -478,7 +473,8 @@ call_parse:
if (unlikely(cmd->bufflen != cmd->expected_transfer_len)) {
PRINT_INFO("Warning: expected transfer length %d for "
"opcode 0x%02x (handler %s, target %s) doesn't "
"match decoded value %d. Faulty initiator?",
"match decoded value %d. Faulty initiator or "
"scst_scsi_op_table should be updated?",
cmd->expected_transfer_len, cmd->cdb[0],
dev->handler->name, cmd->tgtt->name,
cmd->bufflen);
@@ -486,6 +482,16 @@ call_parse:
#endif
}
if ((cmd->data_direction == SCST_DATA_UNKNOWN) ||
((cmd->bufflen == 0) && (cmd->data_direction != SCST_DATA_NONE))) {
PRINT_ERROR("Wrong data direction (%d) or/and buffer "
"length (%d). Opcode 0x%x, handler %s, target %s",
cmd->data_direction, cmd->bufflen, cmd->cdb[0],
dev->handler->name, cmd->tgtt->name);
goto out_error;
}
set_res:
switch (state) {
case SCST_CMD_STATE_PREPARE_SPACE:
case SCST_CMD_STATE_DEV_PARSE: