aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_fsf.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2010-09-08 08:39:55 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-09-16 22:54:17 -0400
commitb62a8d9b45b971a67a0f8413338c230e3117dff5 (patch)
treea38acd9f0fcb14e41e26503d8a25d8f1539dd27d /drivers/s390/scsi/zfcp_fsf.c
parentfdbd1c5e27dabfa950d4b0f52a20069aeaf67b9d (diff)
[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit
This is the large change to switch from using the data in zfcp_unit to zfcp_scsi_dev. Keeping everything working requires doing the switch in one piece. To ensure that no code keeps using the data in zfcp_unit, this patch also removes the data from zfcp_unit that is now being replaced with zfcp_scsi_dev. For zfcp, the scsi_device together with zfcp_scsi_dev exist from the call of slave_alloc to the call of slave_destroy. The data in zfcp_scsi_dev is initialized in zfcp_scsi_slave_alloc and the LUN is opened; the final shutdown for the LUN is run from slave_destroy. Where the scsi_device or zfcp_scsi_dev is needed, the pointer to the scsi_device is passed as function argument and inside the function converted to the pointer to zfcp_scsi_dev; this avoids back and forth conversion betweeen scsi_device and zfcp_scsi_dev. While changing the function arguments from zfcp_unit to scsi_device, the functions names are renamed form "unit" to "lun". This is to have a seperation between zfcp_scsi_dev/LUN and the zfcp_unit; only code referring to the remaining configuration information in zfcp_unit struct uses "unit". Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_fsf.c')
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c279
1 files changed, 140 insertions, 139 deletions
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 9d1d7d1842ce..2fbd80257bca 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -86,17 +86,19 @@ static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
86 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 86 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
87} 87}
88 88
89static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req, 89static void zfcp_fsf_access_denied_lun(struct zfcp_fsf_req *req,
90 struct zfcp_unit *unit) 90 struct scsi_device *sdev)
91{ 91{
92 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
93
92 struct fsf_qtcb_header *header = &req->qtcb->header; 94 struct fsf_qtcb_header *header = &req->qtcb->header;
93 dev_warn(&req->adapter->ccw_device->dev, 95 dev_warn(&req->adapter->ccw_device->dev,
94 "Access denied to unit 0x%016Lx on port 0x%016Lx\n", 96 "Access denied to LUN 0x%016Lx on port 0x%016Lx\n",
95 (unsigned long long)unit->fcp_lun, 97 (unsigned long long)zfcp_scsi_dev_lun(sdev),
96 (unsigned long long)unit->port->wwpn); 98 (unsigned long long)zfcp_sdev->port->wwpn);
97 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); 99 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
98 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); 100 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
99 zfcp_erp_unit_access_denied(unit, "fsuad_1", req); 101 zfcp_erp_lun_access_denied(sdev, "fsadl_1", req);
100 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 102 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
101} 103}
102 104
@@ -811,7 +813,8 @@ out:
811 813
812static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) 814static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
813{ 815{
814 struct zfcp_unit *unit = req->data; 816 struct scsi_device *sdev = req->data;
817 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
815 union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual; 818 union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
816 819
817 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 820 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
@@ -820,14 +823,15 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
820 switch (req->qtcb->header.fsf_status) { 823 switch (req->qtcb->header.fsf_status) {
821 case FSF_PORT_HANDLE_NOT_VALID: 824 case FSF_PORT_HANDLE_NOT_VALID:
822 if (fsq->word[0] == fsq->word[1]) { 825 if (fsq->word[0] == fsq->word[1]) {
823 zfcp_erp_adapter_reopen(unit->port->adapter, 0, 826 zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0,
824 "fsafch1", req); 827 "fsafch1", req);
825 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 828 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
826 } 829 }
827 break; 830 break;
828 case FSF_LUN_HANDLE_NOT_VALID: 831 case FSF_LUN_HANDLE_NOT_VALID:
829 if (fsq->word[0] == fsq->word[1]) { 832 if (fsq->word[0] == fsq->word[1]) {
830 zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req); 833 zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fsafch2",
834 req);
831 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 835 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
832 } 836 }
833 break; 837 break;
@@ -835,17 +839,17 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
835 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; 839 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
836 break; 840 break;
837 case FSF_PORT_BOXED: 841 case FSF_PORT_BOXED:
838 zfcp_erp_port_boxed(unit->port, "fsafch3", req); 842 zfcp_erp_port_boxed(zfcp_sdev->port, "fsafch3", req);
839 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 843 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
840 break; 844 break;
841 case FSF_LUN_BOXED: 845 case FSF_LUN_BOXED:
842 zfcp_erp_unit_boxed(unit, "fsafch4", req); 846 zfcp_erp_lun_boxed(sdev, "fsafch4", req);
843 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 847 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
844 break; 848 break;
845 case FSF_ADAPTER_STATUS_AVAILABLE: 849 case FSF_ADAPTER_STATUS_AVAILABLE:
846 switch (fsq->word[0]) { 850 switch (fsq->word[0]) {
847 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: 851 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
848 zfcp_fc_test_link(unit->port); 852 zfcp_fc_test_link(zfcp_sdev->port);
849 /* fall through */ 853 /* fall through */
850 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: 854 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
851 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 855 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -859,17 +863,18 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
859} 863}
860 864
861/** 865/**
862 * zfcp_fsf_abort_fcp_command - abort running SCSI command 866 * zfcp_fsf_abort_fcp_cmnd - abort running SCSI command
863 * @old_req_id: unsigned long 867 * @scmnd: The SCSI command to abort
864 * @unit: pointer to struct zfcp_unit
865 * Returns: pointer to struct zfcp_fsf_req 868 * Returns: pointer to struct zfcp_fsf_req
866 */ 869 */
867 870
868struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, 871struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd)
869 struct zfcp_unit *unit)
870{ 872{
871 struct zfcp_fsf_req *req = NULL; 873 struct zfcp_fsf_req *req = NULL;
872 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 874 struct scsi_device *sdev = scmnd->device;
875 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
876 struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio;
877 unsigned long old_req_id = (unsigned long) scmnd->host_scribble;
873 878
874 spin_lock_bh(&qdio->req_q_lock); 879 spin_lock_bh(&qdio->req_q_lock);
875 if (zfcp_qdio_sbal_get(qdio)) 880 if (zfcp_qdio_sbal_get(qdio))
@@ -882,16 +887,16 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
882 goto out; 887 goto out;
883 } 888 }
884 889
885 if (unlikely(!(atomic_read(&unit->status) & 890 if (unlikely(!(atomic_read(&zfcp_sdev->status) &
886 ZFCP_STATUS_COMMON_UNBLOCKED))) 891 ZFCP_STATUS_COMMON_UNBLOCKED)))
887 goto out_error_free; 892 goto out_error_free;
888 893
889 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); 894 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
890 895
891 req->data = unit; 896 req->data = zfcp_sdev;
892 req->handler = zfcp_fsf_abort_fcp_command_handler; 897 req->handler = zfcp_fsf_abort_fcp_command_handler;
893 req->qtcb->header.lun_handle = unit->handle; 898 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
894 req->qtcb->header.port_handle = unit->port->handle; 899 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
895 req->qtcb->bottom.support.req_handle = (u64) old_req_id; 900 req->qtcb->bottom.support.req_handle = (u64) old_req_id;
896 901
897 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); 902 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
@@ -1666,7 +1671,7 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1666{ 1671{
1667 struct zfcp_port *port = req->data; 1672 struct zfcp_port *port = req->data;
1668 struct fsf_qtcb_header *header = &req->qtcb->header; 1673 struct fsf_qtcb_header *header = &req->qtcb->header;
1669 struct zfcp_unit *unit; 1674 struct scsi_device *sdev;
1670 1675
1671 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1676 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1672 return; 1677 return;
@@ -1683,11 +1688,10 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1683 /* can't use generic zfcp_erp_modify_port_status because 1688 /* can't use generic zfcp_erp_modify_port_status because
1684 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ 1689 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
1685 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); 1690 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1686 read_lock(&port->unit_list_lock); 1691 shost_for_each_device(sdev, port->adapter->scsi_host)
1687 list_for_each_entry(unit, &port->unit_list, list) 1692 if (sdev_to_zfcp(sdev)->port == port)
1688 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, 1693 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1689 &unit->status); 1694 &sdev_to_zfcp(sdev)->status);
1690 read_unlock(&port->unit_list_lock);
1691 zfcp_erp_port_boxed(port, "fscpph2", req); 1695 zfcp_erp_port_boxed(port, "fscpph2", req);
1692 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1696 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1693 break; 1697 break;
@@ -1705,11 +1709,10 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1705 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port 1709 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
1706 */ 1710 */
1707 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); 1711 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1708 read_lock(&port->unit_list_lock); 1712 shost_for_each_device(sdev, port->adapter->scsi_host)
1709 list_for_each_entry(unit, &port->unit_list, list) 1713 if (sdev_to_zfcp(sdev)->port == port)
1710 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, 1714 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1711 &unit->status); 1715 &sdev_to_zfcp(sdev)->status);
1712 read_unlock(&port->unit_list_lock);
1713 break; 1716 break;
1714 } 1717 }
1715} 1718}
@@ -1758,10 +1761,11 @@ out:
1758 return retval; 1761 return retval;
1759} 1762}
1760 1763
1761static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) 1764static void zfcp_fsf_open_lun_handler(struct zfcp_fsf_req *req)
1762{ 1765{
1763 struct zfcp_adapter *adapter = req->adapter; 1766 struct zfcp_adapter *adapter = req->adapter;
1764 struct zfcp_unit *unit = req->data; 1767 struct scsi_device *sdev = req->data;
1768 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
1765 struct fsf_qtcb_header *header = &req->qtcb->header; 1769 struct fsf_qtcb_header *header = &req->qtcb->header;
1766 struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support; 1770 struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
1767 struct fsf_queue_designator *queue_designator = 1771 struct fsf_queue_designator *queue_designator =
@@ -1773,24 +1777,24 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1773 1777
1774 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | 1778 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
1775 ZFCP_STATUS_COMMON_ACCESS_BOXED | 1779 ZFCP_STATUS_COMMON_ACCESS_BOXED |
1776 ZFCP_STATUS_UNIT_SHARED | 1780 ZFCP_STATUS_LUN_SHARED |
1777 ZFCP_STATUS_UNIT_READONLY, 1781 ZFCP_STATUS_LUN_READONLY,
1778 &unit->status); 1782 &zfcp_sdev->status);
1779 1783
1780 switch (header->fsf_status) { 1784 switch (header->fsf_status) {
1781 1785
1782 case FSF_PORT_HANDLE_NOT_VALID: 1786 case FSF_PORT_HANDLE_NOT_VALID:
1783 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req); 1787 zfcp_erp_adapter_reopen(adapter, 0, "fsouh_1", req);
1784 /* fall through */ 1788 /* fall through */
1785 case FSF_LUN_ALREADY_OPEN: 1789 case FSF_LUN_ALREADY_OPEN:
1786 break; 1790 break;
1787 case FSF_ACCESS_DENIED: 1791 case FSF_ACCESS_DENIED:
1788 zfcp_fsf_access_denied_unit(req, unit); 1792 zfcp_fsf_access_denied_lun(req, sdev);
1789 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); 1793 atomic_clear_mask(ZFCP_STATUS_LUN_SHARED, &zfcp_sdev->status);
1790 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); 1794 atomic_clear_mask(ZFCP_STATUS_LUN_READONLY, &zfcp_sdev->status);
1791 break; 1795 break;
1792 case FSF_PORT_BOXED: 1796 case FSF_PORT_BOXED:
1793 zfcp_erp_port_boxed(unit->port, "fsouh_2", req); 1797 zfcp_erp_port_boxed(zfcp_sdev->port, "fsouh_2", req);
1794 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1798 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1795 break; 1799 break;
1796 case FSF_LUN_SHARING_VIOLATION: 1800 case FSF_LUN_SHARING_VIOLATION:
@@ -1798,25 +1802,25 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1798 dev_warn(&adapter->ccw_device->dev, 1802 dev_warn(&adapter->ccw_device->dev,
1799 "LUN 0x%Lx on port 0x%Lx is already in " 1803 "LUN 0x%Lx on port 0x%Lx is already in "
1800 "use by CSS%d, MIF Image ID %x\n", 1804 "use by CSS%d, MIF Image ID %x\n",
1801 (unsigned long long)unit->fcp_lun, 1805 (unsigned long long)zfcp_scsi_dev_lun(sdev),
1802 (unsigned long long)unit->port->wwpn, 1806 (unsigned long long)zfcp_sdev->port->wwpn,
1803 queue_designator->cssid, 1807 queue_designator->cssid,
1804 queue_designator->hla); 1808 queue_designator->hla);
1805 else 1809 else
1806 zfcp_act_eval_err(adapter, 1810 zfcp_act_eval_err(adapter,
1807 header->fsf_status_qual.word[2]); 1811 header->fsf_status_qual.word[2]);
1808 zfcp_erp_unit_access_denied(unit, "fsouh_3", req); 1812 zfcp_erp_lun_access_denied(sdev, "fsolh_3", req);
1809 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); 1813 atomic_clear_mask(ZFCP_STATUS_LUN_SHARED, &zfcp_sdev->status);
1810 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); 1814 atomic_clear_mask(ZFCP_STATUS_LUN_READONLY, &zfcp_sdev->status);
1811 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1815 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1812 break; 1816 break;
1813 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: 1817 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
1814 dev_warn(&adapter->ccw_device->dev, 1818 dev_warn(&adapter->ccw_device->dev,
1815 "No handle is available for LUN " 1819 "No handle is available for LUN "
1816 "0x%016Lx on port 0x%016Lx\n", 1820 "0x%016Lx on port 0x%016Lx\n",
1817 (unsigned long long)unit->fcp_lun, 1821 (unsigned long long)zfcp_scsi_dev_lun(sdev),
1818 (unsigned long long)unit->port->wwpn); 1822 (unsigned long long)zfcp_sdev->port->wwpn);
1819 zfcp_erp_unit_failed(unit, "fsouh_4", req); 1823 zfcp_erp_lun_failed(sdev, "fsolh_4", req);
1820 /* fall through */ 1824 /* fall through */
1821 case FSF_INVALID_COMMAND_OPTION: 1825 case FSF_INVALID_COMMAND_OPTION:
1822 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1826 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -1824,7 +1828,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1824 case FSF_ADAPTER_STATUS_AVAILABLE: 1828 case FSF_ADAPTER_STATUS_AVAILABLE:
1825 switch (header->fsf_status_qual.word[0]) { 1829 switch (header->fsf_status_qual.word[0]) {
1826 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: 1830 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1827 zfcp_fc_test_link(unit->port); 1831 zfcp_fc_test_link(zfcp_sdev->port);
1828 /* fall through */ 1832 /* fall through */
1829 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: 1833 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1830 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1834 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -1833,8 +1837,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1833 break; 1837 break;
1834 1838
1835 case FSF_GOOD: 1839 case FSF_GOOD:
1836 unit->handle = header->lun_handle; 1840 zfcp_sdev->lun_handle = header->lun_handle;
1837 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); 1841 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status);
1838 1842
1839 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) && 1843 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
1840 (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) && 1844 (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
@@ -1845,39 +1849,39 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1845 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER); 1849 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER);
1846 1850
1847 if (!exclusive) 1851 if (!exclusive)
1848 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, 1852 atomic_set_mask(ZFCP_STATUS_LUN_SHARED,
1849 &unit->status); 1853 &zfcp_sdev->status);
1850 1854
1851 if (!readwrite) { 1855 if (!readwrite) {
1852 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY, 1856 atomic_set_mask(ZFCP_STATUS_LUN_READONLY,
1853 &unit->status); 1857 &zfcp_sdev->status);
1854 dev_info(&adapter->ccw_device->dev, 1858 dev_info(&adapter->ccw_device->dev,
1855 "SCSI device at LUN 0x%016Lx on port " 1859 "SCSI device at LUN 0x%016Lx on port "
1856 "0x%016Lx opened read-only\n", 1860 "0x%016Lx opened read-only\n",
1857 (unsigned long long)unit->fcp_lun, 1861 (unsigned long long)zfcp_scsi_dev_lun(sdev),
1858 (unsigned long long)unit->port->wwpn); 1862 (unsigned long long)zfcp_sdev->port->wwpn);
1859 } 1863 }
1860 1864
1861 if (exclusive && !readwrite) { 1865 if (exclusive && !readwrite) {
1862 dev_err(&adapter->ccw_device->dev, 1866 dev_err(&adapter->ccw_device->dev,
1863 "Exclusive read-only access not " 1867 "Exclusive read-only access not "
1864 "supported (unit 0x%016Lx, " 1868 "supported (LUN 0x%016Lx, "
1865 "port 0x%016Lx)\n", 1869 "port 0x%016Lx)\n",
1866 (unsigned long long)unit->fcp_lun, 1870 (unsigned long long)zfcp_scsi_dev_lun(sdev),
1867 (unsigned long long)unit->port->wwpn); 1871 (unsigned long long)zfcp_sdev->port->wwpn);
1868 zfcp_erp_unit_failed(unit, "fsouh_5", req); 1872 zfcp_erp_lun_failed(sdev, "fsolh_5", req);
1869 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1873 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1870 zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req); 1874 zfcp_erp_lun_shutdown(sdev, 0, "fsolh_6", req);
1871 } else if (!exclusive && readwrite) { 1875 } else if (!exclusive && readwrite) {
1872 dev_err(&adapter->ccw_device->dev, 1876 dev_err(&adapter->ccw_device->dev,
1873 "Shared read-write access not " 1877 "Shared read-write access not "
1874 "supported (unit 0x%016Lx, port " 1878 "supported (LUN 0x%016Lx, port "
1875 "0x%016Lx)\n", 1879 "0x%016Lx)\n",
1876 (unsigned long long)unit->fcp_lun, 1880 (unsigned long long)zfcp_scsi_dev_lun(sdev),
1877 (unsigned long long)unit->port->wwpn); 1881 (unsigned long long)zfcp_sdev->port->wwpn);
1878 zfcp_erp_unit_failed(unit, "fsouh_7", req); 1882 zfcp_erp_lun_failed(sdev, "fsolh_7", req);
1879 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1883 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1880 zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req); 1884 zfcp_erp_lun_shutdown(sdev, 0, "fsolh_8", req);
1881 } 1885 }
1882 } 1886 }
1883 break; 1887 break;
@@ -1885,11 +1889,11 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1885} 1889}
1886 1890
1887/** 1891/**
1888 * zfcp_fsf_open_unit - open unit 1892 * zfcp_fsf_open_lun - open LUN
1889 * @erp_action: pointer to struct zfcp_erp_action 1893 * @erp_action: pointer to struct zfcp_erp_action
1890 * Returns: 0 on success, error otherwise 1894 * Returns: 0 on success, error otherwise
1891 */ 1895 */
1892int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) 1896int zfcp_fsf_open_lun(struct zfcp_erp_action *erp_action)
1893{ 1897{
1894 struct zfcp_adapter *adapter = erp_action->adapter; 1898 struct zfcp_adapter *adapter = erp_action->adapter;
1895 struct zfcp_qdio *qdio = adapter->qdio; 1899 struct zfcp_qdio *qdio = adapter->qdio;
@@ -1913,9 +1917,9 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1913 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); 1917 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1914 1918
1915 req->qtcb->header.port_handle = erp_action->port->handle; 1919 req->qtcb->header.port_handle = erp_action->port->handle;
1916 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun; 1920 req->qtcb->bottom.support.fcp_lun = zfcp_scsi_dev_lun(erp_action->sdev);
1917 req->handler = zfcp_fsf_open_unit_handler; 1921 req->handler = zfcp_fsf_open_lun_handler;
1918 req->data = erp_action->unit; 1922 req->data = erp_action->sdev;
1919 req->erp_action = erp_action; 1923 req->erp_action = erp_action;
1920 erp_action->fsf_req_id = req->req_id; 1924 erp_action->fsf_req_id = req->req_id;
1921 1925
@@ -1933,30 +1937,32 @@ out:
1933 return retval; 1937 return retval;
1934} 1938}
1935 1939
1936static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req) 1940static void zfcp_fsf_close_lun_handler(struct zfcp_fsf_req *req)
1937{ 1941{
1938 struct zfcp_unit *unit = req->data; 1942 struct scsi_device *sdev = req->data;
1943 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
1939 1944
1940 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1945 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1941 return; 1946 return;
1942 1947
1943 switch (req->qtcb->header.fsf_status) { 1948 switch (req->qtcb->header.fsf_status) {
1944 case FSF_PORT_HANDLE_NOT_VALID: 1949 case FSF_PORT_HANDLE_NOT_VALID:
1945 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req); 1950 zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fscuh_1",
1951 req);
1946 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1952 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1947 break; 1953 break;
1948 case FSF_LUN_HANDLE_NOT_VALID: 1954 case FSF_LUN_HANDLE_NOT_VALID:
1949 zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req); 1955 zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fscuh_2", req);
1950 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1956 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1951 break; 1957 break;
1952 case FSF_PORT_BOXED: 1958 case FSF_PORT_BOXED:
1953 zfcp_erp_port_boxed(unit->port, "fscuh_3", req); 1959 zfcp_erp_port_boxed(zfcp_sdev->port, "fscuh_3", req);
1954 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1960 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1955 break; 1961 break;
1956 case FSF_ADAPTER_STATUS_AVAILABLE: 1962 case FSF_ADAPTER_STATUS_AVAILABLE:
1957 switch (req->qtcb->header.fsf_status_qual.word[0]) { 1963 switch (req->qtcb->header.fsf_status_qual.word[0]) {
1958 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: 1964 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1959 zfcp_fc_test_link(unit->port); 1965 zfcp_fc_test_link(zfcp_sdev->port);
1960 /* fall through */ 1966 /* fall through */
1961 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: 1967 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1962 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1968 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -1964,19 +1970,20 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
1964 } 1970 }
1965 break; 1971 break;
1966 case FSF_GOOD: 1972 case FSF_GOOD:
1967 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); 1973 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status);
1968 break; 1974 break;
1969 } 1975 }
1970} 1976}
1971 1977
1972/** 1978/**
1973 * zfcp_fsf_close_unit - close zfcp unit 1979 * zfcp_fsf_close_LUN - close LUN
1974 * @erp_action: pointer to struct zfcp_unit 1980 * @erp_action: pointer to erp_action triggering the "close LUN"
1975 * Returns: 0 on success, error otherwise 1981 * Returns: 0 on success, error otherwise
1976 */ 1982 */
1977int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) 1983int zfcp_fsf_close_lun(struct zfcp_erp_action *erp_action)
1978{ 1984{
1979 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1985 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1986 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(erp_action->sdev);
1980 struct zfcp_fsf_req *req; 1987 struct zfcp_fsf_req *req;
1981 int retval = -EIO; 1988 int retval = -EIO;
1982 1989
@@ -1997,9 +2004,9 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
1997 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); 2004 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1998 2005
1999 req->qtcb->header.port_handle = erp_action->port->handle; 2006 req->qtcb->header.port_handle = erp_action->port->handle;
2000 req->qtcb->header.lun_handle = erp_action->unit->handle; 2007 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2001 req->handler = zfcp_fsf_close_unit_handler; 2008 req->handler = zfcp_fsf_close_lun_handler;
2002 req->data = erp_action->unit; 2009 req->data = erp_action->sdev;
2003 req->erp_action = erp_action; 2010 req->erp_action = erp_action;
2004 erp_action->fsf_req_id = req->req_id; 2011 erp_action->fsf_req_id = req->req_id;
2005 2012
@@ -2025,7 +2032,7 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2025{ 2032{
2026 struct fsf_qual_latency_info *lat_in; 2033 struct fsf_qual_latency_info *lat_in;
2027 struct latency_cont *lat = NULL; 2034 struct latency_cont *lat = NULL;
2028 struct zfcp_unit *unit = req->unit; 2035 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scsi->device);
2029 struct zfcp_blk_drv_data blktrc; 2036 struct zfcp_blk_drv_data blktrc;
2030 int ticks = req->adapter->timer_ticks; 2037 int ticks = req->adapter->timer_ticks;
2031 2038
@@ -2048,24 +2055,24 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2048 case FSF_DATADIR_DIF_READ_STRIP: 2055 case FSF_DATADIR_DIF_READ_STRIP:
2049 case FSF_DATADIR_DIF_READ_CONVERT: 2056 case FSF_DATADIR_DIF_READ_CONVERT:
2050 case FSF_DATADIR_READ: 2057 case FSF_DATADIR_READ:
2051 lat = &unit->latencies.read; 2058 lat = &zfcp_sdev->latencies.read;
2052 break; 2059 break;
2053 case FSF_DATADIR_DIF_WRITE_INSERT: 2060 case FSF_DATADIR_DIF_WRITE_INSERT:
2054 case FSF_DATADIR_DIF_WRITE_CONVERT: 2061 case FSF_DATADIR_DIF_WRITE_CONVERT:
2055 case FSF_DATADIR_WRITE: 2062 case FSF_DATADIR_WRITE:
2056 lat = &unit->latencies.write; 2063 lat = &zfcp_sdev->latencies.write;
2057 break; 2064 break;
2058 case FSF_DATADIR_CMND: 2065 case FSF_DATADIR_CMND:
2059 lat = &unit->latencies.cmd; 2066 lat = &zfcp_sdev->latencies.cmd;
2060 break; 2067 break;
2061 } 2068 }
2062 2069
2063 if (lat) { 2070 if (lat) {
2064 spin_lock(&unit->latencies.lock); 2071 spin_lock(&zfcp_sdev->latencies.lock);
2065 zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat); 2072 zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat);
2066 zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat); 2073 zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat);
2067 lat->counter++; 2074 lat->counter++;
2068 spin_unlock(&unit->latencies.lock); 2075 spin_unlock(&zfcp_sdev->latencies.lock);
2069 } 2076 }
2070 } 2077 }
2071 2078
@@ -2141,68 +2148,66 @@ static void zfcp_fsf_send_fcp_ctm_handler(struct zfcp_fsf_req *req)
2141 2148
2142static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) 2149static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2143{ 2150{
2144 struct zfcp_unit *unit; 2151 struct scsi_cmnd *scmnd = req->data;
2152 struct scsi_device *sdev = scmnd->device;
2153 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2145 struct fsf_qtcb_header *header = &req->qtcb->header; 2154 struct fsf_qtcb_header *header = &req->qtcb->header;
2146 2155
2147 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
2148 unit = req->data;
2149 else
2150 unit = req->unit;
2151
2152 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) 2156 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
2153 goto skip_fsfstatus; 2157 goto skip_fsfstatus;
2154 2158
2155 switch (header->fsf_status) { 2159 switch (header->fsf_status) {
2156 case FSF_HANDLE_MISMATCH: 2160 case FSF_HANDLE_MISMATCH:
2157 case FSF_PORT_HANDLE_NOT_VALID: 2161 case FSF_PORT_HANDLE_NOT_VALID:
2158 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req); 2162 zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fssfch1",
2163 req);
2159 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2164 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2160 break; 2165 break;
2161 case FSF_FCPLUN_NOT_VALID: 2166 case FSF_FCPLUN_NOT_VALID:
2162 case FSF_LUN_HANDLE_NOT_VALID: 2167 case FSF_LUN_HANDLE_NOT_VALID:
2163 zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req); 2168 zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fssfch2", req);
2164 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2169 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2165 break; 2170 break;
2166 case FSF_SERVICE_CLASS_NOT_SUPPORTED: 2171 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
2167 zfcp_fsf_class_not_supp(req); 2172 zfcp_fsf_class_not_supp(req);
2168 break; 2173 break;
2169 case FSF_ACCESS_DENIED: 2174 case FSF_ACCESS_DENIED:
2170 zfcp_fsf_access_denied_unit(req, unit); 2175 zfcp_fsf_access_denied_lun(req, sdev);
2171 break; 2176 break;
2172 case FSF_DIRECTION_INDICATOR_NOT_VALID: 2177 case FSF_DIRECTION_INDICATOR_NOT_VALID:
2173 dev_err(&req->adapter->ccw_device->dev, 2178 dev_err(&req->adapter->ccw_device->dev,
2174 "Incorrect direction %d, unit 0x%016Lx on port " 2179 "Incorrect direction %d, LUN 0x%016Lx on port "
2175 "0x%016Lx closed\n", 2180 "0x%016Lx closed\n",
2176 req->qtcb->bottom.io.data_direction, 2181 req->qtcb->bottom.io.data_direction,
2177 (unsigned long long)unit->fcp_lun, 2182 (unsigned long long)zfcp_scsi_dev_lun(sdev),
2178 (unsigned long long)unit->port->wwpn); 2183 (unsigned long long)zfcp_sdev->port->wwpn);
2179 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3", 2184 zfcp_erp_adapter_shutdown(zfcp_sdev->port->adapter, 0,
2180 req); 2185 "fssfch3", req);
2181 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2186 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2182 break; 2187 break;
2183 case FSF_CMND_LENGTH_NOT_VALID: 2188 case FSF_CMND_LENGTH_NOT_VALID:
2184 dev_err(&req->adapter->ccw_device->dev, 2189 dev_err(&req->adapter->ccw_device->dev,
2185 "Incorrect CDB length %d, unit 0x%016Lx on " 2190 "Incorrect CDB length %d, LUN 0x%016Lx on "
2186 "port 0x%016Lx closed\n", 2191 "port 0x%016Lx closed\n",
2187 req->qtcb->bottom.io.fcp_cmnd_length, 2192 req->qtcb->bottom.io.fcp_cmnd_length,
2188 (unsigned long long)unit->fcp_lun, 2193 (unsigned long long)zfcp_scsi_dev_lun(sdev),
2189 (unsigned long long)unit->port->wwpn); 2194 (unsigned long long)zfcp_sdev->port->wwpn);
2190 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4", 2195 zfcp_erp_adapter_shutdown(zfcp_sdev->port->adapter, 0,
2191 req); 2196 "fssfch4", req);
2192 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2197 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2193 break; 2198 break;
2194 case FSF_PORT_BOXED: 2199 case FSF_PORT_BOXED:
2195 zfcp_erp_port_boxed(unit->port, "fssfch5", req); 2200 zfcp_erp_port_boxed(zfcp_sdev->port, "fssfch5", req);
2196 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2201 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2197 break; 2202 break;
2198 case FSF_LUN_BOXED: 2203 case FSF_LUN_BOXED:
2199 zfcp_erp_unit_boxed(unit, "fssfch6", req); 2204 zfcp_erp_lun_boxed(sdev, "fssfch6", req);
2200 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2205 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2201 break; 2206 break;
2202 case FSF_ADAPTER_STATUS_AVAILABLE: 2207 case FSF_ADAPTER_STATUS_AVAILABLE:
2203 if (header->fsf_status_qual.word[0] == 2208 if (header->fsf_status_qual.word[0] ==
2204 FSF_SQ_INVOKE_LINK_TEST_PROCEDURE) 2209 FSF_SQ_INVOKE_LINK_TEST_PROCEDURE)
2205 zfcp_fc_test_link(unit->port); 2210 zfcp_fc_test_link(zfcp_sdev->port);
2206 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2211 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2207 break; 2212 break;
2208 } 2213 }
@@ -2211,8 +2216,6 @@ skip_fsfstatus:
2211 zfcp_fsf_send_fcp_ctm_handler(req); 2216 zfcp_fsf_send_fcp_ctm_handler(req);
2212 else { 2217 else {
2213 zfcp_fsf_send_fcp_command_task_handler(req); 2218 zfcp_fsf_send_fcp_command_task_handler(req);
2214 req->unit = NULL;
2215 put_device(&unit->dev);
2216 } 2219 }
2217} 2220}
2218 2221
@@ -2255,22 +2258,22 @@ static int zfcp_fsf_set_data_dir(struct scsi_cmnd *scsi_cmnd, u32 *data_dir)
2255} 2258}
2256 2259
2257/** 2260/**
2258 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) 2261 * zfcp_fsf_fcp_cmnd - initiate an FCP command (for a SCSI command)
2259 * @unit: unit where command is sent to
2260 * @scsi_cmnd: scsi command to be sent 2262 * @scsi_cmnd: scsi command to be sent
2261 */ 2263 */
2262int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, 2264int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd)
2263 struct scsi_cmnd *scsi_cmnd)
2264{ 2265{
2265 struct zfcp_fsf_req *req; 2266 struct zfcp_fsf_req *req;
2266 struct fcp_cmnd *fcp_cmnd; 2267 struct fcp_cmnd *fcp_cmnd;
2267 unsigned int sbtype = SBAL_FLAGS0_TYPE_READ; 2268 unsigned int sbtype = SBAL_FLAGS0_TYPE_READ;
2268 int real_bytes, retval = -EIO, dix_bytes = 0; 2269 int real_bytes, retval = -EIO, dix_bytes = 0;
2269 struct zfcp_adapter *adapter = unit->port->adapter; 2270 struct scsi_device *sdev = scsi_cmnd->device;
2271 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
2272 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
2270 struct zfcp_qdio *qdio = adapter->qdio; 2273 struct zfcp_qdio *qdio = adapter->qdio;
2271 struct fsf_qtcb_bottom_io *io; 2274 struct fsf_qtcb_bottom_io *io;
2272 2275
2273 if (unlikely(!(atomic_read(&unit->status) & 2276 if (unlikely(!(atomic_read(&zfcp_sdev->status) &
2274 ZFCP_STATUS_COMMON_UNBLOCKED))) 2277 ZFCP_STATUS_COMMON_UNBLOCKED)))
2275 return -EBUSY; 2278 return -EBUSY;
2276 2279
@@ -2295,11 +2298,10 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2295 2298
2296 io = &req->qtcb->bottom.io; 2299 io = &req->qtcb->bottom.io;
2297 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 2300 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2298 req->unit = unit;
2299 req->data = scsi_cmnd; 2301 req->data = scsi_cmnd;
2300 req->handler = zfcp_fsf_send_fcp_command_handler; 2302 req->handler = zfcp_fsf_send_fcp_command_handler;
2301 req->qtcb->header.lun_handle = unit->handle; 2303 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2302 req->qtcb->header.port_handle = unit->port->handle; 2304 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
2303 io->service_class = FSF_CLASS_3; 2305 io->service_class = FSF_CLASS_3;
2304 io->fcp_cmnd_length = FCP_CMND_LEN; 2306 io->fcp_cmnd_length = FCP_CMND_LEN;
2305 2307
@@ -2310,8 +2312,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2310 2312
2311 zfcp_fsf_set_data_dir(scsi_cmnd, &io->data_direction); 2313 zfcp_fsf_set_data_dir(scsi_cmnd, &io->data_direction);
2312 2314
2313 get_device(&unit->dev);
2314
2315 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2315 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2316 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); 2316 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
2317 2317
@@ -2338,7 +2338,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2338 goto out; 2338 goto out;
2339 2339
2340failed_scsi_cmnd: 2340failed_scsi_cmnd:
2341 put_device(&unit->dev);
2342 zfcp_fsf_req_free(req); 2341 zfcp_fsf_req_free(req);
2343 scsi_cmnd->host_scribble = NULL; 2342 scsi_cmnd->host_scribble = NULL;
2344out: 2343out:
@@ -2347,18 +2346,20 @@ out:
2347} 2346}
2348 2347
2349/** 2348/**
2350 * zfcp_fsf_send_fcp_ctm - send SCSI task management command 2349 * zfcp_fsf_fcp_task_mgmt - send SCSI task management command
2351 * @unit: pointer to struct zfcp_unit 2350 * @scmnd: SCSI command to send the task management command for
2352 * @tm_flags: unsigned byte for task management flags 2351 * @tm_flags: unsigned byte for task management flags
2353 * Returns: on success pointer to struct fsf_req, NULL otherwise 2352 * Returns: on success pointer to struct fsf_req, NULL otherwise
2354 */ 2353 */
2355struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) 2354struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_cmnd *scmnd,
2355 u8 tm_flags)
2356{ 2356{
2357 struct zfcp_fsf_req *req = NULL; 2357 struct zfcp_fsf_req *req = NULL;
2358 struct fcp_cmnd *fcp_cmnd; 2358 struct fcp_cmnd *fcp_cmnd;
2359 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 2359 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);
2360 struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio;
2360 2361
2361 if (unlikely(!(atomic_read(&unit->status) & 2362 if (unlikely(!(atomic_read(&zfcp_sdev->status) &
2362 ZFCP_STATUS_COMMON_UNBLOCKED))) 2363 ZFCP_STATUS_COMMON_UNBLOCKED)))
2363 return NULL; 2364 return NULL;
2364 2365
@@ -2376,10 +2377,10 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2376 } 2377 }
2377 2378
2378 req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; 2379 req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
2379 req->data = unit; 2380 req->data = scmnd;
2380 req->handler = zfcp_fsf_send_fcp_command_handler; 2381 req->handler = zfcp_fsf_send_fcp_command_handler;
2381 req->qtcb->header.lun_handle = unit->handle; 2382 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2382 req->qtcb->header.port_handle = unit->port->handle; 2383 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
2383 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; 2384 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
2384 req->qtcb->bottom.io.service_class = FSF_CLASS_3; 2385 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2385 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; 2386 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
@@ -2387,7 +2388,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2387 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); 2388 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2388 2389
2389 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2390 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2390 zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags); 2391 zfcp_fc_fcp_tm(fcp_cmnd, scmnd->device, tm_flags);
2391 2392
2392 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); 2393 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
2393 if (!zfcp_fsf_req_send(req)) 2394 if (!zfcp_fsf_req_send(req))