Better version of the previous patch

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5247 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2014-01-29 04:16:58 +00:00
parent b0a7ab2210
commit e9ef3fa2d1
3 changed files with 24 additions and 20 deletions

View File

@@ -1951,6 +1951,9 @@ struct scst_cmd {
/* Set if cmd is queued as hw pending */
unsigned int cmd_hw_pending:1;
/* Set if cmd has NACA bit set in CDB */
unsigned int cmd_naca:1;
/*
* Set if the target driver wants to alloc data buffers on its own.
* In this case tgt_alloc_data_buf() must be provided in the target
@@ -2030,6 +2033,9 @@ struct scst_cmd {
/* Set if scst_cmd_set_write_not_received_data_len() was called */
unsigned int write_not_received_set:1;
/* Set if cmd has LINK bit set in CDB */
unsigned int cmd_linked:1;
/**************************************************************/
/* cmd's async flags */

View File

@@ -6825,7 +6825,6 @@ int scst_get_cdb_info(struct scst_cmd *cmd)
int dev_type = cmd->dev->type;
int i, res = 0;
uint8_t op;
uint8_t control;
const struct scst_sdbops *ptr = NULL;
TRACE_ENTRY();
@@ -6871,7 +6870,8 @@ int scst_get_cdb_info(struct scst_cmd *cmd)
}
cmd->cdb_len = SCST_GET_CDB_LEN(op);
control = cmd->cdb[cmd->cdb_len - 1];
cmd->cmd_naca = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_NACA_BIT);
cmd->cmd_linked = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_LINK_BIT);
cmd->op_name = ptr->info_op_name;
cmd->data_direction = ptr->info_data_direction;
cmd->op_flags = ptr->info_op_flags | SCST_INFO_VALID;
@@ -6881,24 +6881,6 @@ int scst_get_cdb_info(struct scst_cmd *cmd)
cmd->len_len = ptr->info_len_len;
res = (*ptr->get_cdb_info)(cmd, ptr);
if (unlikely(control & CONTROL_BYTE_NACA_BIT)) {
PRINT_ERROR("NACA bit in control byte CDB is not supported "
"(opcode 0x%02x)", cmd->cdb[0]);
scst_set_cmd_error(cmd,
SCST_LOAD_SENSE(scst_sense_invalid_message));
res = 1; /* command invalid */
goto out;
}
if (unlikely(control & CONTROL_BYTE_LINK_BIT)) {
PRINT_ERROR("Linked commands are not supported "
"(opcode 0x%02x)", cmd->cdb[0]);
scst_set_invalid_field_in_cdb(cmd, cmd->cdb_len-1,
SCST_INVAL_FIELD_BIT_OFFS_VALID | 0);
res = 1; /* command invalid */
goto out;
}
out:
TRACE_EXIT_RES(res);
return res;

View File

@@ -744,6 +744,22 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
cmd->op_flags &= ~SCST_UNKNOWN_LENGTH;
}
if (unlikely(cmd->cmd_naca)) {
PRINT_ERROR("NACA bit in control byte CDB is not supported "
"(opcode 0x%02x)", cmd->cdb[0]);
scst_set_cmd_error(cmd,
SCST_LOAD_SENSE(scst_sense_invalid_message));
goto out_done;
}
if (unlikely(cmd->cmd_linked)) {
PRINT_ERROR("Linked commands are not supported "
"(opcode 0x%02x)", cmd->cdb[0]);
scst_set_invalid_field_in_cdb(cmd, cmd->cdb_len-1,
SCST_INVAL_FIELD_BIT_OFFS_VALID | 0);
goto out_done;
}
if (cmd->dh_data_buf_alloced &&
unlikely((orig_bufflen > cmd->bufflen))) {
PRINT_ERROR("Dev handler supplied data buffer (size %d), "