mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-18 03:01:26 +00:00
Zero size descriptor are possible, so we have to add cmd_data_descriptors_cnt to track their count.
+ small cleanup git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4412 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2122,10 +2122,10 @@ struct scst_cmd {
|
||||
|
||||
/*
|
||||
* List of parsed data descriptors for commands operating with
|
||||
* several lba and data_len pairs, like UNMAP, finished with zero
|
||||
* length entry.
|
||||
* several lba and data_len pairs, like UNMAP, and its size in elements.
|
||||
*/
|
||||
void *cmd_data_descriptors;
|
||||
int cmd_data_descriptors_cnt;
|
||||
|
||||
#ifdef CONFIG_SCST_MEASURE_LATENCY
|
||||
/*
|
||||
|
||||
@@ -2019,7 +2019,7 @@ static enum compl_status_e vdisk_exec_unmap(struct vdisk_cmd_params *p)
|
||||
struct scst_cmd *cmd = p->cmd;
|
||||
struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv;
|
||||
struct scst_data_descriptor *pd = cmd->cmd_data_descriptors;
|
||||
int i;
|
||||
int i, cnt = cmd->cmd_data_descriptors_cnt;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
@@ -2040,7 +2040,7 @@ static enum compl_status_e vdisk_exec_unmap(struct vdisk_cmd_params *p)
|
||||
if (pd == NULL)
|
||||
goto out;
|
||||
|
||||
for (i = 0; pd[i].sdd_len != 0; i++) {
|
||||
for (i = 0; i < cnt; i++) {
|
||||
int rc;
|
||||
|
||||
if (unlikely(test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags))) {
|
||||
|
||||
@@ -1971,7 +1971,7 @@ out:
|
||||
}
|
||||
EXPORT_SYMBOL(scst_check_convert_sense);
|
||||
|
||||
static int scst_set_cmd_error_sense(struct scst_cmd *cmd, uint8_t *sense,
|
||||
int scst_set_cmd_error_sense(struct scst_cmd *cmd, uint8_t *sense,
|
||||
unsigned int len)
|
||||
{
|
||||
int res;
|
||||
@@ -8564,6 +8564,7 @@ static bool scst_parse_unmap_descriptors(struct scst_cmd *cmd)
|
||||
TRACE_ENTRY();
|
||||
|
||||
EXTRACHECKS_BUG_ON(cmd->cmd_data_descriptors != NULL);
|
||||
EXTRACHECKS_BUG_ON(cmd->cmd_data_descriptors_cnt != 0);
|
||||
|
||||
length = scst_get_buf_full_sense(cmd, &address);
|
||||
if (unlikely(length <= 0)) {
|
||||
@@ -8596,7 +8597,7 @@ static bool scst_parse_unmap_descriptors(struct scst_cmd *cmd)
|
||||
if (cnt == 0)
|
||||
goto out_put;
|
||||
|
||||
pd = kzalloc(sizeof(*pd) * (cnt+1), GFP_KERNEL);
|
||||
pd = kzalloc(sizeof(*pd) * cnt, GFP_KERNEL);
|
||||
if (pd == NULL) {
|
||||
PRINT_ERROR("Unable to kmalloc UNMAP %d descriptors", cnt+1);
|
||||
scst_set_busy(cmd);
|
||||
@@ -8618,6 +8619,7 @@ static bool scst_parse_unmap_descriptors(struct scst_cmd *cmd)
|
||||
}
|
||||
|
||||
cmd->cmd_data_descriptors = pd;
|
||||
cmd->cmd_data_descriptors_cnt = cnt;
|
||||
|
||||
out_put:
|
||||
scst_put_buf_full(cmd, address);
|
||||
@@ -8640,6 +8642,7 @@ static void scst_free_unmap_descriptors(struct scst_cmd *cmd)
|
||||
TRACE_ENTRY();
|
||||
|
||||
kfree(cmd->cmd_data_descriptors);
|
||||
cmd->cmd_data_descriptors = NULL;
|
||||
|
||||
TRACE_EXIT();
|
||||
return;
|
||||
|
||||
@@ -340,6 +340,8 @@ static inline bool scst_acg_sess_is_empty(struct scst_acg *acg)
|
||||
int scst_prepare_request_sense(struct scst_cmd *orig_cmd);
|
||||
int scst_finish_internal_cmd(struct scst_cmd *cmd);
|
||||
|
||||
int scst_set_cmd_error_sense(struct scst_cmd *cmd, uint8_t *sense,
|
||||
unsigned int len);
|
||||
void scst_store_sense(struct scst_cmd *cmd);
|
||||
|
||||
int scst_assign_dev_handler(struct scst_device *dev,
|
||||
|
||||
@@ -628,7 +628,7 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
|
||||
cmd->data_len = cmd->bufflen;
|
||||
cmd->out_bufflen = cmd->expected_out_transfer_len;
|
||||
} else {
|
||||
PRINT_ERROR("Unknown opcode 0x%02x for %s and "
|
||||
PRINT_WARNING("Unknown opcode 0x%02x for %s and "
|
||||
"target %s not supplied expected values",
|
||||
cmd->cdb[0], devt->name, cmd->tgtt->name);
|
||||
scst_set_cmd_error(cmd,
|
||||
@@ -636,7 +636,7 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
|
||||
goto out_done;
|
||||
}
|
||||
#else
|
||||
PRINT_ERROR("Refusing unknown opcode %x", cmd->cdb[0]);
|
||||
PRINT_WARNING("Refusing unknown opcode %x", cmd->cdb[0]);
|
||||
scst_set_cmd_error(cmd,
|
||||
SCST_LOAD_SENSE(scst_sense_invalid_opcode));
|
||||
goto out_done;
|
||||
|
||||
Reference in New Issue
Block a user