aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-10-10 17:37:14 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-11-06 23:55:45 -0500
commit019c4ca621488739b1bfb7597a14ac7f0cbcc908 (patch)
tree2717b223b7a5d1fbd8765805879b87446ea98862 /drivers/target
parente6c4219b54ac9d0bd348ea59e606303f9aef1784 (diff)
target: kill dev->dev_task_attr_type
We can just key off ordered tag emulation of the transport_type field. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_device.c5
-rw-r--r--drivers/target/target_core_spc.c6
-rw-r--r--drivers/target/target_core_transport.c130
3 files changed, 69 insertions, 72 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index e45a70970548..6a27e7fd33fb 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1412,11 +1412,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
1412 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS; 1412 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;
1413 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS; 1413 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS;
1414 1414
1415 if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
1416 dev->dev_task_attr_type = SAM_TASK_ATTR_PASSTHROUGH;
1417 else
1418 dev->dev_task_attr_type = SAM_TASK_ATTR_EMULATED;
1419
1420 return dev; 1415 return dev;
1421} 1416}
1422 1417
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 1f1ddb8183c7..8ca62631ec7f 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1054,8 +1054,7 @@ int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size)
1054 * Do implict HEAD_OF_QUEUE processing for INQUIRY. 1054 * Do implict HEAD_OF_QUEUE processing for INQUIRY.
1055 * See spc4r17 section 5.3 1055 * See spc4r17 section 5.3
1056 */ 1056 */
1057 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 1057 cmd->sam_task_attr = MSG_HEAD_TAG;
1058 cmd->sam_task_attr = MSG_HEAD_TAG;
1059 cmd->execute_cmd = spc_emulate_inquiry; 1058 cmd->execute_cmd = spc_emulate_inquiry;
1060 break; 1059 break;
1061 case SECURITY_PROTOCOL_IN: 1060 case SECURITY_PROTOCOL_IN:
@@ -1083,8 +1082,7 @@ int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size)
1083 * Do implict HEAD_OF_QUEUE processing for REPORT_LUNS 1082 * Do implict HEAD_OF_QUEUE processing for REPORT_LUNS
1084 * See spc4r17 section 5.3 1083 * See spc4r17 section 5.3
1085 */ 1084 */
1086 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 1085 cmd->sam_task_attr = MSG_HEAD_TAG;
1087 cmd->sam_task_attr = MSG_HEAD_TAG;
1088 break; 1086 break;
1089 case TEST_UNIT_READY: 1087 case TEST_UNIT_READY:
1090 cmd->execute_cmd = spc_emulate_testunitready; 1088 cmd->execute_cmd = spc_emulate_testunitready;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index c80d88435f90..757e3777ce79 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1068,11 +1068,13 @@ EXPORT_SYMBOL(transport_init_se_cmd);
1068 1068
1069static int transport_check_alloc_task_attr(struct se_cmd *cmd) 1069static int transport_check_alloc_task_attr(struct se_cmd *cmd)
1070{ 1070{
1071 struct se_device *dev = cmd->se_dev;
1072
1071 /* 1073 /*
1072 * Check if SAM Task Attribute emulation is enabled for this 1074 * Check if SAM Task Attribute emulation is enabled for this
1073 * struct se_device storage object 1075 * struct se_device storage object
1074 */ 1076 */
1075 if (cmd->se_dev->dev_task_attr_type != SAM_TASK_ATTR_EMULATED) 1077 if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
1076 return 0; 1078 return 0;
1077 1079
1078 if (cmd->sam_task_attr == MSG_ACA_TAG) { 1080 if (cmd->sam_task_attr == MSG_ACA_TAG) {
@@ -1084,11 +1086,11 @@ static int transport_check_alloc_task_attr(struct se_cmd *cmd)
1084 * Used to determine when ORDERED commands should go from 1086 * Used to determine when ORDERED commands should go from
1085 * Dormant to Active status. 1087 * Dormant to Active status.
1086 */ 1088 */
1087 cmd->se_ordered_id = atomic_inc_return(&cmd->se_dev->dev_ordered_id); 1089 cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
1088 smp_mb__after_atomic_inc(); 1090 smp_mb__after_atomic_inc();
1089 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n", 1091 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
1090 cmd->se_ordered_id, cmd->sam_task_attr, 1092 cmd->se_ordered_id, cmd->sam_task_attr,
1091 cmd->se_dev->transport->name); 1093 dev->transport->name);
1092 return 0; 1094 return 0;
1093} 1095}
1094 1096
@@ -1534,8 +1536,7 @@ void transport_generic_request_failure(struct se_cmd *cmd)
1534 /* 1536 /*
1535 * For SAM Task Attribute emulation for failed struct se_cmd 1537 * For SAM Task Attribute emulation for failed struct se_cmd
1536 */ 1538 */
1537 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 1539 transport_complete_task_attr(cmd);
1538 transport_complete_task_attr(cmd);
1539 1540
1540 switch (cmd->scsi_sense_reason) { 1541 switch (cmd->scsi_sense_reason) {
1541 case TCM_NON_EXISTENT_LUN: 1542 case TCM_NON_EXISTENT_LUN:
@@ -1619,49 +1620,12 @@ static void __target_execute_cmd(struct se_cmd *cmd)
1619 } 1620 }
1620} 1621}
1621 1622
1622void target_execute_cmd(struct se_cmd *cmd) 1623static bool target_handle_task_attr(struct se_cmd *cmd)
1623{ 1624{
1624 struct se_device *dev = cmd->se_dev; 1625 struct se_device *dev = cmd->se_dev;
1625 1626
1626 /* 1627 if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
1627 * If the received CDB has aleady been aborted stop processing it here. 1628 return false;
1628 */
1629 if (transport_check_aborted_status(cmd, 1))
1630 return;
1631
1632 /*
1633 * Determine if IOCTL context caller in requesting the stopping of this
1634 * command for LUN shutdown purposes.
1635 */
1636 spin_lock_irq(&cmd->t_state_lock);
1637 if (cmd->transport_state & CMD_T_LUN_STOP) {
1638 pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n",
1639 __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd));
1640
1641 cmd->transport_state &= ~CMD_T_ACTIVE;
1642 spin_unlock_irq(&cmd->t_state_lock);
1643 complete(&cmd->transport_lun_stop_comp);
1644 return;
1645 }
1646 /*
1647 * Determine if frontend context caller is requesting the stopping of
1648 * this command for frontend exceptions.
1649 */
1650 if (cmd->transport_state & CMD_T_STOP) {
1651 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08x\n",
1652 __func__, __LINE__,
1653 cmd->se_tfo->get_task_tag(cmd));
1654
1655 spin_unlock_irq(&cmd->t_state_lock);
1656 complete(&cmd->t_transport_stop_comp);
1657 return;
1658 }
1659
1660 cmd->t_state = TRANSPORT_PROCESSING;
1661 spin_unlock_irq(&cmd->t_state_lock);
1662
1663 if (dev->dev_task_attr_type != SAM_TASK_ATTR_EMULATED)
1664 goto execute;
1665 1629
1666 /* 1630 /*
1667 * Check for the existence of HEAD_OF_QUEUE, and if true return 1 1631 * Check for the existence of HEAD_OF_QUEUE, and if true return 1
@@ -1672,7 +1636,7 @@ void target_execute_cmd(struct se_cmd *cmd)
1672 pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x, " 1636 pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x, "
1673 "se_ordered_id: %u\n", 1637 "se_ordered_id: %u\n",
1674 cmd->t_task_cdb[0], cmd->se_ordered_id); 1638 cmd->t_task_cdb[0], cmd->se_ordered_id);
1675 goto execute; 1639 return false;
1676 case MSG_ORDERED_TAG: 1640 case MSG_ORDERED_TAG:
1677 atomic_inc(&dev->dev_ordered_sync); 1641 atomic_inc(&dev->dev_ordered_sync);
1678 smp_mb__after_atomic_inc(); 1642 smp_mb__after_atomic_inc();
@@ -1686,7 +1650,7 @@ void target_execute_cmd(struct se_cmd *cmd)
1686 * exist that need to be completed first. 1650 * exist that need to be completed first.
1687 */ 1651 */
1688 if (!atomic_read(&dev->simple_cmds)) 1652 if (!atomic_read(&dev->simple_cmds))
1689 goto execute; 1653 return false;
1690 break; 1654 break;
1691 default: 1655 default:
1692 /* 1656 /*
@@ -1697,23 +1661,61 @@ void target_execute_cmd(struct se_cmd *cmd)
1697 break; 1661 break;
1698 } 1662 }
1699 1663
1700 if (atomic_read(&dev->dev_ordered_sync) != 0) { 1664 if (atomic_read(&dev->dev_ordered_sync) == 0)
1701 spin_lock(&dev->delayed_cmd_lock); 1665 return false;
1702 list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
1703 spin_unlock(&dev->delayed_cmd_lock);
1704 1666
1705 pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to" 1667 spin_lock(&dev->delayed_cmd_lock);
1706 " delayed CMD list, se_ordered_id: %u\n", 1668 list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
1707 cmd->t_task_cdb[0], cmd->sam_task_attr, 1669 spin_unlock(&dev->delayed_cmd_lock);
1708 cmd->se_ordered_id); 1670
1671 pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to"
1672 " delayed CMD list, se_ordered_id: %u\n",
1673 cmd->t_task_cdb[0], cmd->sam_task_attr,
1674 cmd->se_ordered_id);
1675 return true;
1676}
1677
1678void target_execute_cmd(struct se_cmd *cmd)
1679{
1680 /*
1681 * If the received CDB has aleady been aborted stop processing it here.
1682 */
1683 if (transport_check_aborted_status(cmd, 1))
1709 return; 1684 return;
1710 }
1711 1685
1712execute:
1713 /* 1686 /*
1714 * Otherwise, no ORDERED task attributes exist.. 1687 * Determine if IOCTL context caller in requesting the stopping of this
1688 * command for LUN shutdown purposes.
1715 */ 1689 */
1716 __target_execute_cmd(cmd); 1690 spin_lock_irq(&cmd->t_state_lock);
1691 if (cmd->transport_state & CMD_T_LUN_STOP) {
1692 pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n",
1693 __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd));
1694
1695 cmd->transport_state &= ~CMD_T_ACTIVE;
1696 spin_unlock_irq(&cmd->t_state_lock);
1697 complete(&cmd->transport_lun_stop_comp);
1698 return;
1699 }
1700 /*
1701 * Determine if frontend context caller is requesting the stopping of
1702 * this command for frontend exceptions.
1703 */
1704 if (cmd->transport_state & CMD_T_STOP) {
1705 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08x\n",
1706 __func__, __LINE__,
1707 cmd->se_tfo->get_task_tag(cmd));
1708
1709 spin_unlock_irq(&cmd->t_state_lock);
1710 complete(&cmd->t_transport_stop_comp);
1711 return;
1712 }
1713
1714 cmd->t_state = TRANSPORT_PROCESSING;
1715 spin_unlock_irq(&cmd->t_state_lock);
1716
1717 if (!target_handle_task_attr(cmd))
1718 __target_execute_cmd(cmd);
1717} 1719}
1718EXPORT_SYMBOL(target_execute_cmd); 1720EXPORT_SYMBOL(target_execute_cmd);
1719 1721
@@ -1752,6 +1754,9 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
1752{ 1754{
1753 struct se_device *dev = cmd->se_dev; 1755 struct se_device *dev = cmd->se_dev;
1754 1756
1757 if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
1758 return;
1759
1755 if (cmd->sam_task_attr == MSG_SIMPLE_TAG) { 1760 if (cmd->sam_task_attr == MSG_SIMPLE_TAG) {
1756 atomic_dec(&dev->simple_cmds); 1761 atomic_dec(&dev->simple_cmds);
1757 smp_mb__after_atomic_dec(); 1762 smp_mb__after_atomic_dec();
@@ -1780,8 +1785,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
1780{ 1785{
1781 int ret = 0; 1786 int ret = 0;
1782 1787
1783 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 1788 transport_complete_task_attr(cmd);
1784 transport_complete_task_attr(cmd);
1785 1789
1786 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { 1790 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
1787 ret = cmd->se_tfo->queue_status(cmd); 1791 ret = cmd->se_tfo->queue_status(cmd);
@@ -1839,8 +1843,8 @@ static void target_complete_ok_work(struct work_struct *work)
1839 * delayed execution list after a HEAD_OF_QUEUE or ORDERED Task 1843 * delayed execution list after a HEAD_OF_QUEUE or ORDERED Task
1840 * Attribute. 1844 * Attribute.
1841 */ 1845 */
1842 if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 1846 transport_complete_task_attr(cmd);
1843 transport_complete_task_attr(cmd); 1847
1844 /* 1848 /*
1845 * Check to schedule QUEUE_FULL work, or execute an existing 1849 * Check to schedule QUEUE_FULL work, or execute an existing
1846 * cmd->transport_qf_callback() 1850 * cmd->transport_qf_callback()