On Thu, Jun 4, 2009 at 7:59 PM, Mike Christie<micha...@cs.wisc.edu> wrote:
>
> Erez Zilber wrote:
>>> With that patch you can do both. module_params are exposed in sysfs and
>>> if you set IWUSR then you can write to it.
>>>
>>> echo 1 > /sys/module/libiscsi/debug_libiscsi
>>>
>>> to turn on
>>>
>>> echo 0 > /sys/module/libiscsi/debug_libiscsi
>>>
>>> to turn off.
>>
>> OK, thanks.
>>
>>>> We can have separate logging for stuff like login, scsi, error
>>>> handling, connection state etc.
>>>>
>>> Send a patch. Note that right now each module has its own logging param.
>>> So the higher level libiscsi stuff has one. The common iscsi over tcp
>>> module libiscsi_tcp has one, then iscsi_tcp has its own. You may want to
>>> merge them all into one or make it so you can turn it on/off at each
>>> layer/level.
>>
>> I've attached a patch that add 2 more module parameters to libiscsi,
>> so now we have conn, session & eh events. Later, we can add more
>> logging events. If you're ok with this fix, I will send another patch
>
> Looks ok to me.
>
>> that fixes the broken compat patches. BTW - which compat patches are
>
> Ok thanks.
>
>> still maintained?
>>
>
> 2.6.14-23_compat.patch
> 2.6.24_compat.patch
> 2.6.26_compat.patch
> 2.6.27_compat.patch
>

Attached with fixes to compat patches.

Erez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

[PATCH] Use more debug flags in libiscsi

Allow the user to control the debug logs in libiscsi. We will now
have a module param for connection, session & error handling. Also,
fix backport patches.

Signed-off-by: Erez Zilber <erezzi.l...@gmail.com>
---
 kernel/2.6.26_compat.patch |   10 ++--
 kernel/2.6.27_compat.patch |   13 ++----
 kernel/libiscsi.c          |   93 +++++++++++++++++++++++++++-----------------
 3 files changed, 67 insertions(+), 49 deletions(-)

diff --git a/kernel/2.6.26_compat.patch b/kernel/2.6.26_compat.patch
index 98e9d3e..641d2f6 100644
--- a/kernel/2.6.26_compat.patch
+++ b/kernel/2.6.26_compat.patch
@@ -1,5 +1,5 @@
 diff --git a/libiscsi.c b/libiscsi.c
-index 733fa00..5d88693 100644
+index 149d5eb..467abbf 100644
 --- a/libiscsi.c
 +++ b/libiscsi.c
 @@ -38,6 +38,8 @@
@@ -8,9 +8,9 @@ index 733fa00..5d88693 100644
  
 +#include "open_iscsi_compat.h"
 +
- static int iscsi_dbg_lib;
- module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR);
- MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. "
+ static int iscsi_dbg_lib_conn;
+ module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int,
+ 		   S_IRUGO | S_IWUSR);
 diff --git a/open_iscsi_compat.h b/open_iscsi_compat.h
 new file mode 100644
 index 0000000..b977df5
@@ -46,7 +46,7 @@ index 0000000..b977df5
 +
 +#endif
 diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c
-index c9e95e7..79bd57f 100644
+index a49a92c..c07535e 100644
 --- a/scsi_transport_iscsi.c
 +++ b/scsi_transport_iscsi.c
 @@ -30,6 +30,8 @@
diff --git a/kernel/2.6.27_compat.patch b/kernel/2.6.27_compat.patch
index 144f68b..5111232 100644
--- a/kernel/2.6.27_compat.patch
+++ b/kernel/2.6.27_compat.patch
@@ -1,5 +1,5 @@
 diff --git a/libiscsi.c b/libiscsi.c
-index 733fa00..5d88693 100644
+index 149d5eb..467abbf 100644
 --- a/libiscsi.c
 +++ b/libiscsi.c
 @@ -38,6 +38,8 @@
@@ -8,9 +8,9 @@ index 733fa00..5d88693 100644
  
 +#include "open_iscsi_compat.h"
 +
- static int iscsi_dbg_lib;
- module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR);
- MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. "
+ static int iscsi_dbg_lib_conn;
+ module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int,
+		    S_IRUGO | S_IWUSR);
 diff --git a/open_iscsi_compat.h b/open_iscsi_compat.h
 new file mode 100644
 index 0000000..b977df5
@@ -46,7 +46,7 @@ index 0000000..b977df5
 +
 +#endif
 diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c
-index c9e95e7..38e14e5 100644
+index a49a92c..a9f480e 100644
 --- a/scsi_transport_iscsi.c
 +++ b/scsi_transport_iscsi.c
 @@ -30,6 +30,8 @@
@@ -58,6 +58,3 @@ index c9e95e7..38e14e5 100644
  #define ISCSI_SESSION_ATTRS 21
  #define ISCSI_CONN_ATTRS 13
  #define ISCSI_HOST_ATTRS 4
--- 
-1.5.2.1
-
diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c
index fe4b66e..149d5eb 100644
--- a/kernel/libiscsi.c
+++ b/kernel/libiscsi.c
@@ -38,15 +38,30 @@
 #include "scsi_transport_iscsi.h"
 #include "libiscsi.h"
 
-static int iscsi_dbg_lib;
-module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. "
-		 "Set to 1 to turn on, and zero to turn off. Default "
-		 "is off.");
+static int iscsi_dbg_lib_conn;
+module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int,
+		   S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug_libiscsi_conn,
+		 "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...)			\
 	do {							\
-		if (iscsi_dbg_lib)				\
+		if (iscsi_dbg_lib_conn)				\
 			iscsi_conn_printk(KERN_INFO, _conn,	\
 					     "%s " dbg_fmt,	\
 					     __func__, ##arg);	\
@@ -54,7 +69,15 @@ MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. "
 
 #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...)			\
 	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,	\
 					     "%s " dbg_fmt,		\
 					     __func__, ##arg);		\
@@ -1557,10 +1580,10 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
 	spin_lock_bh(&session->lock);
 	if (session->state == ISCSI_STATE_TERMINATE) {
 failed:
-		iscsi_session_printk(KERN_INFO, session,
-				     "failing target reset: Could not log "
-				     "back into target [age %d]\n",
-				     session->age);
+		ISCSI_DBG_EH(session,
+			     "failing target reset: Could not log back into "
+			     "target [age %d]\n",
+			     session->age);
 		spin_unlock_bh(&session->lock);
 		mutex_unlock(&session->eh_mutex);
 		return FAILED;
@@ -1584,10 +1607,10 @@ failed:
 
 	mutex_lock(&session->eh_mutex);
 	spin_lock_bh(&session->lock);
-	if (session->state == ISCSI_STATE_LOGGED_IN)
-		iscsi_session_printk(KERN_INFO, session,
-				     "target reset succeeded\n");
-	else
+	if (session->state == ISCSI_STATE_LOGGED_IN) {
+		ISCSI_DBG_EH(session,
+			     "target reset succeeded\n");
+	} else
 		goto failed;
 	spin_unlock_bh(&session->lock);
 	mutex_unlock(&session->eh_mutex);
@@ -1728,7 +1751,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
 	cls_session = starget_to_session(scsi_target(scmd->device));
 	session = cls_session->dd_data;
 
-	ISCSI_DBG_SESSION(session, "scsi cmd %p timedout\n", scmd);
+	ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", scmd);
 
 	spin_lock(&session->lock);
 	if (session->state != ISCSI_STATE_LOGGED_IN) {
@@ -1772,8 +1795,8 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
 		rc = BLK_EH_RESET_TIMER;
 done:
 	spin_unlock(&session->lock);
-	ISCSI_DBG_SESSION(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
-			  "timer reset" : "nh");
+	ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
+		     "timer reset" : "nh");
 	return rc;
 }
 
@@ -1843,7 +1866,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 	cls_session = starget_to_session(scsi_target(sc->device));
 	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);
 	spin_lock_bh(&session->lock);
@@ -1852,8 +1875,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 	 * got the command.
 	 */
 	if (!sc->SCp.ptr) {
-		ISCSI_DBG_SESSION(session, "sc never reached iscsi layer or "
-				  "it completed.\n");
+		ISCSI_DBG_EH(session, "sc never reached iscsi layer or "
+				      "it completed.\n");
 		spin_unlock_bh(&session->lock);
 		mutex_unlock(&session->eh_mutex);
 		return SUCCESS;
@@ -1867,7 +1890,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 	    sc->SCp.phase != session->age) {
 		spin_unlock_bh(&session->lock);
 		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");
 		return FAILED;
 	}
@@ -1877,13 +1900,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 	age = session->age;
 
 	task = (struct iscsi_task *)sc->SCp.ptr;
-	ISCSI_DBG_SESSION(session, "aborting [sc %p itt 0x%x]\n",
-			  sc, task->itt);
+	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n",
+		     sc, task->itt);
 
 	/* task completed before time out */
 	if (!task->sc) {
-		ISCSI_DBG_SESSION(session, "sc completed while abort in "
-				  "progress\n");
+		ISCSI_DBG_EH(session, "sc completed while abort in progress\n");
 		goto success;
 	}
 
@@ -1932,8 +1954,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 		if (!sc->SCp.ptr) {
 			conn->tmf_state = TMF_INITIAL;
 			/* task completed before tmf abort response */
-			ISCSI_DBG_SESSION(session, "sc completed while abort "
-					  "in progress\n");
+			ISCSI_DBG_EH(session, "sc completed while abort	in "
+					      "progress\n");
 			goto success;
 		}
 		/* fall through */
@@ -1945,16 +1967,16 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 success:
 	spin_unlock_bh(&session->lock);
 success_unlocked:
-	ISCSI_DBG_SESSION(session, "abort success [sc %p itt 0x%x]\n",
-			  sc, task->itt);
+	ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
+		     sc, task->itt);
 	mutex_unlock(&session->eh_mutex);
 	return SUCCESS;
 
 failed:
 	spin_unlock_bh(&session->lock);
 failed_unlocked:
-	ISCSI_DBG_SESSION(session, "abort failed [sc %p itt 0x%x]\n", sc,
-			  task ? task->itt : 0);
+	ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
+		     task ? task->itt : 0);
 	mutex_unlock(&session->eh_mutex);
 	return FAILED;
 }
@@ -1981,8 +2003,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
 	cls_session = starget_to_session(scsi_target(sc->device));
 	session = cls_session->dd_data;
 
-	ISCSI_DBG_SESSION(session, "LU Reset [sc %p lun %u]\n",
-			  sc, sc->device->lun);
+	ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
 
 	mutex_lock(&session->eh_mutex);
 	spin_lock_bh(&session->lock);
@@ -2036,8 +2057,8 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
 unlock:
 	spin_unlock_bh(&session->lock);
 done:
-	ISCSI_DBG_SESSION(session, "dev reset result = %s\n",
-			 rc == SUCCESS ? "SUCCESS" : "FAILED");
+	ISCSI_DBG_EH(session, "dev reset result = %s\n",
+		     rc == SUCCESS ? "SUCCESS" : "FAILED");
 	mutex_unlock(&session->eh_mutex);
 	return rc;
 }
-- 
1.6.0.4

Reply via email to