Skip to content

Commit

Permalink
fix the stpg command error for multiple port group
Browse files Browse the repository at this point in the history
Signed-off-by: tangwenji <[email protected]>
  • Loading branch information
tangwenji committed Sep 11, 2018
1 parent 8d07d8b commit 408f2f7
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ int tcmu_emulate_set_tgt_port_grps(struct tcmu_device *dev,
uint32_t off = 4, param_list_len = tcmu_get_xfer_length(cmd->cdb);
uint16_t id, tmp_id;
char *buf, new_state;
int found, ret = TCMU_STS_OK;
int ret = TCMU_STS_OK;

port = tcmu_get_enabled_port(group_list);
if (!port)
Expand All @@ -721,44 +721,39 @@ int tcmu_emulate_set_tgt_port_grps(struct tcmu_device *dev,
id = be16toh(tmp_id);
off += 2;

found = 0;
list_for_each(group_list, group, entry) {
if (group->id != id)
continue;

if (group != port->grp) {
ret = TCMU_STS_HW_ERR;
tcmu_dev_err(dev, "Failing STPG for group %d. Unable to transition remote groups.\n",
id);
goto free_buf;
tcmu_dev_dbg(dev, "Port of group %d is disable.\n", id);
continue;
}

tcmu_dev_dbg(dev, "Got STPG for group %u\n", id);
ret = tcmu_explicit_transition(group_list, group,
new_state,
ALUA_STAT_ALTERED_BY_EXPLICIT_STPG,
cmd->sense_buf);
/* Only one group is enabled, so after matching the previous one,
* whether it is successful or not, we should exit the loop
* without continuing to process the content behind the command.
*/
if (ret != TCMU_STS_OK) {
tcmu_dev_err(dev, "Failing STPG for group %d\n",
id);
goto free_buf;
}
found = 1;
break;
}

if (!found) {
/*
* Could not find what error code to return in SCSI
* spec.
*/
tcmu_dev_err(dev, "Could not find group for %u for STPG\n",
id);
ret = TCMU_STS_EXPL_TRANSITION_ERR;
break;
goto free_buf;
}
}

/*
* Could not find what error code to return in SCSI
* spec.
*/
tcmu_dev_err(dev, "Could not find enable group for STPG\n");
ret = TCMU_STS_EXPL_TRANSITION_ERR;

free_buf:
free(buf);
return ret;
Expand Down

0 comments on commit 408f2f7

Please sign in to comment.