]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
target: add helper to copy sense to se_cmd buffer
authorMike Christie <mchristi@redhat.com>
Wed, 31 May 2017 20:52:39 +0000 (15:52 -0500)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 7 Jul 2017 06:11:45 +0000 (23:11 -0700)
This adds a helper to copy sense from backend module buffer to
the se_cmd's sense buffer.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c
include/target/target_core_backend.h

index a8f943e325eb3f97340f1907d7ed8315b63514c8..341025a3cbb70992f25db493dff28f12588036de 100644 (file)
@@ -704,6 +704,24 @@ static unsigned char *transport_get_sense_buffer(struct se_cmd *cmd)
        return cmd->sense_buffer;
 }
 
+void transport_copy_sense_to_cmd(struct se_cmd *cmd, unsigned char *sense)
+{
+       unsigned char *cmd_sense_buf;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       cmd_sense_buf = transport_get_sense_buffer(cmd);
+       if (!cmd_sense_buf) {
+               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+               return;
+       }
+
+       cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
+       memcpy(cmd_sense_buf, sense, cmd->scsi_sense_length);
+       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+}
+EXPORT_SYMBOL(transport_copy_sense_to_cmd);
+
 void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
 {
        struct se_device *dev = cmd->se_dev;
index 1f2b7007f2df34c4fcecfaec84974d5ffd0d57d8..3757f5f54e03b7e210af75943f0effd6915d5e41 100644 (file)
@@ -73,6 +73,8 @@ void  target_backend_unregister(const struct target_backend_ops *);
 void   target_complete_cmd(struct se_cmd *, u8);
 void   target_complete_cmd_with_length(struct se_cmd *, u8, int);
 
+void   transport_copy_sense_to_cmd(struct se_cmd *, unsigned char *);
+
 sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
 sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd);
 sense_reason_t spc_emulate_inquiry_std(struct se_cmd *, unsigned char *);