diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-09-05 11:09:14 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-09-05 20:20:19 -0400 |
commit | 27a2709912ac19c755d34c79fe11994b0bf8082b (patch) | |
tree | 8e8e0a2a88f9bc8e807a9a7bac8756de43aaa37c | |
parent | 6138ed2ab8791d7a9c5ba66cadadd5eaf1fc1dac (diff) |
target: simplify code around transport_get_sense_data
The error conditions in transport_get_sense_data are superfluous
and complicate the code unnecessarily:
* SCF_TRANSPORT_TASK_SENSE is checked in the caller;
* it's simply part of the invariants of dev->transport->get_sense_buffer
that it must be there if transport_complete ever returns 1, and that
it must not return NULL. Besides, the entire callback will disappear
with the next patch.
* similarly in the caller we can expect that sense data is only sent
for non-zero cmd->scsi_status.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_transport.c | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d0afdaa0625..040f05fde4d 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -570,7 +570,7 @@ static void target_complete_failure_work(struct work_struct *work) | |||
570 | /* | 570 | /* |
571 | * Used to obtain Sense Data from underlying Linux/SCSI struct scsi_cmnd | 571 | * Used to obtain Sense Data from underlying Linux/SCSI struct scsi_cmnd |
572 | */ | 572 | */ |
573 | static int transport_get_sense_data(struct se_cmd *cmd) | 573 | static void transport_get_sense_data(struct se_cmd *cmd) |
574 | { | 574 | { |
575 | unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; | 575 | unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; |
576 | struct se_device *dev = cmd->se_dev; | 576 | struct se_device *dev = cmd->se_dev; |
@@ -580,30 +580,15 @@ static int transport_get_sense_data(struct se_cmd *cmd) | |||
580 | WARN_ON(!cmd->se_lun); | 580 | WARN_ON(!cmd->se_lun); |
581 | 581 | ||
582 | if (!dev) | 582 | if (!dev) |
583 | return 0; | 583 | return; |
584 | 584 | ||
585 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 585 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
586 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { | 586 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { |
587 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 587 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
588 | return 0; | 588 | return; |
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 | } | 589 | } |
598 | 590 | ||
599 | sense_buffer = dev->transport->get_sense_buffer(cmd); | 591 | 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); | 592 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
608 | 593 | ||
609 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER); | 594 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER); |
@@ -615,11 +600,6 @@ static int transport_get_sense_data(struct se_cmd *cmd) | |||
615 | 600 | ||
616 | pr_debug("HBA_[%u]_PLUG[%s]: Set SAM STATUS: 0x%02x and sense\n", | 601 | 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); | 602 | 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 | } | 603 | } |
624 | 604 | ||
625 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) | 605 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) |
@@ -1990,7 +1970,7 @@ static void transport_handle_queue_full( | |||
1990 | static void target_complete_ok_work(struct work_struct *work) | 1970 | static void target_complete_ok_work(struct work_struct *work) |
1991 | { | 1971 | { |
1992 | struct se_cmd *cmd = container_of(work, struct se_cmd, work); | 1972 | struct se_cmd *cmd = container_of(work, struct se_cmd, work); |
1993 | int reason = 0, ret; | 1973 | int ret; |
1994 | 1974 | ||
1995 | /* | 1975 | /* |
1996 | * Check if we need to move delayed/dormant tasks from cmds on the | 1976 | * Check if we need to move delayed/dormant tasks from cmds on the |
@@ -2011,19 +1991,16 @@ static void target_complete_ok_work(struct work_struct *work) | |||
2011 | * the struct se_cmd in question. | 1991 | * the struct se_cmd in question. |
2012 | */ | 1992 | */ |
2013 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { | 1993 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { |
2014 | if (transport_get_sense_data(cmd) < 0) | 1994 | WARN_ON(!cmd->scsi_status); |
2015 | reason = TCM_NON_EXISTENT_LUN; | 1995 | transport_get_sense_data(cmd); |
2016 | 1996 | ret = transport_send_check_condition_and_sense( | |
2017 | if (cmd->scsi_status) { | 1997 | cmd, 0, 1); |
2018 | ret = transport_send_check_condition_and_sense( | 1998 | if (ret == -EAGAIN || ret == -ENOMEM) |
2019 | cmd, reason, 1); | 1999 | goto queue_full; |
2020 | if (ret == -EAGAIN || ret == -ENOMEM) | ||
2021 | goto queue_full; | ||
2022 | 2000 | ||
2023 | transport_lun_remove_cmd(cmd); | 2001 | transport_lun_remove_cmd(cmd); |
2024 | transport_cmd_check_stop_to_fabric(cmd); | 2002 | transport_cmd_check_stop_to_fabric(cmd); |
2025 | return; | 2003 | return; |
2026 | } | ||
2027 | } | 2004 | } |
2028 | /* | 2005 | /* |
2029 | * Check for a callback, used by amongst other things | 2006 | * Check for a callback, used by amongst other things |