diff options
author | Erez Zilber <erezzi.list@gmail.com> | 2009-06-15 23:11:10 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-06-21 11:52:41 -0400 |
commit | bd2199d417313a056d4d2b2bac852231e1b50a4e (patch) | |
tree | 7ff88e6be26be91e822cebf81cce261e8dc08db5 /drivers | |
parent | 32382492eb18e8e20be382a1743d0c08469d1e84 (diff) |
libiscsi: add conn and scsi eh log debug flags
Allow the user to control the debug logs in libiscsi. We will now
have a module param for connection, session & error handling.
[Mike Christie - Fixed up to compile on current code and added
missing ISCSI_DBG_EH conversions]
Signed-off-by: Erez Zilber <erezzi.list@gmail.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libiscsi.c | 109 |
1 files changed, 65 insertions, 44 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index b55b7991d5fa..716cc344c5df 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -38,15 +38,30 @@ | |||
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 | ||
41 | static int iscsi_dbg_lib; | 41 | static int iscsi_dbg_lib_conn; |
42 | module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR); | 42 | module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int, |
43 | MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " | 43 | S_IRUGO | S_IWUSR); |
44 | "Set to 1 to turn on, and zero to turn off. Default " | 44 | MODULE_PARM_DESC(debug_libiscsi_conn, |
45 | "is off."); | 45 | "Turn on debugging for connections in libiscsi module. " |
46 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
47 | |||
48 | static int iscsi_dbg_lib_session; | ||
49 | module_param_named(debug_libiscsi_session, iscsi_dbg_lib_session, int, | ||
50 | S_IRUGO | S_IWUSR); | ||
51 | MODULE_PARM_DESC(debug_libiscsi_session, | ||
52 | "Turn on debugging for sessions in libiscsi module. " | ||
53 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
54 | |||
55 | static int iscsi_dbg_lib_eh; | ||
56 | module_param_named(debug_libiscsi_eh, iscsi_dbg_lib_eh, int, | ||
57 | S_IRUGO | S_IWUSR); | ||
58 | MODULE_PARM_DESC(debug_libiscsi_eh, | ||
59 | "Turn on debugging for error handling in libiscsi module. " | ||
60 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
46 | 61 | ||
47 | #define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \ | 62 | #define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \ |
48 | do { \ | 63 | do { \ |
49 | if (iscsi_dbg_lib) \ | 64 | if (iscsi_dbg_lib_conn) \ |
50 | iscsi_conn_printk(KERN_INFO, _conn, \ | 65 | iscsi_conn_printk(KERN_INFO, _conn, \ |
51 | "%s " dbg_fmt, \ | 66 | "%s " dbg_fmt, \ |
52 | __func__, ##arg); \ | 67 | __func__, ##arg); \ |
@@ -54,7 +69,15 @@ MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " | |||
54 | 69 | ||
55 | #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \ | 70 | #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \ |
56 | do { \ | 71 | do { \ |
57 | if (iscsi_dbg_lib) \ | 72 | if (iscsi_dbg_lib_session) \ |
73 | iscsi_session_printk(KERN_INFO, _session, \ | ||
74 | "%s " dbg_fmt, \ | ||
75 | __func__, ##arg); \ | ||
76 | } while (0); | ||
77 | |||
78 | #define ISCSI_DBG_EH(_session, dbg_fmt, arg...) \ | ||
79 | do { \ | ||
80 | if (iscsi_dbg_lib_eh) \ | ||
58 | iscsi_session_printk(KERN_INFO, _session, \ | 81 | iscsi_session_printk(KERN_INFO, _session, \ |
59 | "%s " dbg_fmt, \ | 82 | "%s " dbg_fmt, \ |
60 | __func__, ##arg); \ | 83 | __func__, ##arg); \ |
@@ -1561,10 +1584,10 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) | |||
1561 | spin_lock_bh(&session->lock); | 1584 | spin_lock_bh(&session->lock); |
1562 | if (session->state == ISCSI_STATE_TERMINATE) { | 1585 | if (session->state == ISCSI_STATE_TERMINATE) { |
1563 | failed: | 1586 | failed: |
1564 | iscsi_session_printk(KERN_INFO, session, | 1587 | ISCSI_DBG_EH(session, |
1565 | "failing target reset: Could not log " | 1588 | "failing target reset: Could not log back into " |
1566 | "back into target [age %d]\n", | 1589 | "target [age %d]\n", |
1567 | session->age); | 1590 | session->age); |
1568 | spin_unlock_bh(&session->lock); | 1591 | spin_unlock_bh(&session->lock); |
1569 | mutex_unlock(&session->eh_mutex); | 1592 | mutex_unlock(&session->eh_mutex); |
1570 | return FAILED; | 1593 | return FAILED; |
@@ -1578,7 +1601,7 @@ failed: | |||
1578 | */ | 1601 | */ |
1579 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1602 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
1580 | 1603 | ||
1581 | ISCSI_DBG_SESSION(session, "wait for relogin\n"); | 1604 | ISCSI_DBG_EH(session, "wait for relogin\n"); |
1582 | wait_event_interruptible(conn->ehwait, | 1605 | wait_event_interruptible(conn->ehwait, |
1583 | session->state == ISCSI_STATE_TERMINATE || | 1606 | session->state == ISCSI_STATE_TERMINATE || |
1584 | session->state == ISCSI_STATE_LOGGED_IN || | 1607 | session->state == ISCSI_STATE_LOGGED_IN || |
@@ -1588,10 +1611,10 @@ failed: | |||
1588 | 1611 | ||
1589 | mutex_lock(&session->eh_mutex); | 1612 | mutex_lock(&session->eh_mutex); |
1590 | spin_lock_bh(&session->lock); | 1613 | spin_lock_bh(&session->lock); |
1591 | if (session->state == ISCSI_STATE_LOGGED_IN) | 1614 | if (session->state == ISCSI_STATE_LOGGED_IN) { |
1592 | iscsi_session_printk(KERN_INFO, session, | 1615 | ISCSI_DBG_EH(session, |
1593 | "target reset succeeded\n"); | 1616 | "target reset succeeded\n"); |
1594 | else | 1617 | } else |
1595 | goto failed; | 1618 | goto failed; |
1596 | spin_unlock_bh(&session->lock); | 1619 | spin_unlock_bh(&session->lock); |
1597 | mutex_unlock(&session->eh_mutex); | 1620 | mutex_unlock(&session->eh_mutex); |
@@ -1607,7 +1630,7 @@ static void iscsi_tmf_timedout(unsigned long data) | |||
1607 | spin_lock(&session->lock); | 1630 | spin_lock(&session->lock); |
1608 | if (conn->tmf_state == TMF_QUEUED) { | 1631 | if (conn->tmf_state == TMF_QUEUED) { |
1609 | conn->tmf_state = TMF_TIMEDOUT; | 1632 | conn->tmf_state = TMF_TIMEDOUT; |
1610 | ISCSI_DBG_SESSION(session, "tmf timedout\n"); | 1633 | ISCSI_DBG_EH(session, "tmf timedout\n"); |
1611 | /* unblock eh_abort() */ | 1634 | /* unblock eh_abort() */ |
1612 | wake_up(&conn->ehwait); | 1635 | wake_up(&conn->ehwait); |
1613 | } | 1636 | } |
@@ -1627,7 +1650,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, | |||
1627 | spin_unlock_bh(&session->lock); | 1650 | spin_unlock_bh(&session->lock); |
1628 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1651 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
1629 | spin_lock_bh(&session->lock); | 1652 | spin_lock_bh(&session->lock); |
1630 | ISCSI_DBG_SESSION(session, "tmf exec failure\n"); | 1653 | ISCSI_DBG_EH(session, "tmf exec failure\n"); |
1631 | return -EPERM; | 1654 | return -EPERM; |
1632 | } | 1655 | } |
1633 | conn->tmfcmd_pdus_cnt++; | 1656 | conn->tmfcmd_pdus_cnt++; |
@@ -1635,7 +1658,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, | |||
1635 | conn->tmf_timer.function = iscsi_tmf_timedout; | 1658 | conn->tmf_timer.function = iscsi_tmf_timedout; |
1636 | conn->tmf_timer.data = (unsigned long)conn; | 1659 | conn->tmf_timer.data = (unsigned long)conn; |
1637 | add_timer(&conn->tmf_timer); | 1660 | add_timer(&conn->tmf_timer); |
1638 | ISCSI_DBG_SESSION(session, "tmf set timeout\n"); | 1661 | ISCSI_DBG_EH(session, "tmf set timeout\n"); |
1639 | 1662 | ||
1640 | spin_unlock_bh(&session->lock); | 1663 | spin_unlock_bh(&session->lock); |
1641 | mutex_unlock(&session->eh_mutex); | 1664 | mutex_unlock(&session->eh_mutex); |
@@ -1733,7 +1756,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) | |||
1733 | cls_session = starget_to_session(scsi_target(sc->device)); | 1756 | cls_session = starget_to_session(scsi_target(sc->device)); |
1734 | session = cls_session->dd_data; | 1757 | session = cls_session->dd_data; |
1735 | 1758 | ||
1736 | ISCSI_DBG_SESSION(session, "scsi cmd %p timedout\n", sc); | 1759 | ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); |
1737 | 1760 | ||
1738 | spin_lock(&session->lock); | 1761 | spin_lock(&session->lock); |
1739 | if (session->state != ISCSI_STATE_LOGGED_IN) { | 1762 | if (session->state != ISCSI_STATE_LOGGED_IN) { |
@@ -1763,10 +1786,10 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) | |||
1763 | * nop as a ping. | 1786 | * nop as a ping. |
1764 | */ | 1787 | */ |
1765 | if (time_after_eq(task->last_xfer, task->last_timeout)) { | 1788 | if (time_after_eq(task->last_xfer, task->last_timeout)) { |
1766 | ISCSI_DBG_CONN(conn, "Command making progress. Asking " | 1789 | ISCSI_DBG_EH(session, "Command making progress. Asking " |
1767 | "scsi-ml for more time to complete. " | 1790 | "scsi-ml for more time to complete. " |
1768 | "Last data recv at %lu. Last timeout was at " | 1791 | "Last data recv at %lu. Last timeout was at " |
1769 | "%lu\n.", task->last_xfer, task->last_timeout); | 1792 | "%lu\n.", task->last_xfer, task->last_timeout); |
1770 | task->have_checked_conn = false; | 1793 | task->have_checked_conn = false; |
1771 | rc = BLK_EH_RESET_TIMER; | 1794 | rc = BLK_EH_RESET_TIMER; |
1772 | goto done; | 1795 | goto done; |
@@ -1806,8 +1829,8 @@ done: | |||
1806 | if (task) | 1829 | if (task) |
1807 | task->last_timeout = jiffies; | 1830 | task->last_timeout = jiffies; |
1808 | spin_unlock(&session->lock); | 1831 | spin_unlock(&session->lock); |
1809 | ISCSI_DBG_SESSION(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? | 1832 | ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? |
1810 | "timer reset" : "nh"); | 1833 | "timer reset" : "nh"); |
1811 | return rc; | 1834 | return rc; |
1812 | } | 1835 | } |
1813 | 1836 | ||
@@ -1877,7 +1900,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1877 | cls_session = starget_to_session(scsi_target(sc->device)); | 1900 | cls_session = starget_to_session(scsi_target(sc->device)); |
1878 | session = cls_session->dd_data; | 1901 | session = cls_session->dd_data; |
1879 | 1902 | ||
1880 | ISCSI_DBG_SESSION(session, "aborting sc %p\n", sc); | 1903 | ISCSI_DBG_EH(session, "aborting sc %p\n", sc); |
1881 | 1904 | ||
1882 | mutex_lock(&session->eh_mutex); | 1905 | mutex_lock(&session->eh_mutex); |
1883 | spin_lock_bh(&session->lock); | 1906 | spin_lock_bh(&session->lock); |
@@ -1886,8 +1909,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1886 | * got the command. | 1909 | * got the command. |
1887 | */ | 1910 | */ |
1888 | if (!sc->SCp.ptr) { | 1911 | if (!sc->SCp.ptr) { |
1889 | ISCSI_DBG_SESSION(session, "sc never reached iscsi layer or " | 1912 | ISCSI_DBG_EH(session, "sc never reached iscsi layer or " |
1890 | "it completed.\n"); | 1913 | "it completed.\n"); |
1891 | spin_unlock_bh(&session->lock); | 1914 | spin_unlock_bh(&session->lock); |
1892 | mutex_unlock(&session->eh_mutex); | 1915 | mutex_unlock(&session->eh_mutex); |
1893 | return SUCCESS; | 1916 | return SUCCESS; |
@@ -1901,7 +1924,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1901 | sc->SCp.phase != session->age) { | 1924 | sc->SCp.phase != session->age) { |
1902 | spin_unlock_bh(&session->lock); | 1925 | spin_unlock_bh(&session->lock); |
1903 | mutex_unlock(&session->eh_mutex); | 1926 | mutex_unlock(&session->eh_mutex); |
1904 | ISCSI_DBG_SESSION(session, "failing abort due to dropped " | 1927 | ISCSI_DBG_EH(session, "failing abort due to dropped " |
1905 | "session.\n"); | 1928 | "session.\n"); |
1906 | return FAILED; | 1929 | return FAILED; |
1907 | } | 1930 | } |
@@ -1911,13 +1934,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1911 | age = session->age; | 1934 | age = session->age; |
1912 | 1935 | ||
1913 | task = (struct iscsi_task *)sc->SCp.ptr; | 1936 | task = (struct iscsi_task *)sc->SCp.ptr; |
1914 | ISCSI_DBG_SESSION(session, "aborting [sc %p itt 0x%x]\n", | 1937 | ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", |
1915 | sc, task->itt); | 1938 | sc, task->itt); |
1916 | 1939 | ||
1917 | /* task completed before time out */ | 1940 | /* task completed before time out */ |
1918 | if (!task->sc) { | 1941 | if (!task->sc) { |
1919 | ISCSI_DBG_SESSION(session, "sc completed while abort in " | 1942 | ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); |
1920 | "progress\n"); | ||
1921 | goto success; | 1943 | goto success; |
1922 | } | 1944 | } |
1923 | 1945 | ||
@@ -1966,8 +1988,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1966 | if (!sc->SCp.ptr) { | 1988 | if (!sc->SCp.ptr) { |
1967 | conn->tmf_state = TMF_INITIAL; | 1989 | conn->tmf_state = TMF_INITIAL; |
1968 | /* task completed before tmf abort response */ | 1990 | /* task completed before tmf abort response */ |
1969 | ISCSI_DBG_SESSION(session, "sc completed while abort " | 1991 | ISCSI_DBG_EH(session, "sc completed while abort in " |
1970 | "in progress\n"); | 1992 | "progress\n"); |
1971 | goto success; | 1993 | goto success; |
1972 | } | 1994 | } |
1973 | /* fall through */ | 1995 | /* fall through */ |
@@ -1979,16 +2001,16 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1979 | success: | 2001 | success: |
1980 | spin_unlock_bh(&session->lock); | 2002 | spin_unlock_bh(&session->lock); |
1981 | success_unlocked: | 2003 | success_unlocked: |
1982 | ISCSI_DBG_SESSION(session, "abort success [sc %p itt 0x%x]\n", | 2004 | ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n", |
1983 | sc, task->itt); | 2005 | sc, task->itt); |
1984 | mutex_unlock(&session->eh_mutex); | 2006 | mutex_unlock(&session->eh_mutex); |
1985 | return SUCCESS; | 2007 | return SUCCESS; |
1986 | 2008 | ||
1987 | failed: | 2009 | failed: |
1988 | spin_unlock_bh(&session->lock); | 2010 | spin_unlock_bh(&session->lock); |
1989 | failed_unlocked: | 2011 | failed_unlocked: |
1990 | ISCSI_DBG_SESSION(session, "abort failed [sc %p itt 0x%x]\n", sc, | 2012 | ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc, |
1991 | task ? task->itt : 0); | 2013 | task ? task->itt : 0); |
1992 | mutex_unlock(&session->eh_mutex); | 2014 | mutex_unlock(&session->eh_mutex); |
1993 | return FAILED; | 2015 | return FAILED; |
1994 | } | 2016 | } |
@@ -2015,8 +2037,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
2015 | cls_session = starget_to_session(scsi_target(sc->device)); | 2037 | cls_session = starget_to_session(scsi_target(sc->device)); |
2016 | session = cls_session->dd_data; | 2038 | session = cls_session->dd_data; |
2017 | 2039 | ||
2018 | ISCSI_DBG_SESSION(session, "LU Reset [sc %p lun %u]\n", | 2040 | ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun); |
2019 | sc, sc->device->lun); | ||
2020 | 2041 | ||
2021 | mutex_lock(&session->eh_mutex); | 2042 | mutex_lock(&session->eh_mutex); |
2022 | spin_lock_bh(&session->lock); | 2043 | spin_lock_bh(&session->lock); |
@@ -2070,8 +2091,8 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
2070 | unlock: | 2091 | unlock: |
2071 | spin_unlock_bh(&session->lock); | 2092 | spin_unlock_bh(&session->lock); |
2072 | done: | 2093 | done: |
2073 | ISCSI_DBG_SESSION(session, "dev reset result = %s\n", | 2094 | ISCSI_DBG_EH(session, "dev reset result = %s\n", |
2074 | rc == SUCCESS ? "SUCCESS" : "FAILED"); | 2095 | rc == SUCCESS ? "SUCCESS" : "FAILED"); |
2075 | mutex_unlock(&session->eh_mutex); | 2096 | mutex_unlock(&session->eh_mutex); |
2076 | return rc; | 2097 | return rc; |
2077 | } | 2098 | } |