diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-09-05 11:09:13 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-09-05 20:19:46 -0400 |
commit | 6138ed2ab8791d7a9c5ba66cadadd5eaf1fc1dac (patch) | |
tree | 832960b78ddc6b0a490e415c6cf5b55ac0b3f5a8 /drivers | |
parent | 13b5533a38b1eec9d61a07711dc075f03ae47a36 (diff) |
target: move transport_get_sense_data
We will be calling it from transport_complete_cmd, avoid forward
declarations. No semantic change.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/target/target_core_transport.c | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 3425098ef728..d0afdaa06255 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -567,6 +567,61 @@ static void target_complete_failure_work(struct work_struct *work) | |||
567 | transport_generic_request_failure(cmd); | 567 | transport_generic_request_failure(cmd); |
568 | } | 568 | } |
569 | 569 | ||
570 | /* | ||
571 | * Used to obtain Sense Data from underlying Linux/SCSI struct scsi_cmnd | ||
572 | */ | ||
573 | static int transport_get_sense_data(struct se_cmd *cmd) | ||
574 | { | ||
575 | unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; | ||
576 | struct se_device *dev = cmd->se_dev; | ||
577 | unsigned long flags; | ||
578 | u32 offset = 0; | ||
579 | |||
580 | WARN_ON(!cmd->se_lun); | ||
581 | |||
582 | if (!dev) | ||
583 | return 0; | ||
584 | |||
585 | spin_lock_irqsave(&cmd->t_state_lock, flags); | ||
586 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { | ||
587 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
588 | return 0; | ||
589 | } | ||
590 | |||
591 | if (!(cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)) | ||
592 | goto out; | ||
593 | |||
594 | if (!dev->transport->get_sense_buffer) { | ||
595 | pr_err("dev->transport->get_sense_buffer is NULL\n"); | ||
596 | goto out; | ||
597 | } | ||
598 | |||
599 | sense_buffer = dev->transport->get_sense_buffer(cmd); | ||
600 | if (!sense_buffer) { | ||
601 | pr_err("ITT 0x%08x cmd %p: Unable to locate" | ||
602 | " sense buffer for task with sense\n", | ||
603 | cmd->se_tfo->get_task_tag(cmd), cmd); | ||
604 | goto out; | ||
605 | } | ||
606 | |||
607 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
608 | |||
609 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER); | ||
610 | |||
611 | memcpy(&buffer[offset], sense_buffer, TRANSPORT_SENSE_BUFFER); | ||
612 | |||
613 | /* Automatically padded */ | ||
614 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset; | ||
615 | |||
616 | pr_debug("HBA_[%u]_PLUG[%s]: Set SAM STATUS: 0x%02x and sense\n", | ||
617 | dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status); | ||
618 | return 0; | ||
619 | |||
620 | out: | ||
621 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
622 | return -1; | ||
623 | } | ||
624 | |||
570 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) | 625 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) |
571 | { | 626 | { |
572 | struct se_device *dev = cmd->se_dev; | 627 | struct se_device *dev = cmd->se_dev; |
@@ -1821,61 +1876,6 @@ execute: | |||
1821 | EXPORT_SYMBOL(target_execute_cmd); | 1876 | EXPORT_SYMBOL(target_execute_cmd); |
1822 | 1877 | ||
1823 | /* | 1878 | /* |
1824 | * Used to obtain Sense Data from underlying Linux/SCSI struct scsi_cmnd | ||
1825 | */ | ||
1826 | static int transport_get_sense_data(struct se_cmd *cmd) | ||
1827 | { | ||
1828 | unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; | ||
1829 | struct se_device *dev = cmd->se_dev; | ||
1830 | unsigned long flags; | ||
1831 | u32 offset = 0; | ||
1832 | |||
1833 | WARN_ON(!cmd->se_lun); | ||
1834 | |||
1835 | if (!dev) | ||
1836 | return 0; | ||
1837 | |||
1838 | spin_lock_irqsave(&cmd->t_state_lock, flags); | ||
1839 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { | ||
1840 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
1841 | return 0; | ||
1842 | } | ||
1843 | |||
1844 | if (!(cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)) | ||
1845 | goto out; | ||
1846 | |||
1847 | if (!dev->transport->get_sense_buffer) { | ||
1848 | pr_err("dev->transport->get_sense_buffer is NULL\n"); | ||
1849 | goto out; | ||
1850 | } | ||
1851 | |||
1852 | sense_buffer = dev->transport->get_sense_buffer(cmd); | ||
1853 | if (!sense_buffer) { | ||
1854 | pr_err("ITT 0x%08x cmd %p: Unable to locate" | ||
1855 | " sense buffer for task with sense\n", | ||
1856 | cmd->se_tfo->get_task_tag(cmd), cmd); | ||
1857 | goto out; | ||
1858 | } | ||
1859 | |||
1860 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
1861 | |||
1862 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER); | ||
1863 | |||
1864 | memcpy(&buffer[offset], sense_buffer, TRANSPORT_SENSE_BUFFER); | ||
1865 | |||
1866 | /* Automatically padded */ | ||
1867 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset; | ||
1868 | |||
1869 | pr_debug("HBA_[%u]_PLUG[%s]: Set SAM STATUS: 0x%02x and sense\n", | ||
1870 | dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status); | ||
1871 | return 0; | ||
1872 | |||
1873 | out: | ||
1874 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
1875 | return -1; | ||
1876 | } | ||
1877 | |||
1878 | /* | ||
1879 | * Process all commands up to the last received ORDERED task attribute which | 1879 | * Process all commands up to the last received ORDERED task attribute which |
1880 | * requires another blocking boundary | 1880 | * requires another blocking boundary |
1881 | */ | 1881 | */ |