diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2009-08-20 16:11:01 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-05 10:42:45 -0400 |
commit | 632248aab3170004e24512a4378fc6d9d7f3b4ac (patch) | |
tree | 92a1044d22bd70244298aeb4e4ff1ed164419cfa /drivers/scsi | |
parent | b06fc73a9ebd352065dd4dd3139fb53ed72ac970 (diff) |
[SCSI] iscsi class: Add logging to scsi_transport_iscsi.c
Logging for connections and sessions in the scsi_transport_iscsi module
is now controlled by module parameters.
Signed-off-by: Erez Zilber <erezzi.list@gmail.com>
[Mike Christie: newline fixups and modification of some dbg statements]
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index b47240ca4b19..ad897df36615 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -36,6 +36,38 @@ | |||
36 | 36 | ||
37 | #define ISCSI_TRANSPORT_VERSION "2.0-870" | 37 | #define ISCSI_TRANSPORT_VERSION "2.0-870" |
38 | 38 | ||
39 | static int dbg_session; | ||
40 | module_param_named(debug_session, dbg_session, int, | ||
41 | S_IRUGO | S_IWUSR); | ||
42 | MODULE_PARM_DESC(debug_session, | ||
43 | "Turn on debugging for sessions in scsi_transport_iscsi " | ||
44 | "module. Set to 1 to turn on, and zero to turn off. Default " | ||
45 | "is off."); | ||
46 | |||
47 | static int dbg_conn; | ||
48 | module_param_named(debug_conn, dbg_conn, int, | ||
49 | S_IRUGO | S_IWUSR); | ||
50 | MODULE_PARM_DESC(debug_conn, | ||
51 | "Turn on debugging for connections in scsi_transport_iscsi " | ||
52 | "module. Set to 1 to turn on, and zero to turn off. Default " | ||
53 | "is off."); | ||
54 | |||
55 | #define ISCSI_DBG_TRANS_SESSION(_session, dbg_fmt, arg...) \ | ||
56 | do { \ | ||
57 | if (dbg_session) \ | ||
58 | iscsi_cls_session_printk(KERN_INFO, _session, \ | ||
59 | "%s: " dbg_fmt, \ | ||
60 | __func__, ##arg); \ | ||
61 | } while (0); | ||
62 | |||
63 | #define ISCSI_DBG_TRANS_CONN(_conn, dbg_fmt, arg...) \ | ||
64 | do { \ | ||
65 | if (dbg_conn) \ | ||
66 | iscsi_cls_conn_printk(KERN_INFO, _conn, \ | ||
67 | "%s: " dbg_fmt, \ | ||
68 | __func__, ##arg); \ | ||
69 | } while (0); | ||
70 | |||
39 | struct iscsi_internal { | 71 | struct iscsi_internal { |
40 | struct scsi_transport_template t; | 72 | struct scsi_transport_template t; |
41 | struct iscsi_transport *iscsi_transport; | 73 | struct iscsi_transport *iscsi_transport; |
@@ -377,6 +409,7 @@ static void iscsi_session_release(struct device *dev) | |||
377 | 409 | ||
378 | shost = iscsi_session_to_shost(session); | 410 | shost = iscsi_session_to_shost(session); |
379 | scsi_host_put(shost); | 411 | scsi_host_put(shost); |
412 | ISCSI_DBG_TRANS_SESSION(session, "Completing session release\n"); | ||
380 | kfree(session); | 413 | kfree(session); |
381 | } | 414 | } |
382 | 415 | ||
@@ -441,6 +474,9 @@ static int iscsi_user_scan_session(struct device *dev, void *data) | |||
441 | return 0; | 474 | return 0; |
442 | 475 | ||
443 | session = iscsi_dev_to_session(dev); | 476 | session = iscsi_dev_to_session(dev); |
477 | |||
478 | ISCSI_DBG_TRANS_SESSION(session, "Scanning session\n"); | ||
479 | |||
444 | shost = iscsi_session_to_shost(session); | 480 | shost = iscsi_session_to_shost(session); |
445 | ihost = shost->shost_data; | 481 | ihost = shost->shost_data; |
446 | 482 | ||
@@ -448,8 +484,7 @@ static int iscsi_user_scan_session(struct device *dev, void *data) | |||
448 | spin_lock_irqsave(&session->lock, flags); | 484 | spin_lock_irqsave(&session->lock, flags); |
449 | if (session->state != ISCSI_SESSION_LOGGED_IN) { | 485 | if (session->state != ISCSI_SESSION_LOGGED_IN) { |
450 | spin_unlock_irqrestore(&session->lock, flags); | 486 | spin_unlock_irqrestore(&session->lock, flags); |
451 | mutex_unlock(&ihost->mutex); | 487 | goto user_scan_exit; |
452 | return 0; | ||
453 | } | 488 | } |
454 | id = session->target_id; | 489 | id = session->target_id; |
455 | spin_unlock_irqrestore(&session->lock, flags); | 490 | spin_unlock_irqrestore(&session->lock, flags); |
@@ -462,7 +497,10 @@ static int iscsi_user_scan_session(struct device *dev, void *data) | |||
462 | scsi_scan_target(&session->dev, 0, id, | 497 | scsi_scan_target(&session->dev, 0, id, |
463 | scan_data->lun, 1); | 498 | scan_data->lun, 1); |
464 | } | 499 | } |
500 | |||
501 | user_scan_exit: | ||
465 | mutex_unlock(&ihost->mutex); | 502 | mutex_unlock(&ihost->mutex); |
503 | ISCSI_DBG_TRANS_SESSION(session, "Completed session scan\n"); | ||
466 | return 0; | 504 | return 0; |
467 | } | 505 | } |
468 | 506 | ||
@@ -522,7 +560,9 @@ static void session_recovery_timedout(struct work_struct *work) | |||
522 | if (session->transport->session_recovery_timedout) | 560 | if (session->transport->session_recovery_timedout) |
523 | session->transport->session_recovery_timedout(session); | 561 | session->transport->session_recovery_timedout(session); |
524 | 562 | ||
563 | ISCSI_DBG_TRANS_SESSION(session, "Unblocking SCSI target\n"); | ||
525 | scsi_target_unblock(&session->dev); | 564 | scsi_target_unblock(&session->dev); |
565 | ISCSI_DBG_TRANS_SESSION(session, "Completed unblocking SCSI target\n"); | ||
526 | } | 566 | } |
527 | 567 | ||
528 | static void __iscsi_unblock_session(struct work_struct *work) | 568 | static void __iscsi_unblock_session(struct work_struct *work) |
@@ -534,6 +574,7 @@ static void __iscsi_unblock_session(struct work_struct *work) | |||
534 | struct iscsi_cls_host *ihost = shost->shost_data; | 574 | struct iscsi_cls_host *ihost = shost->shost_data; |
535 | unsigned long flags; | 575 | unsigned long flags; |
536 | 576 | ||
577 | ISCSI_DBG_TRANS_SESSION(session, "Unblocking session\n"); | ||
537 | /* | 578 | /* |
538 | * The recovery and unblock work get run from the same workqueue, | 579 | * The recovery and unblock work get run from the same workqueue, |
539 | * so try to cancel it if it was going to run after this unblock. | 580 | * so try to cancel it if it was going to run after this unblock. |
@@ -553,6 +594,7 @@ static void __iscsi_unblock_session(struct work_struct *work) | |||
553 | if (scsi_queue_work(shost, &session->scan_work)) | 594 | if (scsi_queue_work(shost, &session->scan_work)) |
554 | atomic_inc(&ihost->nr_scans); | 595 | atomic_inc(&ihost->nr_scans); |
555 | } | 596 | } |
597 | ISCSI_DBG_TRANS_SESSION(session, "Completed unblocking session\n"); | ||
556 | } | 598 | } |
557 | 599 | ||
558 | /** | 600 | /** |
@@ -579,10 +621,12 @@ static void __iscsi_block_session(struct work_struct *work) | |||
579 | block_work); | 621 | block_work); |
580 | unsigned long flags; | 622 | unsigned long flags; |
581 | 623 | ||
624 | ISCSI_DBG_TRANS_SESSION(session, "Blocking session\n"); | ||
582 | spin_lock_irqsave(&session->lock, flags); | 625 | spin_lock_irqsave(&session->lock, flags); |
583 | session->state = ISCSI_SESSION_FAILED; | 626 | session->state = ISCSI_SESSION_FAILED; |
584 | spin_unlock_irqrestore(&session->lock, flags); | 627 | spin_unlock_irqrestore(&session->lock, flags); |
585 | scsi_target_block(&session->dev); | 628 | scsi_target_block(&session->dev); |
629 | ISCSI_DBG_TRANS_SESSION(session, "Completed SCSI target blocking\n"); | ||
586 | queue_delayed_work(iscsi_eh_timer_workq, &session->recovery_work, | 630 | queue_delayed_work(iscsi_eh_timer_workq, &session->recovery_work, |
587 | session->recovery_tmo * HZ); | 631 | session->recovery_tmo * HZ); |
588 | } | 632 | } |
@@ -602,6 +646,8 @@ static void __iscsi_unbind_session(struct work_struct *work) | |||
602 | struct iscsi_cls_host *ihost = shost->shost_data; | 646 | struct iscsi_cls_host *ihost = shost->shost_data; |
603 | unsigned long flags; | 647 | unsigned long flags; |
604 | 648 | ||
649 | ISCSI_DBG_TRANS_SESSION(session, "Unbinding session\n"); | ||
650 | |||
605 | /* Prevent new scans and make sure scanning is not in progress */ | 651 | /* Prevent new scans and make sure scanning is not in progress */ |
606 | mutex_lock(&ihost->mutex); | 652 | mutex_lock(&ihost->mutex); |
607 | spin_lock_irqsave(&session->lock, flags); | 653 | spin_lock_irqsave(&session->lock, flags); |
@@ -616,6 +662,7 @@ static void __iscsi_unbind_session(struct work_struct *work) | |||
616 | 662 | ||
617 | scsi_remove_target(&session->dev); | 663 | scsi_remove_target(&session->dev); |
618 | iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); | 664 | iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); |
665 | ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n"); | ||
619 | } | 666 | } |
620 | 667 | ||
621 | struct iscsi_cls_session * | 668 | struct iscsi_cls_session * |
@@ -647,6 +694,8 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport, | |||
647 | device_initialize(&session->dev); | 694 | device_initialize(&session->dev); |
648 | if (dd_size) | 695 | if (dd_size) |
649 | session->dd_data = &session[1]; | 696 | session->dd_data = &session[1]; |
697 | |||
698 | ISCSI_DBG_TRANS_SESSION(session, "Completed session allocation\n"); | ||
650 | return session; | 699 | return session; |
651 | } | 700 | } |
652 | EXPORT_SYMBOL_GPL(iscsi_alloc_session); | 701 | EXPORT_SYMBOL_GPL(iscsi_alloc_session); |
@@ -712,6 +761,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id) | |||
712 | spin_unlock_irqrestore(&sesslock, flags); | 761 | spin_unlock_irqrestore(&sesslock, flags); |
713 | 762 | ||
714 | iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION); | 763 | iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION); |
764 | ISCSI_DBG_TRANS_SESSION(session, "Completed session adding\n"); | ||
715 | return 0; | 765 | return 0; |
716 | 766 | ||
717 | release_host: | 767 | release_host: |
@@ -752,6 +802,7 @@ static void iscsi_conn_release(struct device *dev) | |||
752 | struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); | 802 | struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); |
753 | struct device *parent = conn->dev.parent; | 803 | struct device *parent = conn->dev.parent; |
754 | 804 | ||
805 | ISCSI_DBG_TRANS_CONN(conn, "Releasing conn\n"); | ||
755 | kfree(conn); | 806 | kfree(conn); |
756 | put_device(parent); | 807 | put_device(parent); |
757 | } | 808 | } |
@@ -774,6 +825,8 @@ void iscsi_remove_session(struct iscsi_cls_session *session) | |||
774 | unsigned long flags; | 825 | unsigned long flags; |
775 | int err; | 826 | int err; |
776 | 827 | ||
828 | ISCSI_DBG_TRANS_SESSION(session, "Removing session\n"); | ||
829 | |||
777 | spin_lock_irqsave(&sesslock, flags); | 830 | spin_lock_irqsave(&sesslock, flags); |
778 | list_del(&session->sess_list); | 831 | list_del(&session->sess_list); |
779 | spin_unlock_irqrestore(&sesslock, flags); | 832 | spin_unlock_irqrestore(&sesslock, flags); |
@@ -807,12 +860,15 @@ void iscsi_remove_session(struct iscsi_cls_session *session) | |||
807 | "for session. Error %d.\n", err); | 860 | "for session. Error %d.\n", err); |
808 | 861 | ||
809 | transport_unregister_device(&session->dev); | 862 | transport_unregister_device(&session->dev); |
863 | |||
864 | ISCSI_DBG_TRANS_SESSION(session, "Completing session removal\n"); | ||
810 | device_del(&session->dev); | 865 | device_del(&session->dev); |
811 | } | 866 | } |
812 | EXPORT_SYMBOL_GPL(iscsi_remove_session); | 867 | EXPORT_SYMBOL_GPL(iscsi_remove_session); |
813 | 868 | ||
814 | void iscsi_free_session(struct iscsi_cls_session *session) | 869 | void iscsi_free_session(struct iscsi_cls_session *session) |
815 | { | 870 | { |
871 | ISCSI_DBG_TRANS_SESSION(session, "Freeing session\n"); | ||
816 | iscsi_session_event(session, ISCSI_KEVENT_DESTROY_SESSION); | 872 | iscsi_session_event(session, ISCSI_KEVENT_DESTROY_SESSION); |
817 | put_device(&session->dev); | 873 | put_device(&session->dev); |
818 | } | 874 | } |
@@ -828,6 +884,7 @@ EXPORT_SYMBOL_GPL(iscsi_free_session); | |||
828 | int iscsi_destroy_session(struct iscsi_cls_session *session) | 884 | int iscsi_destroy_session(struct iscsi_cls_session *session) |
829 | { | 885 | { |
830 | iscsi_remove_session(session); | 886 | iscsi_remove_session(session); |
887 | ISCSI_DBG_TRANS_SESSION(session, "Completing session destruction\n"); | ||
831 | iscsi_free_session(session); | 888 | iscsi_free_session(session); |
832 | return 0; | 889 | return 0; |
833 | } | 890 | } |
@@ -885,6 +942,8 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid) | |||
885 | list_add(&conn->conn_list, &connlist); | 942 | list_add(&conn->conn_list, &connlist); |
886 | conn->active = 1; | 943 | conn->active = 1; |
887 | spin_unlock_irqrestore(&connlock, flags); | 944 | spin_unlock_irqrestore(&connlock, flags); |
945 | |||
946 | ISCSI_DBG_TRANS_CONN(conn, "Completed conn creation\n"); | ||
888 | return conn; | 947 | return conn; |
889 | 948 | ||
890 | release_parent_ref: | 949 | release_parent_ref: |
@@ -912,6 +971,7 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn) | |||
912 | spin_unlock_irqrestore(&connlock, flags); | 971 | spin_unlock_irqrestore(&connlock, flags); |
913 | 972 | ||
914 | transport_unregister_device(&conn->dev); | 973 | transport_unregister_device(&conn->dev); |
974 | ISCSI_DBG_TRANS_CONN(conn, "Completing conn destruction\n"); | ||
915 | device_unregister(&conn->dev); | 975 | device_unregister(&conn->dev); |
916 | return 0; | 976 | return 0; |
917 | } | 977 | } |
@@ -1200,6 +1260,9 @@ int iscsi_session_event(struct iscsi_cls_session *session, | |||
1200 | "Cannot notify userspace of session " | 1260 | "Cannot notify userspace of session " |
1201 | "event %u. Check iscsi daemon\n", | 1261 | "event %u. Check iscsi daemon\n", |
1202 | event); | 1262 | event); |
1263 | |||
1264 | ISCSI_DBG_TRANS_SESSION(session, "Completed handling event %d rc %d\n", | ||
1265 | event, rc); | ||
1203 | return rc; | 1266 | return rc; |
1204 | } | 1267 | } |
1205 | EXPORT_SYMBOL_GPL(iscsi_session_event); | 1268 | EXPORT_SYMBOL_GPL(iscsi_session_event); |
@@ -1221,6 +1284,8 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep, | |||
1221 | shost = iscsi_session_to_shost(session); | 1284 | shost = iscsi_session_to_shost(session); |
1222 | ev->r.c_session_ret.host_no = shost->host_no; | 1285 | ev->r.c_session_ret.host_no = shost->host_no; |
1223 | ev->r.c_session_ret.sid = session->sid; | 1286 | ev->r.c_session_ret.sid = session->sid; |
1287 | ISCSI_DBG_TRANS_SESSION(session, | ||
1288 | "Completed creating transport session\n"); | ||
1224 | return 0; | 1289 | return 0; |
1225 | } | 1290 | } |
1226 | 1291 | ||
@@ -1246,6 +1311,8 @@ iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) | |||
1246 | 1311 | ||
1247 | ev->r.c_conn_ret.sid = session->sid; | 1312 | ev->r.c_conn_ret.sid = session->sid; |
1248 | ev->r.c_conn_ret.cid = conn->cid; | 1313 | ev->r.c_conn_ret.cid = conn->cid; |
1314 | |||
1315 | ISCSI_DBG_TRANS_CONN(conn, "Completed creating transport conn\n"); | ||
1249 | return 0; | 1316 | return 0; |
1250 | } | 1317 | } |
1251 | 1318 | ||
@@ -1258,8 +1325,10 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev | |||
1258 | if (!conn) | 1325 | if (!conn) |
1259 | return -EINVAL; | 1326 | return -EINVAL; |
1260 | 1327 | ||
1328 | ISCSI_DBG_TRANS_CONN(conn, "Destroying transport conn\n"); | ||
1261 | if (transport->destroy_conn) | 1329 | if (transport->destroy_conn) |
1262 | transport->destroy_conn(conn); | 1330 | transport->destroy_conn(conn); |
1331 | |||
1263 | return 0; | 1332 | return 0; |
1264 | } | 1333 | } |
1265 | 1334 | ||