diff options
author | Asias He <asias@redhat.com> | 2013-04-10 03:06:16 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-04-11 04:48:42 -0400 |
commit | 055f648c49d948de9452b0f1758869bbbd0097b8 (patch) | |
tree | 683c374546db82f1413afeea5b1b4fe7cfff59b4 /drivers/vhost | |
parent | 637ab21e284f4e9188acc2746695f7f6452b4a22 (diff) |
tcm_vhost: Send bad target to guest when cmd fails
Send bad target to guest in case:
1) we can not allocate the cmd
2) fail to submit the cmd
Signed-off-by: Asias He <asias@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/tcm_vhost.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index 1bb0fb4950d1..957a0b98a5d9 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c | |||
@@ -703,7 +703,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs, | |||
703 | if (IS_ERR(tv_cmd)) { | 703 | if (IS_ERR(tv_cmd)) { |
704 | vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n", | 704 | vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n", |
705 | PTR_ERR(tv_cmd)); | 705 | PTR_ERR(tv_cmd)); |
706 | break; | 706 | goto err_cmd; |
707 | } | 707 | } |
708 | pr_debug("Allocated tv_cmd: %p exp_data_len: %d, data_direction" | 708 | pr_debug("Allocated tv_cmd: %p exp_data_len: %d, data_direction" |
709 | ": %d\n", tv_cmd, exp_data_len, data_direction); | 709 | ": %d\n", tv_cmd, exp_data_len, data_direction); |
@@ -729,7 +729,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs, | |||
729 | " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", | 729 | " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", |
730 | scsi_command_size(tv_cmd->tvc_cdb), | 730 | scsi_command_size(tv_cmd->tvc_cdb), |
731 | TCM_VHOST_MAX_CDB_SIZE); | 731 | TCM_VHOST_MAX_CDB_SIZE); |
732 | goto err; | 732 | goto err_free; |
733 | } | 733 | } |
734 | tv_cmd->tvc_lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF; | 734 | tv_cmd->tvc_lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF; |
735 | 735 | ||
@@ -742,7 +742,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs, | |||
742 | data_direction == DMA_TO_DEVICE); | 742 | data_direction == DMA_TO_DEVICE); |
743 | if (unlikely(ret)) { | 743 | if (unlikely(ret)) { |
744 | vq_err(vq, "Failed to map iov to sgl\n"); | 744 | vq_err(vq, "Failed to map iov to sgl\n"); |
745 | goto err; | 745 | goto err_free; |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
@@ -765,8 +765,10 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs, | |||
765 | mutex_unlock(&vq->mutex); | 765 | mutex_unlock(&vq->mutex); |
766 | return; | 766 | return; |
767 | 767 | ||
768 | err: | 768 | err_free: |
769 | vhost_scsi_free_cmd(tv_cmd); | 769 | vhost_scsi_free_cmd(tv_cmd); |
770 | err_cmd: | ||
771 | vhost_scsi_send_bad_target(vs, vq, head, out); | ||
770 | mutex_unlock(&vq->mutex); | 772 | mutex_unlock(&vq->mutex); |
771 | } | 773 | } |
772 | 774 | ||