Commit 65f81ccbd1e33872b1b47bc550e452e7e3dadf58

Authored by Nicholas Bellinger
Committed by Greg Kroah-Hartman
1 parent 82bc9d04f4

vhost-scsi: Add missing virtio-scsi -> TCM attribute conversion

commit 46243860806bdc2756f3ce8ac86b4d7c616bcd6c upstream.

While looking at hch's recent conversion to drop the MSG_*_TAG
definitions, I noticed a long standing bug in vhost-scsi where
the VIRTIO_SCSI_S_* attribute definitions where incorrectly
being passed directly into target_submit_cmd_map_sgls().

This patch adds the missing virtio-scsi to TCM/SAM task attribute
conversion.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 21 additions and 3 deletions Side-by-side Diff

drivers/vhost/scsi.c
... ... @@ -909,6 +909,23 @@
909 909 return 0;
910 910 }
911 911  
  912 +static int vhost_scsi_to_tcm_attr(int attr)
  913 +{
  914 + switch (attr) {
  915 + case VIRTIO_SCSI_S_SIMPLE:
  916 + return MSG_SIMPLE_TAG;
  917 + case VIRTIO_SCSI_S_ORDERED:
  918 + return MSG_ORDERED_TAG;
  919 + case VIRTIO_SCSI_S_HEAD:
  920 + return MSG_HEAD_TAG;
  921 + case VIRTIO_SCSI_S_ACA:
  922 + return MSG_ACA_TAG;
  923 + default:
  924 + break;
  925 + }
  926 + return MSG_SIMPLE_TAG;
  927 +}
  928 +
912 929 static void tcm_vhost_submission_work(struct work_struct *work)
913 930 {
914 931 struct tcm_vhost_cmd *cmd =
... ... @@ -934,9 +951,10 @@
934 951 rc = target_submit_cmd_map_sgls(se_cmd, tv_nexus->tvn_se_sess,
935 952 cmd->tvc_cdb, &cmd->tvc_sense_buf[0],
936 953 cmd->tvc_lun, cmd->tvc_exp_data_len,
937   - cmd->tvc_task_attr, cmd->tvc_data_direction,
938   - TARGET_SCF_ACK_KREF, sg_ptr, cmd->tvc_sgl_count,
939   - NULL, 0, sg_prot_ptr, cmd->tvc_prot_sgl_count);
  954 + vhost_scsi_to_tcm_attr(cmd->tvc_task_attr),
  955 + cmd->tvc_data_direction, TARGET_SCF_ACK_KREF,
  956 + sg_ptr, cmd->tvc_sgl_count, NULL, 0,
  957 + sg_prot_ptr, cmd->tvc_prot_sgl_count);
940 958 if (rc < 0) {
941 959 transport_send_check_condition_and_sense(se_cmd,
942 960 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);