Re: [PATCH] Add logging to scsi_transport_iscsi.c

2009-07-30 Thread Mike Christie

Erez Zilber wrote:
 On Thu, Jul 30, 2009 at 6:37 AM, Mike Christiemicha...@cs.wisc.edu wrote:
 On 07/26/2009 08:48 AM, Erez Zilber wrote:
 I've attached a new version. I hope it's better. Whenever possible,
 there's a dbg statement before  after. For example, if we free the
 conn object, I can't put a dbg call after it (because conn is already
 NULL). If you still see specific things that need to be fixed, let me
 know.

 Thanks for the work on this.

 How about the attached.
 - I added a : between the function name and debug output.
 - Removed some extra newlines
 - Tried to add dbg statements at the top and end of functions that can
 take a long time or fail in odd ways because they call into the scsi
 layer like the scanning, blocking, target removal, etc. For functions
 like allocation, adding, destroying and freeing I tried to just add a
 dbg statement at the top of end of the function.

 The patch was made over the linux-2.6-iscsi tree iscsi branch.

 
 Looks good.
 

Ok. Merged in linux-2.6-iscsi. I have to do some reworking to the 
open-iscsi.org patches. That will take some time.

Thanks.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: [PATCH] Add logging to scsi_transport_iscsi.c

2009-07-29 Thread Mike Christie
On 07/26/2009 08:48 AM, Erez Zilber wrote:
 I've attached a new version. I hope it's better. Whenever possible,
 there's a dbg statement before  after. For example, if we free the
 conn object, I can't put a dbg call after it (because conn is already
 NULL). If you still see specific things that need to be fixed, let me
 know.


Thanks for the work on this.

How about the attached.
- I added a : between the function name and debug output.
- Removed some extra newlines
- Tried to add dbg statements at the top and end of functions that can 
take a long time or fail in odd ways because they call into the scsi 
layer like the scanning, blocking, target removal, etc. For functions 
like allocation, adding, destroying and freeing I tried to just add a 
dbg statement at the top of end of the function.

The patch was made over the linux-2.6-iscsi tree iscsi branch.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index b47240c..5d765f5 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -36,6 +36,38 @@
 
 #define ISCSI_TRANSPORT_VERSION 2.0-870
 
+static int dbg_session;
+module_param_named(debug_session, dbg_session, int,
+  S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug_session,
+Turn on debugging for sessions in scsi_transport_iscsi 
+module. Set to 1 to turn on, and zero to turn off. Default 
+is off.);
+
+static int dbg_conn;
+module_param_named(debug_conn, dbg_conn, int,
+  S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug_conn,
+Turn on debugging for connections in scsi_transport_iscsi 
+module. Set to 1 to turn on, and zero to turn off. Default 
+is off.);
+
+#define ISCSI_DBG_TRANS_SESSION(_session, dbg_fmt, arg...) \
+   do {\
+   if (dbg_session)\
+   iscsi_cls_session_printk(KERN_INFO, _session,   \
+%s:  dbg_fmt,\
+__func__, ##arg);  \
+   } while (0);
+
+#define ISCSI_DBG_TRANS_CONN(_conn, dbg_fmt, arg...)   \
+   do {\
+   if (dbg_conn)   \
+   iscsi_cls_conn_printk(KERN_INFO, _conn, \
+ %s:  dbg_fmt,   \
+ __func__, ##arg); \
+   } while (0);
+
 struct iscsi_internal {
struct scsi_transport_template t;
struct iscsi_transport *iscsi_transport;
@@ -377,6 +409,7 @@ static void iscsi_session_release(struct device *dev)
 
shost = iscsi_session_to_shost(session);
scsi_host_put(shost);
+   ISCSI_DBG_TRANS_SESSION(session, Completing session release\n);
kfree(session);
 }
 
@@ -441,6 +474,9 @@ static int iscsi_user_scan_session(struct device *dev, void 
*data)
return 0;
 
session = iscsi_dev_to_session(dev);
+
+   ISCSI_DBG_TRANS_SESSION(session, Scanning session\n);
+
shost = iscsi_session_to_shost(session);
ihost = shost-shost_data;
 
@@ -448,8 +484,7 @@ static int iscsi_user_scan_session(struct device *dev, void 
*data)
spin_lock_irqsave(session-lock, flags);
if (session-state != ISCSI_SESSION_LOGGED_IN) {
spin_unlock_irqrestore(session-lock, flags);
-   mutex_unlock(ihost-mutex);
-   return 0;
+   goto user_scan_exit;
}
id = session-target_id;
spin_unlock_irqrestore(session-lock, flags);
@@ -462,7 +497,10 @@ static int iscsi_user_scan_session(struct device *dev, 
void *data)
scsi_scan_target(session-dev, 0, id,
 scan_data-lun, 1);
}
+   
+user_scan_exit:
mutex_unlock(ihost-mutex);
+   ISCSI_DBG_TRANS_SESSION(session, Completed session scan\n);
return 0;
 }
 
@@ -522,7 +560,9 @@ static void session_recovery_timedout(struct work_struct 
*work)
if (session-transport-session_recovery_timedout)
session-transport-session_recovery_timedout(session);
 
+   ISCSI_DBG_TRANS_SESSION(session, Unblocking SCSI target\n);
scsi_target_unblock(session-dev);
+