Commit 019c4ca621488739b1bfb7597a14ac7f0cbcc908

Authored by Christoph Hellwig
Committed by Nicholas Bellinger
1 parent e6c4219b54

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>

Showing 4 changed files with 69 additions and 83 deletions Side-by-side Diff

drivers/target/target_core_device.c
... ... @@ -1412,11 +1412,6 @@
1412 1412 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;
1413 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 1415 return dev;
1421 1416 }
1422 1417  
drivers/target/target_core_spc.c
... ... @@ -1054,8 +1054,7 @@
1054 1054 * Do implict HEAD_OF_QUEUE processing for INQUIRY.
1055 1055 * See spc4r17 section 5.3
1056 1056 */
1057   - if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
1058   - cmd->sam_task_attr = MSG_HEAD_TAG;
  1057 + cmd->sam_task_attr = MSG_HEAD_TAG;
1059 1058 cmd->execute_cmd = spc_emulate_inquiry;
1060 1059 break;
1061 1060 case SECURITY_PROTOCOL_IN:
... ... @@ -1083,8 +1082,7 @@
1083 1082 * Do implict HEAD_OF_QUEUE processing for REPORT_LUNS
1084 1083 * See spc4r17 section 5.3
1085 1084 */
1086   - if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
1087   - cmd->sam_task_attr = MSG_HEAD_TAG;
  1085 + cmd->sam_task_attr = MSG_HEAD_TAG;
1088 1086 break;
1089 1087 case TEST_UNIT_READY:
1090 1088 cmd->execute_cmd = spc_emulate_testunitready;
drivers/target/target_core_transport.c
... ... @@ -1068,11 +1068,13 @@
1068 1068  
1069 1069 static int transport_check_alloc_task_attr(struct se_cmd *cmd)
1070 1070 {
  1071 + struct se_device *dev = cmd->se_dev;
  1072 +
1071 1073 /*
1072 1074 * Check if SAM Task Attribute emulation is enabled for this
1073 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 1078 return 0;
1077 1079  
1078 1080 if (cmd->sam_task_attr == MSG_ACA_TAG) {
1079 1081  
... ... @@ -1084,11 +1086,11 @@
1084 1086 * Used to determine when ORDERED commands should go from
1085 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 1090 smp_mb__after_atomic_inc();
1089 1091 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
1090 1092 cmd->se_ordered_id, cmd->sam_task_attr,
1091   - cmd->se_dev->transport->name);
  1093 + dev->transport->name);
1092 1094 return 0;
1093 1095 }
1094 1096  
... ... @@ -1534,8 +1536,7 @@
1534 1536 /*
1535 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)
1538   - transport_complete_task_attr(cmd);
  1539 + transport_complete_task_attr(cmd);
1539 1540  
1540 1541 switch (cmd->scsi_sense_reason) {
1541 1542 case TCM_NON_EXISTENT_LUN:
1542 1543  
1543 1544  
... ... @@ -1619,51 +1620,14 @@
1619 1620 }
1620 1621 }
1621 1622  
1622   -void target_execute_cmd(struct se_cmd *cmd)
  1623 +static bool target_handle_task_attr(struct se_cmd *cmd)
1623 1624 {
1624 1625 struct se_device *dev = cmd->se_dev;
1625 1626  
1626   - /*
1627   - * If the received CDB has aleady been aborted stop processing it here.
1628   - */
1629   - if (transport_check_aborted_status(cmd, 1))
1630   - return;
  1627 + if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
  1628 + return false;
1631 1629  
1632 1630 /*
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   -
1666   - /*
1667 1631 * Check for the existence of HEAD_OF_QUEUE, and if true return 1
1668 1632 * to allow the passed struct se_cmd list of tasks to the front of the list.
1669 1633 */
... ... @@ -1672,7 +1636,7 @@
1672 1636 pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x, "
1673 1637 "se_ordered_id: %u\n",
1674 1638 cmd->t_task_cdb[0], cmd->se_ordered_id);
1675   - goto execute;
  1639 + return false;
1676 1640 case MSG_ORDERED_TAG:
1677 1641 atomic_inc(&dev->dev_ordered_sync);
1678 1642 smp_mb__after_atomic_inc();
... ... @@ -1686,7 +1650,7 @@
1686 1650 * exist that need to be completed first.
1687 1651 */
1688 1652 if (!atomic_read(&dev->simple_cmds))
1689   - goto execute;
  1653 + return false;
1690 1654 break;
1691 1655 default:
1692 1656 /*
1693 1657  
1694 1658  
1695 1659  
1696 1660  
1697 1661  
... ... @@ -1697,23 +1661,61 @@
1697 1661 break;
1698 1662 }
1699 1663  
1700   - if (atomic_read(&dev->dev_ordered_sync) != 0) {
1701   - spin_lock(&dev->delayed_cmd_lock);
1702   - list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
1703   - spin_unlock(&dev->delayed_cmd_lock);
  1664 + if (atomic_read(&dev->dev_ordered_sync) == 0)
  1665 + return false;
1704 1666  
1705   - pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to"
1706   - " delayed CMD list, se_ordered_id: %u\n",
1707   - cmd->t_task_cdb[0], cmd->sam_task_attr,
1708   - cmd->se_ordered_id);
  1667 + spin_lock(&dev->delayed_cmd_lock);
  1668 + list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
  1669 + spin_unlock(&dev->delayed_cmd_lock);
  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 +
  1678 +void 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 1684 return;
1710   - }
1711 1685  
1712   -execute:
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 }
1718 1720 EXPORT_SYMBOL(target_execute_cmd);
1719 1721  
... ... @@ -1752,6 +1754,9 @@
1752 1754 {
1753 1755 struct se_device *dev = cmd->se_dev;
1754 1756  
  1757 + if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
  1758 + return;
  1759 +
1755 1760 if (cmd->sam_task_attr == MSG_SIMPLE_TAG) {
1756 1761 atomic_dec(&dev->simple_cmds);
1757 1762 smp_mb__after_atomic_dec();
... ... @@ -1780,8 +1785,7 @@
1780 1785 {
1781 1786 int ret = 0;
1782 1787  
1783   - if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
1784   - transport_complete_task_attr(cmd);
  1788 + transport_complete_task_attr(cmd);
1785 1789  
1786 1790 if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
1787 1791 ret = cmd->se_tfo->queue_status(cmd);
... ... @@ -1839,8 +1843,8 @@
1839 1843 * delayed execution list after a HEAD_OF_QUEUE or ORDERED Task
1840 1844 * Attribute.
1841 1845 */
1842   - if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
1843   - transport_complete_task_attr(cmd);
  1846 + transport_complete_task_attr(cmd);
  1847 +
1844 1848 /*
1845 1849 * Check to schedule QUEUE_FULL work, or execute an existing
1846 1850 * cmd->transport_qf_callback()
include/target/target_core_base.h
... ... @@ -233,16 +233,6 @@
233 233 } t10_alua_index_t;
234 234  
235 235 /*
236   - * Used by TCM Core internally to signal if SAM Task Attribute emulation
237   - * is enabled or disabled, or running in with TCM/pSCSI passthrough mode
238   - */
239   -typedef enum {
240   - SAM_TASK_ATTR_PASSTHROUGH,
241   - SAM_TASK_ATTR_UNTAGGED,
242   - SAM_TASK_ATTR_EMULATED
243   -} t10_task_attr_index_t;
244   -
245   -/*
246 236 * Used for target SCSI statistics
247 237 */
248 238 typedef enum {
... ... @@ -686,7 +676,6 @@
686 676 u32 queue_depth;
687 677 /* Used for SPC-2 reservations enforce of ISIDs */
688 678 u64 dev_res_bin_isid;
689   - t10_task_attr_index_t dev_task_attr_type;
690 679 /* Pointer to transport specific device structure */
691 680 u32 dev_index;
692 681 u64 creation_time;