target/user: Use sense_reason_t in tcmu_queue_cmd_ring
Instead of using -ERROR-style returns, use sense_reason_t. This lets us remove tcmu_pass_op(), and return more correct sense values. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <mchristi@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
1001354ca3
commit
02eb924fab
|
@ -389,7 +389,8 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, size_t cmd_size, size_t d
|
|||
return true;
|
||||
}
|
||||
|
||||
static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
|
||||
static sense_reason_t
|
||||
tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
|
||||
{
|
||||
struct tcmu_dev *udev = tcmu_cmd->tcmu_dev;
|
||||
struct se_cmd *se_cmd = tcmu_cmd->se_cmd;
|
||||
|
@ -405,7 +406,7 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
|
|||
DECLARE_BITMAP(old_bitmap, DATA_BLOCK_BITS);
|
||||
|
||||
if (test_bit(TCMU_DEV_BIT_BROKEN, &udev->flags))
|
||||
return -EINVAL;
|
||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||
|
||||
/*
|
||||
* Must be a certain minimum size for response sense info, but
|
||||
|
@ -450,7 +451,7 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
|
|||
finish_wait(&udev->wait_cmdr, &__wait);
|
||||
if (!ret) {
|
||||
pr_warn("tcmu: command timed out\n");
|
||||
return -ETIMEDOUT;
|
||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||
}
|
||||
|
||||
spin_lock_irq(&udev->cmdr_lock);
|
||||
|
@ -526,10 +527,11 @@ static int tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
|
|||
mod_timer(&udev->timeout,
|
||||
round_jiffies_up(jiffies + msecs_to_jiffies(TCMU_TIME_OUT)));
|
||||
|
||||
return 0;
|
||||
return TCM_NO_SENSE;
|
||||
}
|
||||
|
||||
static int tcmu_queue_cmd(struct se_cmd *se_cmd)
|
||||
static sense_reason_t
|
||||
tcmu_queue_cmd(struct se_cmd *se_cmd)
|
||||
{
|
||||
struct se_device *se_dev = se_cmd->se_dev;
|
||||
struct tcmu_dev *udev = TCMU_DEV(se_dev);
|
||||
|
@ -538,10 +540,10 @@ static int tcmu_queue_cmd(struct se_cmd *se_cmd)
|
|||
|
||||
tcmu_cmd = tcmu_alloc_cmd(se_cmd);
|
||||
if (!tcmu_cmd)
|
||||
return -ENOMEM;
|
||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||
|
||||
ret = tcmu_queue_cmd_ring(tcmu_cmd);
|
||||
if (ret < 0) {
|
||||
if (ret != TCM_NO_SENSE) {
|
||||
pr_err("TCMU: Could not queue command\n");
|
||||
spin_lock_irq(&udev->commands_lock);
|
||||
idr_remove(&udev->commands, tcmu_cmd->cmd_id);
|
||||
|
@ -1128,21 +1130,10 @@ static sector_t tcmu_get_blocks(struct se_device *dev)
|
|||
dev->dev_attrib.block_size);
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
tcmu_pass_op(struct se_cmd *se_cmd)
|
||||
{
|
||||
int ret = tcmu_queue_cmd(se_cmd);
|
||||
|
||||
if (ret != 0)
|
||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||
else
|
||||
return TCM_NO_SENSE;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
tcmu_parse_cdb(struct se_cmd *cmd)
|
||||
{
|
||||
return passthrough_parse_cdb(cmd, tcmu_pass_op);
|
||||
return passthrough_parse_cdb(cmd, tcmu_queue_cmd);
|
||||
}
|
||||
|
||||
static const struct target_backend_ops tcmu_ops = {
|
||||
|
|
Loading…
Reference in New Issue