aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c213
1 files changed, 94 insertions, 119 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 01a1a4d36f21..64b1dd827366 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -38,14 +38,6 @@
38#include <scsi/scsi_transport_iscsi.h> 38#include <scsi/scsi_transport_iscsi.h>
39#include <scsi/libiscsi.h> 39#include <scsi/libiscsi.h>
40 40
41struct iscsi_session *
42class_to_transport_session(struct iscsi_cls_session *cls_session)
43{
44 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
45 return iscsi_hostdata(shost->hostdata);
46}
47EXPORT_SYMBOL_GPL(class_to_transport_session);
48
49/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */ 41/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
50#define SNA32_CHECK 2147483648UL 42#define SNA32_CHECK 2147483648UL
51 43
@@ -1096,6 +1088,7 @@ enum {
1096 1088
1097int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 1089int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
1098{ 1090{
1091 struct iscsi_cls_session *cls_session;
1099 struct Scsi_Host *host; 1092 struct Scsi_Host *host;
1100 int reason = 0; 1093 int reason = 0;
1101 struct iscsi_session *session; 1094 struct iscsi_session *session;
@@ -1109,10 +1102,11 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
1109 host = sc->device->host; 1102 host = sc->device->host;
1110 spin_unlock(host->host_lock); 1103 spin_unlock(host->host_lock);
1111 1104
1112 session = iscsi_hostdata(host->hostdata); 1105 cls_session = starget_to_session(scsi_target(sc->device));
1106 session = cls_session->dd_data;
1113 spin_lock(&session->lock); 1107 spin_lock(&session->lock);
1114 1108
1115 reason = iscsi_session_chkready(session_to_cls(session)); 1109 reason = iscsi_session_chkready(cls_session);
1116 if (reason) { 1110 if (reason) {
1117 sc->result = reason; 1111 sc->result = reason;
1118 goto fault; 1112 goto fault;
@@ -1222,7 +1216,7 @@ EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
1222 1216
1223void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session) 1217void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
1224{ 1218{
1225 struct iscsi_session *session = class_to_transport_session(cls_session); 1219 struct iscsi_session *session = cls_session->dd_data;
1226 1220
1227 spin_lock_bh(&session->lock); 1221 spin_lock_bh(&session->lock);
1228 if (session->state != ISCSI_STATE_LOGGED_IN) { 1222 if (session->state != ISCSI_STATE_LOGGED_IN) {
@@ -1236,9 +1230,13 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
1236 1230
1237int iscsi_eh_host_reset(struct scsi_cmnd *sc) 1231int iscsi_eh_host_reset(struct scsi_cmnd *sc)
1238{ 1232{
1239 struct Scsi_Host *host = sc->device->host; 1233 struct iscsi_cls_session *cls_session;
1240 struct iscsi_session *session = iscsi_hostdata(host->hostdata); 1234 struct iscsi_session *session;
1241 struct iscsi_conn *conn = session->leadconn; 1235 struct iscsi_conn *conn;
1236
1237 cls_session = starget_to_session(scsi_target(sc->device));
1238 session = cls_session->dd_data;
1239 conn = session->leadconn;
1242 1240
1243 mutex_lock(&session->eh_mutex); 1241 mutex_lock(&session->eh_mutex);
1244 spin_lock_bh(&session->lock); 1242 spin_lock_bh(&session->lock);
@@ -1405,7 +1403,7 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
1405 enum scsi_eh_timer_return rc = EH_NOT_HANDLED; 1403 enum scsi_eh_timer_return rc = EH_NOT_HANDLED;
1406 1404
1407 cls_session = starget_to_session(scsi_target(scmd->device)); 1405 cls_session = starget_to_session(scsi_target(scmd->device));
1408 session = class_to_transport_session(cls_session); 1406 session = cls_session->dd_data;
1409 1407
1410 debug_scsi("scsi cmd %p timedout\n", scmd); 1408 debug_scsi("scsi cmd %p timedout\n", scmd);
1411 1409
@@ -1507,13 +1505,16 @@ static void iscsi_prep_abort_task_pdu(struct iscsi_cmd_task *ctask,
1507 1505
1508int iscsi_eh_abort(struct scsi_cmnd *sc) 1506int iscsi_eh_abort(struct scsi_cmnd *sc)
1509{ 1507{
1510 struct Scsi_Host *host = sc->device->host; 1508 struct iscsi_cls_session *cls_session;
1511 struct iscsi_session *session = iscsi_hostdata(host->hostdata); 1509 struct iscsi_session *session;
1512 struct iscsi_conn *conn; 1510 struct iscsi_conn *conn;
1513 struct iscsi_cmd_task *ctask; 1511 struct iscsi_cmd_task *ctask;
1514 struct iscsi_tm *hdr; 1512 struct iscsi_tm *hdr;
1515 int rc, age; 1513 int rc, age;
1516 1514
1515 cls_session = starget_to_session(scsi_target(sc->device));
1516 session = cls_session->dd_data;
1517
1517 mutex_lock(&session->eh_mutex); 1518 mutex_lock(&session->eh_mutex);
1518 spin_lock_bh(&session->lock); 1519 spin_lock_bh(&session->lock);
1519 /* 1520 /*
@@ -1630,12 +1631,15 @@ static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
1630 1631
1631int iscsi_eh_device_reset(struct scsi_cmnd *sc) 1632int iscsi_eh_device_reset(struct scsi_cmnd *sc)
1632{ 1633{
1633 struct Scsi_Host *host = sc->device->host; 1634 struct iscsi_cls_session *cls_session;
1634 struct iscsi_session *session = iscsi_hostdata(host->hostdata); 1635 struct iscsi_session *session;
1635 struct iscsi_conn *conn; 1636 struct iscsi_conn *conn;
1636 struct iscsi_tm *hdr; 1637 struct iscsi_tm *hdr;
1637 int rc = FAILED; 1638 int rc = FAILED;
1638 1639
1640 cls_session = starget_to_session(scsi_target(sc->device));
1641 session = cls_session->dd_data;
1642
1639 debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun); 1643 debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
1640 1644
1641 mutex_lock(&session->eh_mutex); 1645 mutex_lock(&session->eh_mutex);
@@ -1760,55 +1764,53 @@ void iscsi_pool_free(struct iscsi_pool *q)
1760} 1764}
1761EXPORT_SYMBOL_GPL(iscsi_pool_free); 1765EXPORT_SYMBOL_GPL(iscsi_pool_free);
1762 1766
1763/* 1767void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth)
1764 * iSCSI Session's hostdata organization: 1768{
1765 * 1769 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
1766 * *------------------* <== hostdata_session(host->hostdata) 1770 if (qdepth != 0)
1767 * | ptr to class sess| 1771 printk(KERN_ERR "iscsi: invalid queue depth of %d. "
1768 * |------------------| <== iscsi_hostdata(host->hostdata) 1772 "Queue depth must be between 1 and %d.\n",
1769 * | iscsi_session | 1773 qdepth, ISCSI_MAX_CMD_PER_LUN);
1770 * *------------------* 1774 qdepth = ISCSI_DEF_CMD_PER_LUN;
1771 */ 1775 }
1776
1777 shost->transportt->create_work_queue = 1;
1778 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
1779 shost->cmd_per_lun = qdepth;
1780}
1781EXPORT_SYMBOL_GPL(iscsi_host_setup);
1772 1782
1773#define hostdata_privsize(_sz) (sizeof(unsigned long) + _sz + \ 1783void iscsi_host_teardown(struct Scsi_Host *shost)
1774 _sz % sizeof(unsigned long)) 1784{
1785 struct iscsi_host *ihost = shost_priv(shost);
1775 1786
1776#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata)) 1787 kfree(ihost->netdev);
1788 kfree(ihost->hwaddress);
1789 kfree(ihost->initiatorname);
1790}
1791EXPORT_SYMBOL_GPL(iscsi_host_teardown);
1777 1792
1778/** 1793/**
1779 * iscsi_session_setup - create iscsi cls session and host and session 1794 * iscsi_session_setup - create iscsi cls session and host and session
1780 * @scsit: scsi transport template
1781 * @iscsit: iscsi transport template 1795 * @iscsit: iscsi transport template
1782 * @cmds_max: scsi host can queue 1796 * @shost: scsi host
1783 * @qdepth: scsi host cmds per lun 1797 * @cmds_max: session can queue
1784 * @cmd_task_size: LLD ctask private data size 1798 * @cmd_task_size: LLD ctask private data size
1785 * @mgmt_task_size: LLD mtask private data size 1799 * @mgmt_task_size: LLD mtask private data size
1786 * @initial_cmdsn: initial CmdSN 1800 * @initial_cmdsn: initial CmdSN
1787 * @hostno: host no allocated
1788 * 1801 *
1789 * This can be used by software iscsi_transports that allocate 1802 * This can be used by software iscsi_transports that allocate
1790 * a session per scsi host. 1803 * a session per scsi host.
1791 **/ 1804 */
1792struct iscsi_cls_session * 1805struct iscsi_cls_session *
1793iscsi_session_setup(struct iscsi_transport *iscsit, 1806iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
1794 struct scsi_transport_template *scsit, 1807 uint16_t cmds_max, int cmd_task_size, int mgmt_task_size,
1795 uint16_t cmds_max, uint16_t qdepth, 1808 uint32_t initial_cmdsn)
1796 int cmd_task_size, int mgmt_task_size,
1797 uint32_t initial_cmdsn, uint32_t *hostno)
1798{ 1809{
1799 struct Scsi_Host *shost;
1800 struct iscsi_session *session; 1810 struct iscsi_session *session;
1801 struct iscsi_cls_session *cls_session; 1811 struct iscsi_cls_session *cls_session;
1802 int cmd_i; 1812 int cmd_i;
1803 1813
1804 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
1805 if (qdepth != 0)
1806 printk(KERN_ERR "iscsi: invalid queue depth of %d. "
1807 "Queue depth must be between 1 and %d.\n",
1808 qdepth, ISCSI_MAX_CMD_PER_LUN);
1809 qdepth = ISCSI_DEF_CMD_PER_LUN;
1810 }
1811
1812 if (!is_power_of_2(cmds_max) || cmds_max >= ISCSI_MGMT_ITT_OFFSET || 1814 if (!is_power_of_2(cmds_max) || cmds_max >= ISCSI_MGMT_ITT_OFFSET ||
1813 cmds_max < 2) { 1815 cmds_max < 2) {
1814 if (cmds_max != 0) 1816 if (cmds_max != 0)
@@ -1819,25 +1821,11 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1819 cmds_max = ISCSI_DEF_XMIT_CMDS_MAX; 1821 cmds_max = ISCSI_DEF_XMIT_CMDS_MAX;
1820 } 1822 }
1821 1823
1822 shost = scsi_host_alloc(iscsit->host_template, 1824 cls_session = iscsi_alloc_session(shost, iscsit);
1823 hostdata_privsize(sizeof(*session))); 1825 if (!cls_session)
1824 if (!shost)
1825 return NULL; 1826 return NULL;
1826 1827 session = cls_session->dd_data;
1827 /* the iscsi layer takes one task for reserve */ 1828 session->cls_session = cls_session;
1828 shost->can_queue = cmds_max - 1;
1829 shost->cmd_per_lun = qdepth;
1830 shost->max_id = 1;
1831 shost->max_channel = 0;
1832 shost->max_lun = iscsit->max_lun;
1833 shost->max_cmd_len = 16;
1834 shost->transportt = scsit;
1835 shost->transportt->create_work_queue = 1;
1836 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
1837 *hostno = shost->host_no;
1838
1839 session = iscsi_hostdata(shost->hostdata);
1840 memset(session, 0, sizeof(struct iscsi_session));
1841 session->host = shost; 1829 session->host = shost;
1842 session->state = ISCSI_STATE_FREE; 1830 session->state = ISCSI_STATE_FREE;
1843 session->fast_abort = 1; 1831 session->fast_abort = 1;
@@ -1851,6 +1839,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1851 session->max_r2t = 1; 1839 session->max_r2t = 1;
1852 session->tt = iscsit; 1840 session->tt = iscsit;
1853 mutex_init(&session->eh_mutex); 1841 mutex_init(&session->eh_mutex);
1842 spin_lock_init(&session->lock);
1854 1843
1855 /* initialize SCSI PDU commands pool */ 1844 /* initialize SCSI PDU commands pool */
1856 if (iscsi_pool_init(&session->cmdpool, session->cmds_max, 1845 if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
@@ -1868,8 +1857,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1868 INIT_LIST_HEAD(&ctask->running); 1857 INIT_LIST_HEAD(&ctask->running);
1869 } 1858 }
1870 1859
1871 spin_lock_init(&session->lock);
1872
1873 /* initialize immediate command pool */ 1860 /* initialize immediate command pool */
1874 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max, 1861 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max,
1875 (void***)&session->mgmt_cmds, 1862 (void***)&session->mgmt_cmds,
@@ -1887,49 +1874,37 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1887 INIT_LIST_HEAD(&mtask->running); 1874 INIT_LIST_HEAD(&mtask->running);
1888 } 1875 }
1889 1876
1890 if (scsi_add_host(shost, NULL))
1891 goto add_host_fail;
1892
1893 if (!try_module_get(iscsit->owner)) 1877 if (!try_module_get(iscsit->owner))
1894 goto cls_session_fail; 1878 goto module_get_fail;
1895
1896 cls_session = iscsi_create_session(shost, iscsit, 0);
1897 if (!cls_session)
1898 goto module_put;
1899 *(unsigned long*)shost->hostdata = (unsigned long)cls_session;
1900 1879
1880 if (iscsi_add_session(cls_session, 0))
1881 goto cls_session_fail;
1901 return cls_session; 1882 return cls_session;
1902 1883
1903module_put:
1904 module_put(iscsit->owner);
1905cls_session_fail: 1884cls_session_fail:
1906 scsi_remove_host(shost); 1885 module_put(iscsit->owner);
1907add_host_fail: 1886module_get_fail:
1908 iscsi_pool_free(&session->mgmtpool); 1887 iscsi_pool_free(&session->mgmtpool);
1909mgmtpool_alloc_fail: 1888mgmtpool_alloc_fail:
1910 iscsi_pool_free(&session->cmdpool); 1889 iscsi_pool_free(&session->cmdpool);
1911cmdpool_alloc_fail: 1890cmdpool_alloc_fail:
1912 scsi_host_put(shost); 1891 iscsi_free_session(cls_session);
1913 return NULL; 1892 return NULL;
1914} 1893}
1915EXPORT_SYMBOL_GPL(iscsi_session_setup); 1894EXPORT_SYMBOL_GPL(iscsi_session_setup);
1916 1895
1917/** 1896/**
1918 * iscsi_session_teardown - destroy session, host, and cls_session 1897 * iscsi_session_teardown - destroy session, host, and cls_session
1919 * shost: scsi host 1898 * @cls_session: iscsi session
1920 * 1899 *
1921 * This can be used by software iscsi_transports that allocate 1900 * The driver must have called iscsi_remove_session before
1922 * a session per scsi host. 1901 * calling this.
1923 **/ 1902 */
1924void iscsi_session_teardown(struct iscsi_cls_session *cls_session) 1903void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
1925{ 1904{
1926 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 1905 struct iscsi_session *session = cls_session->dd_data;
1927 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
1928 struct module *owner = cls_session->transport->owner; 1906 struct module *owner = cls_session->transport->owner;
1929 1907
1930 iscsi_remove_session(cls_session);
1931 scsi_remove_host(shost);
1932
1933 iscsi_pool_free(&session->mgmtpool); 1908 iscsi_pool_free(&session->mgmtpool);
1934 iscsi_pool_free(&session->cmdpool); 1909 iscsi_pool_free(&session->cmdpool);
1935 1910
@@ -1938,12 +1913,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
1938 kfree(session->username); 1913 kfree(session->username);
1939 kfree(session->username_in); 1914 kfree(session->username_in);
1940 kfree(session->targetname); 1915 kfree(session->targetname);
1941 kfree(session->netdev);
1942 kfree(session->hwaddress);
1943 kfree(session->initiatorname);
1944 1916
1945 iscsi_free_session(cls_session); 1917 iscsi_destroy_session(cls_session);
1946 scsi_host_put(shost);
1947 module_put(owner); 1918 module_put(owner);
1948} 1919}
1949EXPORT_SYMBOL_GPL(iscsi_session_teardown); 1920EXPORT_SYMBOL_GPL(iscsi_session_teardown);
@@ -1956,7 +1927,7 @@ EXPORT_SYMBOL_GPL(iscsi_session_teardown);
1956struct iscsi_cls_conn * 1927struct iscsi_cls_conn *
1957iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) 1928iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1958{ 1929{
1959 struct iscsi_session *session = class_to_transport_session(cls_session); 1930 struct iscsi_session *session = cls_session->dd_data;
1960 struct iscsi_conn *conn; 1931 struct iscsi_conn *conn;
1961 struct iscsi_cls_conn *cls_conn; 1932 struct iscsi_cls_conn *cls_conn;
1962 char *data; 1933 char *data;
@@ -2140,7 +2111,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2140 } 2111 }
2141 spin_unlock_bh(&session->lock); 2112 spin_unlock_bh(&session->lock);
2142 2113
2143 iscsi_unblock_session(session_to_cls(session)); 2114 iscsi_unblock_session(session->cls_session);
2144 wake_up(&conn->ehwait); 2115 wake_up(&conn->ehwait);
2145 return 0; 2116 return 0;
2146} 2117}
@@ -2225,7 +2196,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
2225 if (session->state == ISCSI_STATE_IN_RECOVERY && 2196 if (session->state == ISCSI_STATE_IN_RECOVERY &&
2226 old_stop_stage != STOP_CONN_RECOVER) { 2197 old_stop_stage != STOP_CONN_RECOVER) {
2227 debug_scsi("blocking session\n"); 2198 debug_scsi("blocking session\n");
2228 iscsi_block_session(session_to_cls(session)); 2199 iscsi_block_session(session->cls_session);
2229 } 2200 }
2230 } 2201 }
2231 2202
@@ -2260,7 +2231,7 @@ EXPORT_SYMBOL_GPL(iscsi_conn_stop);
2260int iscsi_conn_bind(struct iscsi_cls_session *cls_session, 2231int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
2261 struct iscsi_cls_conn *cls_conn, int is_leading) 2232 struct iscsi_cls_conn *cls_conn, int is_leading)
2262{ 2233{
2263 struct iscsi_session *session = class_to_transport_session(cls_session); 2234 struct iscsi_session *session = cls_session->dd_data;
2264 struct iscsi_conn *conn = cls_conn->dd_data; 2235 struct iscsi_conn *conn = cls_conn->dd_data;
2265 2236
2266 spin_lock_bh(&session->lock); 2237 spin_lock_bh(&session->lock);
@@ -2410,8 +2381,7 @@ EXPORT_SYMBOL_GPL(iscsi_set_param);
2410int iscsi_session_get_param(struct iscsi_cls_session *cls_session, 2381int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
2411 enum iscsi_param param, char *buf) 2382 enum iscsi_param param, char *buf)
2412{ 2383{
2413 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 2384 struct iscsi_session *session = cls_session->dd_data;
2414 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
2415 int len; 2385 int len;
2416 2386
2417 switch(param) { 2387 switch(param) {
@@ -2525,29 +2495,34 @@ EXPORT_SYMBOL_GPL(iscsi_conn_get_param);
2525int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param, 2495int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,
2526 char *buf) 2496 char *buf)
2527{ 2497{
2528 struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 2498 struct iscsi_host *ihost = shost_priv(shost);
2529 int len; 2499 int len;
2530 2500
2531 switch (param) { 2501 switch (param) {
2532 case ISCSI_HOST_PARAM_NETDEV_NAME: 2502 case ISCSI_HOST_PARAM_NETDEV_NAME:
2533 if (!session->netdev) 2503 if (!ihost->netdev)
2534 len = sprintf(buf, "%s\n", "default"); 2504 len = sprintf(buf, "%s\n", "default");
2535 else 2505 else
2536 len = sprintf(buf, "%s\n", session->netdev); 2506 len = sprintf(buf, "%s\n", ihost->netdev);
2537 break; 2507 break;
2538 case ISCSI_HOST_PARAM_HWADDRESS: 2508 case ISCSI_HOST_PARAM_HWADDRESS:
2539 if (!session->hwaddress) 2509 if (!ihost->hwaddress)
2540 len = sprintf(buf, "%s\n", "default"); 2510 len = sprintf(buf, "%s\n", "default");
2541 else 2511 else
2542 len = sprintf(buf, "%s\n", session->hwaddress); 2512 len = sprintf(buf, "%s\n", ihost->hwaddress);
2543 break; 2513 break;
2544 case ISCSI_HOST_PARAM_INITIATOR_NAME: 2514 case ISCSI_HOST_PARAM_INITIATOR_NAME:
2545 if (!session->initiatorname) 2515 if (!ihost->initiatorname)
2546 len = sprintf(buf, "%s\n", "unknown"); 2516 len = sprintf(buf, "%s\n", "unknown");
2547 else 2517 else
2548 len = sprintf(buf, "%s\n", session->initiatorname); 2518 len = sprintf(buf, "%s\n", ihost->initiatorname);
2549 break; 2519 break;
2550 2520 case ISCSI_HOST_PARAM_IPADDRESS:
2521 if (!strlen(ihost->local_address))
2522 len = sprintf(buf, "%s\n", "unknown");
2523 else
2524 len = sprintf(buf, "%s\n",
2525 ihost->local_address);
2551 default: 2526 default:
2552 return -ENOSYS; 2527 return -ENOSYS;
2553 } 2528 }
@@ -2559,20 +2534,20 @@ EXPORT_SYMBOL_GPL(iscsi_host_get_param);
2559int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param, 2534int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param,
2560 char *buf, int buflen) 2535 char *buf, int buflen)
2561{ 2536{
2562 struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 2537 struct iscsi_host *ihost = shost_priv(shost);
2563 2538
2564 switch (param) { 2539 switch (param) {
2565 case ISCSI_HOST_PARAM_NETDEV_NAME: 2540 case ISCSI_HOST_PARAM_NETDEV_NAME:
2566 if (!session->netdev) 2541 if (!ihost->netdev)
2567 session->netdev = kstrdup(buf, GFP_KERNEL); 2542 ihost->netdev = kstrdup(buf, GFP_KERNEL);
2568 break; 2543 break;
2569 case ISCSI_HOST_PARAM_HWADDRESS: 2544 case ISCSI_HOST_PARAM_HWADDRESS:
2570 if (!session->hwaddress) 2545 if (!ihost->hwaddress)
2571 session->hwaddress = kstrdup(buf, GFP_KERNEL); 2546 ihost->hwaddress = kstrdup(buf, GFP_KERNEL);
2572 break; 2547 break;
2573 case ISCSI_HOST_PARAM_INITIATOR_NAME: 2548 case ISCSI_HOST_PARAM_INITIATOR_NAME:
2574 if (!session->initiatorname) 2549 if (!ihost->initiatorname)
2575 session->initiatorname = kstrdup(buf, GFP_KERNEL); 2550 ihost->initiatorname = kstrdup(buf, GFP_KERNEL);
2576 break; 2551 break;
2577 default: 2552 default:
2578 return -ENOSYS; 2553 return -ENOSYS;