diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-10-10 17:37:16 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-11-06 23:55:45 -0500 |
commit | c87fbd5656f263f0fc1c37d20f402797c068232e (patch) | |
tree | af83a409d4ba234cf0f67419e48d5588423d05ad /drivers/target | |
parent | d977f4377fbc396b888e12fdb3b13118b09ca7db (diff) |
target: simplify alua support
We always support ALUA for virtual backends, and never for physical ones. Simplify
the code to just deal with these two cases and remove the superflous abstractions.
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_alua.c | 135 | ||||
-rw-r--r-- | drivers/target/target_core_alua.h | 1 | ||||
-rw-r--r-- | drivers/target/target_core_configfs.c | 28 | ||||
-rw-r--r-- | drivers/target/target_core_device.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_spc.c | 12 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 38 |
6 files changed, 65 insertions, 153 deletions
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 15c127b780d8..b3302a9200a2 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c | |||
@@ -522,40 +522,26 @@ static inline int core_alua_state_transition( | |||
522 | } | 522 | } |
523 | 523 | ||
524 | /* | 524 | /* |
525 | * Used for alua_type SPC_ALUA_PASSTHROUGH and SPC2_ALUA_DISABLED | ||
526 | * in transport_cmd_sequencer(). This function is assigned to | ||
527 | * struct t10_alua *->state_check() in core_setup_alua() | ||
528 | */ | ||
529 | static int core_alua_state_check_nop( | ||
530 | struct se_cmd *cmd, | ||
531 | unsigned char *cdb, | ||
532 | u8 *alua_ascq) | ||
533 | { | ||
534 | return 0; | ||
535 | } | ||
536 | |||
537 | /* | ||
538 | * Used for alua_type SPC3_ALUA_EMULATED in transport_cmd_sequencer(). | ||
539 | * This function is assigned to struct t10_alua *->state_check() in | ||
540 | * core_setup_alua() | ||
541 | * | ||
542 | * Also, this function can return three different return codes to | ||
543 | * signal transport_generic_cmd_sequencer() | ||
544 | * | ||
545 | * return 1: Is used to signal LUN not accecsable, and check condition/not ready | 525 | * return 1: Is used to signal LUN not accecsable, and check condition/not ready |
546 | * return 0: Used to signal success | 526 | * return 0: Used to signal success |
547 | * reutrn -1: Used to signal failure, and invalid cdb field | 527 | * reutrn -1: Used to signal failure, and invalid cdb field |
548 | */ | 528 | */ |
549 | static int core_alua_state_check( | 529 | int target_alua_state_check(struct se_cmd *cmd) |
550 | struct se_cmd *cmd, | ||
551 | unsigned char *cdb, | ||
552 | u8 *alua_ascq) | ||
553 | { | 530 | { |
531 | struct se_device *dev = cmd->se_dev; | ||
532 | unsigned char *cdb = cmd->t_task_cdb; | ||
554 | struct se_lun *lun = cmd->se_lun; | 533 | struct se_lun *lun = cmd->se_lun; |
555 | struct se_port *port = lun->lun_sep; | 534 | struct se_port *port = lun->lun_sep; |
556 | struct t10_alua_tg_pt_gp *tg_pt_gp; | 535 | struct t10_alua_tg_pt_gp *tg_pt_gp; |
557 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; | 536 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; |
558 | int out_alua_state, nonop_delay_msecs; | 537 | int out_alua_state, nonop_delay_msecs; |
538 | u8 alua_ascq; | ||
539 | int ret; | ||
540 | |||
541 | if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) | ||
542 | return 0; | ||
543 | if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) | ||
544 | return 0; | ||
559 | 545 | ||
560 | if (!port) | 546 | if (!port) |
561 | return 0; | 547 | return 0; |
@@ -564,11 +550,11 @@ static int core_alua_state_check( | |||
564 | * access state: OFFLINE | 550 | * access state: OFFLINE |
565 | */ | 551 | */ |
566 | if (atomic_read(&port->sep_tg_pt_secondary_offline)) { | 552 | if (atomic_read(&port->sep_tg_pt_secondary_offline)) { |
567 | *alua_ascq = ASCQ_04H_ALUA_OFFLINE; | ||
568 | pr_debug("ALUA: Got secondary offline status for local" | 553 | pr_debug("ALUA: Got secondary offline status for local" |
569 | " target port\n"); | 554 | " target port\n"); |
570 | *alua_ascq = ASCQ_04H_ALUA_OFFLINE; | 555 | alua_ascq = ASCQ_04H_ALUA_OFFLINE; |
571 | return 1; | 556 | ret = 1; |
557 | goto out; | ||
572 | } | 558 | } |
573 | /* | 559 | /* |
574 | * Second, obtain the struct t10_alua_tg_pt_gp_member pointer to the | 560 | * Second, obtain the struct t10_alua_tg_pt_gp_member pointer to the |
@@ -593,14 +579,18 @@ static int core_alua_state_check( | |||
593 | 579 | ||
594 | switch (out_alua_state) { | 580 | switch (out_alua_state) { |
595 | case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED: | 581 | case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED: |
596 | return core_alua_state_nonoptimized(cmd, cdb, | 582 | ret = core_alua_state_nonoptimized(cmd, cdb, |
597 | nonop_delay_msecs, alua_ascq); | 583 | nonop_delay_msecs, &alua_ascq); |
584 | break; | ||
598 | case ALUA_ACCESS_STATE_STANDBY: | 585 | case ALUA_ACCESS_STATE_STANDBY: |
599 | return core_alua_state_standby(cmd, cdb, alua_ascq); | 586 | ret = core_alua_state_standby(cmd, cdb, &alua_ascq); |
587 | break; | ||
600 | case ALUA_ACCESS_STATE_UNAVAILABLE: | 588 | case ALUA_ACCESS_STATE_UNAVAILABLE: |
601 | return core_alua_state_unavailable(cmd, cdb, alua_ascq); | 589 | ret = core_alua_state_unavailable(cmd, cdb, &alua_ascq); |
590 | break; | ||
602 | case ALUA_ACCESS_STATE_TRANSITION: | 591 | case ALUA_ACCESS_STATE_TRANSITION: |
603 | return core_alua_state_transition(cmd, cdb, alua_ascq); | 592 | ret = core_alua_state_transition(cmd, cdb, &alua_ascq); |
593 | break; | ||
604 | /* | 594 | /* |
605 | * OFFLINE is a secondary ALUA target port group access state, that is | 595 | * OFFLINE is a secondary ALUA target port group access state, that is |
606 | * handled above with struct se_port->sep_tg_pt_secondary_offline=1 | 596 | * handled above with struct se_port->sep_tg_pt_secondary_offline=1 |
@@ -609,10 +599,27 @@ static int core_alua_state_check( | |||
609 | default: | 599 | default: |
610 | pr_err("Unknown ALUA access state: 0x%02x\n", | 600 | pr_err("Unknown ALUA access state: 0x%02x\n", |
611 | out_alua_state); | 601 | out_alua_state); |
612 | return -EINVAL; | 602 | ret = -EINVAL; |
603 | break; | ||
613 | } | 604 | } |
614 | 605 | ||
615 | return 0; | 606 | out: |
607 | if (ret > 0) { | ||
608 | /* | ||
609 | * Set SCSI additional sense code (ASC) to 'LUN Not Accessible'; | ||
610 | * The ALUA additional sense code qualifier (ASCQ) is determined | ||
611 | * by the ALUA primary or secondary access state.. | ||
612 | */ | ||
613 | pr_debug("[%s]: ALUA TG Port not available, " | ||
614 | "SenseKey: NOT_READY, ASC/ASCQ: " | ||
615 | "0x04/0x%02x\n", | ||
616 | cmd->se_tfo->get_fabric_name(), alua_ascq); | ||
617 | |||
618 | cmd->scsi_asc = 0x04; | ||
619 | cmd->scsi_ascq = alua_ascq; | ||
620 | } | ||
621 | |||
622 | return ret; | ||
616 | } | 623 | } |
617 | 624 | ||
618 | /* | 625 | /* |
@@ -1264,13 +1271,9 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp) | |||
1264 | 1271 | ||
1265 | void core_alua_free_lu_gp_mem(struct se_device *dev) | 1272 | void core_alua_free_lu_gp_mem(struct se_device *dev) |
1266 | { | 1273 | { |
1267 | struct t10_alua *alua = &dev->t10_alua; | ||
1268 | struct t10_alua_lu_gp *lu_gp; | 1274 | struct t10_alua_lu_gp *lu_gp; |
1269 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1275 | struct t10_alua_lu_gp_member *lu_gp_mem; |
1270 | 1276 | ||
1271 | if (alua->alua_type != SPC3_ALUA_EMULATED) | ||
1272 | return; | ||
1273 | |||
1274 | lu_gp_mem = dev->dev_alua_lu_gp_mem; | 1277 | lu_gp_mem = dev->dev_alua_lu_gp_mem; |
1275 | if (!lu_gp_mem) | 1278 | if (!lu_gp_mem) |
1276 | return; | 1279 | return; |
@@ -1538,13 +1541,9 @@ void core_alua_free_tg_pt_gp( | |||
1538 | 1541 | ||
1539 | void core_alua_free_tg_pt_gp_mem(struct se_port *port) | 1542 | void core_alua_free_tg_pt_gp_mem(struct se_port *port) |
1540 | { | 1543 | { |
1541 | struct t10_alua *alua = &port->sep_lun->lun_se_dev->t10_alua; | ||
1542 | struct t10_alua_tg_pt_gp *tg_pt_gp; | 1544 | struct t10_alua_tg_pt_gp *tg_pt_gp; |
1543 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; | 1545 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; |
1544 | 1546 | ||
1545 | if (alua->alua_type != SPC3_ALUA_EMULATED) | ||
1546 | return; | ||
1547 | |||
1548 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; | 1547 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; |
1549 | if (!tg_pt_gp_mem) | 1548 | if (!tg_pt_gp_mem) |
1550 | return; | 1549 | return; |
@@ -1636,14 +1635,10 @@ static void __core_alua_drop_tg_pt_gp_mem( | |||
1636 | ssize_t core_alua_show_tg_pt_gp_info(struct se_port *port, char *page) | 1635 | ssize_t core_alua_show_tg_pt_gp_info(struct se_port *port, char *page) |
1637 | { | 1636 | { |
1638 | struct config_item *tg_pt_ci; | 1637 | struct config_item *tg_pt_ci; |
1639 | struct t10_alua *alua = &port->sep_lun->lun_se_dev->t10_alua; | ||
1640 | struct t10_alua_tg_pt_gp *tg_pt_gp; | 1638 | struct t10_alua_tg_pt_gp *tg_pt_gp; |
1641 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; | 1639 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; |
1642 | ssize_t len = 0; | 1640 | ssize_t len = 0; |
1643 | 1641 | ||
1644 | if (alua->alua_type != SPC3_ALUA_EMULATED) | ||
1645 | return len; | ||
1646 | |||
1647 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; | 1642 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; |
1648 | if (!tg_pt_gp_mem) | 1643 | if (!tg_pt_gp_mem) |
1649 | return len; | 1644 | return len; |
@@ -1686,13 +1681,9 @@ ssize_t core_alua_store_tg_pt_gp_info( | |||
1686 | tpg = port->sep_tpg; | 1681 | tpg = port->sep_tpg; |
1687 | lun = port->sep_lun; | 1682 | lun = port->sep_lun; |
1688 | 1683 | ||
1689 | if (dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) { | 1684 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; |
1690 | pr_warn("SPC3_ALUA_EMULATED not enabled for" | 1685 | if (!tg_pt_gp_mem) |
1691 | " %s/tpgt_%hu/%s\n", tpg->se_tpg_tfo->tpg_get_wwn(tpg), | 1686 | return 0; |
1692 | tpg->se_tpg_tfo->tpg_get_tag(tpg), | ||
1693 | config_item_name(&lun->lun_group.cg_item)); | ||
1694 | return -EINVAL; | ||
1695 | } | ||
1696 | 1687 | ||
1697 | if (count > TG_PT_GROUP_NAME_BUF) { | 1688 | if (count > TG_PT_GROUP_NAME_BUF) { |
1698 | pr_err("ALUA Target Port Group alias too large!\n"); | 1689 | pr_err("ALUA Target Port Group alias too large!\n"); |
@@ -1715,13 +1706,6 @@ ssize_t core_alua_store_tg_pt_gp_info( | |||
1715 | if (!tg_pt_gp_new) | 1706 | if (!tg_pt_gp_new) |
1716 | return -ENODEV; | 1707 | return -ENODEV; |
1717 | } | 1708 | } |
1718 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; | ||
1719 | if (!tg_pt_gp_mem) { | ||
1720 | if (tg_pt_gp_new) | ||
1721 | core_alua_put_tg_pt_gp_from_name(tg_pt_gp_new); | ||
1722 | pr_err("NULL struct se_port->sep_alua_tg_pt_gp_mem pointer\n"); | ||
1723 | return -EINVAL; | ||
1724 | } | ||
1725 | 1709 | ||
1726 | spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); | 1710 | spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); |
1727 | tg_pt_gp = tg_pt_gp_mem->tg_pt_gp; | 1711 | tg_pt_gp = tg_pt_gp_mem->tg_pt_gp; |
@@ -2050,26 +2034,9 @@ ssize_t core_alua_store_secondary_write_metadata( | |||
2050 | 2034 | ||
2051 | int core_setup_alua(struct se_device *dev) | 2035 | int core_setup_alua(struct se_device *dev) |
2052 | { | 2036 | { |
2053 | struct t10_alua *alua = &dev->t10_alua; | 2037 | if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV && |
2054 | struct t10_alua_lu_gp_member *lu_gp_mem; | 2038 | !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { |
2055 | 2039 | struct t10_alua_lu_gp_member *lu_gp_mem; | |
2056 | /* | ||
2057 | * If this device is from Target_Core_Mod/pSCSI, use the ALUA logic | ||
2058 | * of the Underlying SCSI hardware. In Linux/SCSI terms, this can | ||
2059 | * cause a problem because libata and some SATA RAID HBAs appear | ||
2060 | * under Linux/SCSI, but emulate SCSI logic themselves. | ||
2061 | */ | ||
2062 | if ((dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) || | ||
2063 | (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV && | ||
2064 | !dev->dev_attrib.emulate_alua)) { | ||
2065 | pr_debug("%s: Using SPC_ALUA_PASSTHROUGH, no ALUA" | ||
2066 | " emulation\n", dev->transport->name); | ||
2067 | |||
2068 | alua->alua_type = SPC_ALUA_PASSTHROUGH; | ||
2069 | alua->alua_state_check = &core_alua_state_check_nop; | ||
2070 | } else if (dev->transport->get_device_rev(dev) >= SCSI_3) { | ||
2071 | pr_debug("%s: Enabling ALUA Emulation for SPC-3" | ||
2072 | " device\n", dev->transport->name); | ||
2073 | 2040 | ||
2074 | /* | 2041 | /* |
2075 | * Associate this struct se_device with the default ALUA | 2042 | * Associate this struct se_device with the default ALUA |
@@ -2079,8 +2046,6 @@ int core_setup_alua(struct se_device *dev) | |||
2079 | if (IS_ERR(lu_gp_mem)) | 2046 | if (IS_ERR(lu_gp_mem)) |
2080 | return PTR_ERR(lu_gp_mem); | 2047 | return PTR_ERR(lu_gp_mem); |
2081 | 2048 | ||
2082 | alua->alua_type = SPC3_ALUA_EMULATED; | ||
2083 | alua->alua_state_check = &core_alua_state_check; | ||
2084 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); | 2049 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); |
2085 | __core_alua_attach_lu_gp_mem(lu_gp_mem, | 2050 | __core_alua_attach_lu_gp_mem(lu_gp_mem, |
2086 | default_lu_gp); | 2051 | default_lu_gp); |
@@ -2089,12 +2054,6 @@ int core_setup_alua(struct se_device *dev) | |||
2089 | pr_debug("%s: Adding to default ALUA LU Group:" | 2054 | pr_debug("%s: Adding to default ALUA LU Group:" |
2090 | " core/alua/lu_gps/default_lu_gp\n", | 2055 | " core/alua/lu_gps/default_lu_gp\n", |
2091 | dev->transport->name); | 2056 | dev->transport->name); |
2092 | } else { | ||
2093 | pr_debug("%s: Disabling ALUA Emulation for SPC-2" | ||
2094 | " device\n", dev->transport->name); | ||
2095 | |||
2096 | alua->alua_type = SPC2_ALUA_DISABLED; | ||
2097 | alua->alua_state_check = &core_alua_state_check_nop; | ||
2098 | } | 2057 | } |
2099 | 2058 | ||
2100 | return 0; | 2059 | return 0; |
diff --git a/drivers/target/target_core_alua.h b/drivers/target/target_core_alua.h index 5019157ffe69..a2af8aa15b98 100644 --- a/drivers/target/target_core_alua.h +++ b/drivers/target/target_core_alua.h | |||
@@ -132,5 +132,6 @@ extern ssize_t core_alua_show_secondary_write_metadata(struct se_lun *, | |||
132 | extern ssize_t core_alua_store_secondary_write_metadata(struct se_lun *, | 132 | extern ssize_t core_alua_store_secondary_write_metadata(struct se_lun *, |
133 | const char *, size_t); | 133 | const char *, size_t); |
134 | extern int core_setup_alua(struct se_device *); | 134 | extern int core_setup_alua(struct se_device *); |
135 | extern int target_alua_state_check(struct se_cmd *cmd); | ||
135 | 136 | ||
136 | #endif /* TARGET_CORE_ALUA_H */ | 137 | #endif /* TARGET_CORE_ALUA_H */ |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 3d5570da41eb..7b473b66da7b 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -1615,15 +1615,9 @@ static ssize_t target_core_show_alua_lu_gp(void *p, char *page) | |||
1615 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1615 | struct t10_alua_lu_gp_member *lu_gp_mem; |
1616 | ssize_t len = 0; | 1616 | ssize_t len = 0; |
1617 | 1617 | ||
1618 | if (dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) | ||
1619 | return len; | ||
1620 | |||
1621 | lu_gp_mem = dev->dev_alua_lu_gp_mem; | 1618 | lu_gp_mem = dev->dev_alua_lu_gp_mem; |
1622 | if (!lu_gp_mem) { | 1619 | if (!lu_gp_mem) |
1623 | pr_err("NULL struct se_device->dev_alua_lu_gp_mem" | 1620 | return 0; |
1624 | " pointer\n"); | ||
1625 | return -EINVAL; | ||
1626 | } | ||
1627 | 1621 | ||
1628 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); | 1622 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); |
1629 | lu_gp = lu_gp_mem->lu_gp; | 1623 | lu_gp = lu_gp_mem->lu_gp; |
@@ -1649,12 +1643,10 @@ static ssize_t target_core_store_alua_lu_gp( | |||
1649 | unsigned char buf[LU_GROUP_NAME_BUF]; | 1643 | unsigned char buf[LU_GROUP_NAME_BUF]; |
1650 | int move = 0; | 1644 | int move = 0; |
1651 | 1645 | ||
1652 | if (dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) { | 1646 | lu_gp_mem = dev->dev_alua_lu_gp_mem; |
1653 | pr_warn("SPC3_ALUA_EMULATED not enabled for %s/%s\n", | 1647 | if (!lu_gp_mem) |
1654 | config_item_name(&hba->hba_group.cg_item), | 1648 | return 0; |
1655 | config_item_name(&dev->dev_group.cg_item)); | 1649 | |
1656 | return -EINVAL; | ||
1657 | } | ||
1658 | if (count > LU_GROUP_NAME_BUF) { | 1650 | if (count > LU_GROUP_NAME_BUF) { |
1659 | pr_err("ALUA LU Group Alias too large!\n"); | 1651 | pr_err("ALUA LU Group Alias too large!\n"); |
1660 | return -EINVAL; | 1652 | return -EINVAL; |
@@ -1675,14 +1667,6 @@ static ssize_t target_core_store_alua_lu_gp( | |||
1675 | if (!lu_gp_new) | 1667 | if (!lu_gp_new) |
1676 | return -ENODEV; | 1668 | return -ENODEV; |
1677 | } | 1669 | } |
1678 | lu_gp_mem = dev->dev_alua_lu_gp_mem; | ||
1679 | if (!lu_gp_mem) { | ||
1680 | if (lu_gp_new) | ||
1681 | core_alua_put_lu_gp_from_name(lu_gp_new); | ||
1682 | pr_err("NULL struct se_device->dev_alua_lu_gp_mem" | ||
1683 | " pointer\n"); | ||
1684 | return -EINVAL; | ||
1685 | } | ||
1686 | 1670 | ||
1687 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); | 1671 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); |
1688 | lu_gp = lu_gp_mem->lu_gp; | 1672 | lu_gp = lu_gp_mem->lu_gp; |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 4ae1d3913821..3c3a3019ce7b 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -556,7 +556,8 @@ static void core_export_port( | |||
556 | list_add_tail(&port->sep_list, &dev->dev_sep_list); | 556 | list_add_tail(&port->sep_list, &dev->dev_sep_list); |
557 | spin_unlock(&dev->se_port_lock); | 557 | spin_unlock(&dev->se_port_lock); |
558 | 558 | ||
559 | if (dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { | 559 | if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV && |
560 | !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { | ||
560 | tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port); | 561 | tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port); |
561 | if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) { | 562 | if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) { |
562 | pr_err("Unable to allocate t10_alua_tg_pt" | 563 | pr_err("Unable to allocate t10_alua_tg_pt" |
@@ -1398,7 +1399,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) | |||
1398 | dev->dev_attrib.emulate_tas = DA_EMULATE_TAS; | 1399 | dev->dev_attrib.emulate_tas = DA_EMULATE_TAS; |
1399 | dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU; | 1400 | dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU; |
1400 | dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS; | 1401 | dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS; |
1401 | dev->dev_attrib.emulate_alua = DA_EMULATE_ALUA; | ||
1402 | dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; | 1402 | dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; |
1403 | dev->dev_attrib.is_nonrot = DA_IS_NONROT; | 1403 | dev->dev_attrib.is_nonrot = DA_IS_NONROT; |
1404 | dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD; | 1404 | dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD; |
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 862e4347f68f..7ecac453b11a 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -95,8 +95,7 @@ static int spc_emulate_inquiry_std(struct se_cmd *cmd, char *buf) | |||
95 | /* | 95 | /* |
96 | * Enable SCCS and TPGS fields for Emulated ALUA | 96 | * Enable SCCS and TPGS fields for Emulated ALUA |
97 | */ | 97 | */ |
98 | if (dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) | 98 | spc_fill_alua_data(lun->lun_sep, buf); |
99 | spc_fill_alua_data(lun->lun_sep, buf); | ||
100 | 99 | ||
101 | buf[7] = 0x2; /* CmdQue=1 */ | 100 | buf[7] = 0x2; /* CmdQue=1 */ |
102 | 101 | ||
@@ -294,9 +293,6 @@ check_t10_vend_desc: | |||
294 | * Get the PROTOCOL IDENTIFIER as defined by spc4r17 | 293 | * Get the PROTOCOL IDENTIFIER as defined by spc4r17 |
295 | * section 7.5.1 Table 362 | 294 | * section 7.5.1 Table 362 |
296 | */ | 295 | */ |
297 | if (dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) | ||
298 | goto check_scsi_name; | ||
299 | |||
300 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; | 296 | tg_pt_gp_mem = port->sep_alua_tg_pt_gp_mem; |
301 | if (!tg_pt_gp_mem) | 297 | if (!tg_pt_gp_mem) |
302 | goto check_lu_gp; | 298 | goto check_lu_gp; |
@@ -1083,8 +1079,7 @@ int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) | |||
1083 | * MAINTENANCE_IN from SCC-2 | 1079 | * MAINTENANCE_IN from SCC-2 |
1084 | * Check for emulated MI_REPORT_TARGET_PGS | 1080 | * Check for emulated MI_REPORT_TARGET_PGS |
1085 | */ | 1081 | */ |
1086 | if ((cdb[1] & 0x1f) == MI_REPORT_TARGET_PGS && | 1082 | if ((cdb[1] & 0x1f) == MI_REPORT_TARGET_PGS) { |
1087 | dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { | ||
1088 | cmd->execute_cmd = | 1083 | cmd->execute_cmd = |
1089 | target_emulate_report_target_port_groups; | 1084 | target_emulate_report_target_port_groups; |
1090 | } | 1085 | } |
@@ -1102,8 +1097,7 @@ int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) | |||
1102 | * MAINTENANCE_OUT from SCC-2 | 1097 | * MAINTENANCE_OUT from SCC-2 |
1103 | * Check for emulated MO_SET_TARGET_PGS. | 1098 | * Check for emulated MO_SET_TARGET_PGS. |
1104 | */ | 1099 | */ |
1105 | if (cdb[1] == MO_SET_TARGET_PGS && | 1100 | if (cdb[1] == MO_SET_TARGET_PGS) { |
1106 | dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { | ||
1107 | cmd->execute_cmd = | 1101 | cmd->execute_cmd = |
1108 | target_emulate_set_target_port_groups; | 1102 | target_emulate_set_target_port_groups; |
1109 | } | 1103 | } |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index e996bdf480cf..c4c931b525d2 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -70,7 +70,6 @@ static void transport_handle_queue_full(struct se_cmd *cmd, | |||
70 | static int transport_generic_get_mem(struct se_cmd *cmd); | 70 | static int transport_generic_get_mem(struct se_cmd *cmd); |
71 | static int target_get_sess_cmd(struct se_session *, struct se_cmd *, bool); | 71 | static int target_get_sess_cmd(struct se_session *, struct se_cmd *, bool); |
72 | static void transport_put_cmd(struct se_cmd *cmd); | 72 | static void transport_put_cmd(struct se_cmd *cmd); |
73 | static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq); | ||
74 | static void target_complete_ok_work(struct work_struct *work); | 73 | static void target_complete_ok_work(struct work_struct *work); |
75 | 74 | ||
76 | int init_se_kmem_caches(void) | 75 | int init_se_kmem_caches(void) |
@@ -1103,7 +1102,6 @@ int target_setup_cmd_from_cdb( | |||
1103 | unsigned char *cdb) | 1102 | unsigned char *cdb) |
1104 | { | 1103 | { |
1105 | struct se_device *dev = cmd->se_dev; | 1104 | struct se_device *dev = cmd->se_dev; |
1106 | u8 alua_ascq = 0; | ||
1107 | unsigned long flags; | 1105 | unsigned long flags; |
1108 | int ret; | 1106 | int ret; |
1109 | 1107 | ||
@@ -1153,26 +1151,13 @@ int target_setup_cmd_from_cdb( | |||
1153 | return -EINVAL; | 1151 | return -EINVAL; |
1154 | } | 1152 | } |
1155 | 1153 | ||
1156 | ret = dev->t10_alua.alua_state_check(cmd, cdb, &alua_ascq); | 1154 | ret = target_alua_state_check(cmd); |
1157 | if (ret != 0) { | 1155 | if (ret) { |
1158 | /* | ||
1159 | * Set SCSI additional sense code (ASC) to 'LUN Not Accessible'; | ||
1160 | * The ALUA additional sense code qualifier (ASCQ) is determined | ||
1161 | * by the ALUA primary or secondary access state.. | ||
1162 | */ | ||
1163 | if (ret > 0) { | ||
1164 | pr_debug("[%s]: ALUA TG Port not available, " | ||
1165 | "SenseKey: NOT_READY, ASC/ASCQ: " | ||
1166 | "0x04/0x%02x\n", | ||
1167 | cmd->se_tfo->get_fabric_name(), alua_ascq); | ||
1168 | |||
1169 | transport_set_sense_codes(cmd, 0x04, alua_ascq); | ||
1170 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1171 | cmd->scsi_sense_reason = TCM_CHECK_CONDITION_NOT_READY; | ||
1172 | return -EINVAL; | ||
1173 | } | ||
1174 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | 1156 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; |
1175 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | 1157 | if (ret > 0) |
1158 | cmd->scsi_sense_reason = TCM_CHECK_CONDITION_NOT_READY; | ||
1159 | else | ||
1160 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
1176 | return -EINVAL; | 1161 | return -EINVAL; |
1177 | } | 1162 | } |
1178 | 1163 | ||
@@ -2640,17 +2625,6 @@ static int transport_get_sense_codes( | |||
2640 | return 0; | 2625 | return 0; |
2641 | } | 2626 | } |
2642 | 2627 | ||
2643 | static int transport_set_sense_codes( | ||
2644 | struct se_cmd *cmd, | ||
2645 | u8 asc, | ||
2646 | u8 ascq) | ||
2647 | { | ||
2648 | cmd->scsi_asc = asc; | ||
2649 | cmd->scsi_ascq = ascq; | ||
2650 | |||
2651 | return 0; | ||
2652 | } | ||
2653 | |||
2654 | int transport_send_check_condition_and_sense( | 2628 | int transport_send_check_condition_and_sense( |
2655 | struct se_cmd *cmd, | 2629 | struct se_cmd *cmd, |
2656 | u8 reason, | 2630 | u8 reason, |