aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/target/target_core_transport.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index ff7fcf8366a..89760329d5d 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1747,6 +1747,8 @@ int transport_generic_handle_cdb(
1747} 1747}
1748EXPORT_SYMBOL(transport_generic_handle_cdb); 1748EXPORT_SYMBOL(transport_generic_handle_cdb);
1749 1749
1750static void transport_generic_request_failure(struct se_cmd *,
1751 struct se_device *, int, int);
1750/* 1752/*
1751 * Used by fabric module frontends to queue tasks directly. 1753 * Used by fabric module frontends to queue tasks directly.
1752 * Many only be used from process context only 1754 * Many only be used from process context only
@@ -1754,6 +1756,8 @@ EXPORT_SYMBOL(transport_generic_handle_cdb);
1754int transport_handle_cdb_direct( 1756int transport_handle_cdb_direct(
1755 struct se_cmd *cmd) 1757 struct se_cmd *cmd)
1756{ 1758{
1759 int ret;
1760
1757 if (!cmd->se_lun) { 1761 if (!cmd->se_lun) {
1758 dump_stack(); 1762 dump_stack();
1759 pr_err("cmd->se_lun is NULL\n"); 1763 pr_err("cmd->se_lun is NULL\n");
@@ -1765,8 +1769,31 @@ int transport_handle_cdb_direct(
1765 " from interrupt context\n"); 1769 " from interrupt context\n");
1766 return -EINVAL; 1770 return -EINVAL;
1767 } 1771 }
1768 1772 /*
1769 return transport_generic_new_cmd(cmd); 1773 * Set TRANSPORT_NEW_CMD state and cmd->t_transport_active=1 following
1774 * transport_generic_handle_cdb*() -> transport_add_cmd_to_queue()
1775 * in existing usage to ensure that outstanding descriptors are handled
1776 * correctly during shutdown via transport_generic_wait_for_tasks()
1777 *
1778 * Also, we don't take cmd->t_state_lock here as we only expect
1779 * this to be called for initial descriptor submission.
1780 */
1781 cmd->t_state = TRANSPORT_NEW_CMD;
1782 atomic_set(&cmd->t_transport_active, 1);
1783 /*
1784 * transport_generic_new_cmd() is already handling QUEUE_FULL,
1785 * so follow TRANSPORT_NEW_CMD processing thread context usage
1786 * and call transport_generic_request_failure() if necessary..
1787 */
1788 ret = transport_generic_new_cmd(cmd);
1789 if (ret == -EAGAIN)
1790 return 0;
1791 else if (ret < 0) {
1792 cmd->transport_error_status = ret;
1793 transport_generic_request_failure(cmd, NULL, 0,
1794 (cmd->data_direction != DMA_TO_DEVICE));
1795 }
1796 return 0;
1770} 1797}
1771EXPORT_SYMBOL(transport_handle_cdb_direct); 1798EXPORT_SYMBOL(transport_handle_cdb_direct);
1772 1799