Commit bd2199d4 authored by Erez Zilber's avatar Erez Zilber Committed by James Bottomley

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: default avatarErez Zilber <erezzi.list@gmail.com>
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 32382492
...@@ -38,15 +38,30 @@ ...@@ -38,15 +38,30 @@
#include <scsi/scsi_transport_iscsi.h> #include <scsi/scsi_transport_iscsi.h>
#include <scsi/libiscsi.h> #include <scsi/libiscsi.h>
static int iscsi_dbg_lib; static int iscsi_dbg_lib_conn;
module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR); module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int,
MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " S_IRUGO | S_IWUSR);
"Set to 1 to turn on, and zero to turn off. Default " MODULE_PARM_DESC(debug_libiscsi_conn,
"is off."); "Turn on debugging for connections in libiscsi module. "
"Set to 1 to turn on, and zero to turn off. Default is off.");
static int iscsi_dbg_lib_session;
module_param_named(debug_libiscsi_session, iscsi_dbg_lib_session, int,
S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug_libiscsi_session,
"Turn on debugging for sessions in libiscsi module. "
"Set to 1 to turn on, and zero to turn off. Default is off.");
static int iscsi_dbg_lib_eh;
module_param_named(debug_libiscsi_eh, iscsi_dbg_lib_eh, int,
S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug_libiscsi_eh,
"Turn on debugging for error handling in libiscsi module. "
"Set to 1 to turn on, and zero to turn off. Default is off.");
#define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \ #define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \
do { \ do { \
if (iscsi_dbg_lib) \ if (iscsi_dbg_lib_conn) \
iscsi_conn_printk(KERN_INFO, _conn, \ iscsi_conn_printk(KERN_INFO, _conn, \
"%s " dbg_fmt, \ "%s " dbg_fmt, \
__func__, ##arg); \ __func__, ##arg); \
...@@ -54,7 +69,15 @@ MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " ...@@ -54,7 +69,15 @@ MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. "
#define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \ #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \
do { \ do { \
if (iscsi_dbg_lib) \ if (iscsi_dbg_lib_session) \
iscsi_session_printk(KERN_INFO, _session, \
"%s " dbg_fmt, \
__func__, ##arg); \
} while (0);
#define ISCSI_DBG_EH(_session, dbg_fmt, arg...) \
do { \
if (iscsi_dbg_lib_eh) \
iscsi_session_printk(KERN_INFO, _session, \ iscsi_session_printk(KERN_INFO, _session, \
"%s " dbg_fmt, \ "%s " dbg_fmt, \
__func__, ##arg); \ __func__, ##arg); \
...@@ -1561,9 +1584,9 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) ...@@ -1561,9 +1584,9 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
if (session->state == ISCSI_STATE_TERMINATE) { if (session->state == ISCSI_STATE_TERMINATE) {
failed: failed:
iscsi_session_printk(KERN_INFO, session, ISCSI_DBG_EH(session,
"failing target reset: Could not log " "failing target reset: Could not log back into "
"back into target [age %d]\n", "target [age %d]\n",
session->age); session->age);
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
...@@ -1578,7 +1601,7 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) ...@@ -1578,7 +1601,7 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
*/ */
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
ISCSI_DBG_SESSION(session, "wait for relogin\n"); ISCSI_DBG_EH(session, "wait for relogin\n");
wait_event_interruptible(conn->ehwait, wait_event_interruptible(conn->ehwait,
session->state == ISCSI_STATE_TERMINATE || session->state == ISCSI_STATE_TERMINATE ||
session->state == ISCSI_STATE_LOGGED_IN || session->state == ISCSI_STATE_LOGGED_IN ||
...@@ -1588,10 +1611,10 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) ...@@ -1588,10 +1611,10 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
mutex_lock(&session->eh_mutex); mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
if (session->state == ISCSI_STATE_LOGGED_IN) if (session->state == ISCSI_STATE_LOGGED_IN) {
iscsi_session_printk(KERN_INFO, session, ISCSI_DBG_EH(session,
"target reset succeeded\n"); "target reset succeeded\n");
else } else
goto failed; goto failed;
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
...@@ -1607,7 +1630,7 @@ static void iscsi_tmf_timedout(unsigned long data) ...@@ -1607,7 +1630,7 @@ static void iscsi_tmf_timedout(unsigned long data)
spin_lock(&session->lock); spin_lock(&session->lock);
if (conn->tmf_state == TMF_QUEUED) { if (conn->tmf_state == TMF_QUEUED) {
conn->tmf_state = TMF_TIMEDOUT; conn->tmf_state = TMF_TIMEDOUT;
ISCSI_DBG_SESSION(session, "tmf timedout\n"); ISCSI_DBG_EH(session, "tmf timedout\n");
/* unblock eh_abort() */ /* unblock eh_abort() */
wake_up(&conn->ehwait); wake_up(&conn->ehwait);
} }
...@@ -1627,7 +1650,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, ...@@ -1627,7 +1650,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
ISCSI_DBG_SESSION(session, "tmf exec failure\n"); ISCSI_DBG_EH(session, "tmf exec failure\n");
return -EPERM; return -EPERM;
} }
conn->tmfcmd_pdus_cnt++; conn->tmfcmd_pdus_cnt++;
...@@ -1635,7 +1658,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, ...@@ -1635,7 +1658,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
conn->tmf_timer.function = iscsi_tmf_timedout; conn->tmf_timer.function = iscsi_tmf_timedout;
conn->tmf_timer.data = (unsigned long)conn; conn->tmf_timer.data = (unsigned long)conn;
add_timer(&conn->tmf_timer); add_timer(&conn->tmf_timer);
ISCSI_DBG_SESSION(session, "tmf set timeout\n"); ISCSI_DBG_EH(session, "tmf set timeout\n");
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex); 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,7 +1756,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
cls_session = starget_to_session(scsi_target(sc->device)); cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data; session = cls_session->dd_data;
ISCSI_DBG_SESSION(session, "scsi cmd %p timedout\n", sc); ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc);
spin_lock(&session->lock); spin_lock(&session->lock);
if (session->state != ISCSI_STATE_LOGGED_IN) { if (session->state != ISCSI_STATE_LOGGED_IN) {
...@@ -1763,7 +1786,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) ...@@ -1763,7 +1786,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
* nop as a ping. * nop as a ping.
*/ */
if (time_after_eq(task->last_xfer, task->last_timeout)) { if (time_after_eq(task->last_xfer, task->last_timeout)) {
ISCSI_DBG_CONN(conn, "Command making progress. Asking " ISCSI_DBG_EH(session, "Command making progress. Asking "
"scsi-ml for more time to complete. " "scsi-ml for more time to complete. "
"Last data recv at %lu. Last timeout was at " "Last data recv at %lu. Last timeout was at "
"%lu\n.", task->last_xfer, task->last_timeout); "%lu\n.", task->last_xfer, task->last_timeout);
...@@ -1806,7 +1829,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) ...@@ -1806,7 +1829,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
if (task) if (task)
task->last_timeout = jiffies; task->last_timeout = jiffies;
spin_unlock(&session->lock); spin_unlock(&session->lock);
ISCSI_DBG_SESSION(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
"timer reset" : "nh"); "timer reset" : "nh");
return rc; return rc;
} }
...@@ -1877,7 +1900,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1877,7 +1900,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
cls_session = starget_to_session(scsi_target(sc->device)); cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data; session = cls_session->dd_data;
ISCSI_DBG_SESSION(session, "aborting sc %p\n", sc); ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
mutex_lock(&session->eh_mutex); mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
...@@ -1886,7 +1909,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1886,7 +1909,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
* got the command. * got the command.
*/ */
if (!sc->SCp.ptr) { if (!sc->SCp.ptr) {
ISCSI_DBG_SESSION(session, "sc never reached iscsi layer or " ISCSI_DBG_EH(session, "sc never reached iscsi layer or "
"it completed.\n"); "it completed.\n");
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
...@@ -1901,7 +1924,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1901,7 +1924,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
sc->SCp.phase != session->age) { sc->SCp.phase != session->age) {
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
ISCSI_DBG_SESSION(session, "failing abort due to dropped " ISCSI_DBG_EH(session, "failing abort due to dropped "
"session.\n"); "session.\n");
return FAILED; return FAILED;
} }
...@@ -1911,13 +1934,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1911,13 +1934,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
age = session->age; age = session->age;
task = (struct iscsi_task *)sc->SCp.ptr; task = (struct iscsi_task *)sc->SCp.ptr;
ISCSI_DBG_SESSION(session, "aborting [sc %p itt 0x%x]\n", ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n",
sc, task->itt); sc, task->itt);
/* task completed before time out */ /* task completed before time out */
if (!task->sc) { if (!task->sc) {
ISCSI_DBG_SESSION(session, "sc completed while abort in " ISCSI_DBG_EH(session, "sc completed while abort in progress\n");
"progress\n");
goto success; goto success;
} }
...@@ -1966,8 +1988,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1966,8 +1988,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
if (!sc->SCp.ptr) { if (!sc->SCp.ptr) {
conn->tmf_state = TMF_INITIAL; conn->tmf_state = TMF_INITIAL;
/* task completed before tmf abort response */ /* task completed before tmf abort response */
ISCSI_DBG_SESSION(session, "sc completed while abort " ISCSI_DBG_EH(session, "sc completed while abort in "
"in progress\n"); "progress\n");
goto success; goto success;
} }
/* fall through */ /* fall through */
...@@ -1979,7 +2001,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1979,7 +2001,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
success: success:
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
success_unlocked: success_unlocked:
ISCSI_DBG_SESSION(session, "abort success [sc %p itt 0x%x]\n", ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
sc, task->itt); sc, task->itt);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
return SUCCESS; return SUCCESS;
...@@ -1987,7 +2009,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ...@@ -1987,7 +2009,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
failed: failed:
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
failed_unlocked: failed_unlocked:
ISCSI_DBG_SESSION(session, "abort failed [sc %p itt 0x%x]\n", sc, ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
task ? task->itt : 0); task ? task->itt : 0);
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
return FAILED; return FAILED;
...@@ -2015,8 +2037,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) ...@@ -2015,8 +2037,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
cls_session = starget_to_session(scsi_target(sc->device)); cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data; session = cls_session->dd_data;
ISCSI_DBG_SESSION(session, "LU Reset [sc %p lun %u]\n", ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
sc, sc->device->lun);
mutex_lock(&session->eh_mutex); mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
...@@ -2070,7 +2091,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) ...@@ -2070,7 +2091,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
unlock: unlock:
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
done: done:
ISCSI_DBG_SESSION(session, "dev reset result = %s\n", ISCSI_DBG_EH(session, "dev reset result = %s\n",
rc == SUCCESS ? "SUCCESS" : "FAILED"); rc == SUCCESS ? "SUCCESS" : "FAILED");
mutex_unlock(&session->eh_mutex); mutex_unlock(&session->eh_mutex);
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment