aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2009-03-05 15:45:59 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-03-13 16:27:29 -0400
commit0ab1c2529e6a70e1b3c63fe9c6b41d4049758a8e (patch)
treeba6356562bcff4c4ff6ed22cf6827c20daa50900 /drivers
parent1b2c7af877f427a2b25583c9033616c9ebd30aed (diff)
[SCSI] libiscsi_tcp: replace tcp_debug/scsi_debug logging with session/conn logging
This makes the logging a compile time option and replaces the scsi_debug and tcp_debug macro with session and connection ones that print out a driver model id prefix. 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_tcp.c122
1 files changed, 62 insertions, 60 deletions
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index e7705d3532c9..91f8ce4d8d08 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -49,13 +49,21 @@ MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, "
49 "Alex Aizman <itn780@yahoo.com>"); 49 "Alex Aizman <itn780@yahoo.com>");
50MODULE_DESCRIPTION("iSCSI/TCP data-path"); 50MODULE_DESCRIPTION("iSCSI/TCP data-path");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52#undef DEBUG_TCP
53 52
54#ifdef DEBUG_TCP 53static int iscsi_dbg_libtcp;
55#define debug_tcp(fmt...) printk(KERN_INFO "tcp: " fmt) 54module_param_named(debug_libiscsi_tcp, iscsi_dbg_libtcp, int,
56#else 55 S_IRUGO | S_IWUSR);
57#define debug_tcp(fmt...) 56MODULE_PARM_DESC(debug_libiscsi_tcp, "Turn on debugging for libiscsi_tcp "
58#endif 57 "module. Set to 1 to turn on, and zero to turn off. Default "
58 "is off.");
59
60#define ISCSI_DBG_TCP(_conn, dbg_fmt, arg...) \
61 do { \
62 if (iscsi_dbg_libtcp) \
63 iscsi_conn_printk(KERN_INFO, _conn, \
64 "%s " dbg_fmt, \
65 __func__, ##arg); \
66 } while (0);
59 67
60static int iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn, 68static int iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
61 struct iscsi_segment *segment); 69 struct iscsi_segment *segment);
@@ -123,18 +131,13 @@ static void iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv)
123 if (page_count(sg_page(sg)) >= 1 && !recv) 131 if (page_count(sg_page(sg)) >= 1 && !recv)
124 return; 132 return;
125 133
126 debug_tcp("iscsi_tcp_segment_map %s %p\n", recv ? "recv" : "xmit",
127 segment);
128 segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0); 134 segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0);
129 segment->data = segment->sg_mapped + sg->offset + segment->sg_offset; 135 segment->data = segment->sg_mapped + sg->offset + segment->sg_offset;
130} 136}
131 137
132void iscsi_tcp_segment_unmap(struct iscsi_segment *segment) 138void iscsi_tcp_segment_unmap(struct iscsi_segment *segment)
133{ 139{
134 debug_tcp("iscsi_tcp_segment_unmap %p\n", segment);
135
136 if (segment->sg_mapped) { 140 if (segment->sg_mapped) {
137 debug_tcp("iscsi_tcp_segment_unmap valid\n");
138 kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0); 141 kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0);
139 segment->sg_mapped = NULL; 142 segment->sg_mapped = NULL;
140 segment->data = NULL; 143 segment->data = NULL;
@@ -180,8 +183,9 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
180 struct scatterlist sg; 183 struct scatterlist sg;
181 unsigned int pad; 184 unsigned int pad;
182 185
183 debug_tcp("copied %u %u size %u %s\n", segment->copied, copied, 186 ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "copied %u %u size %u %s\n",
184 segment->size, recv ? "recv" : "xmit"); 187 segment->copied, copied, segment->size,
188 recv ? "recv" : "xmit");
185 if (segment->hash && copied) { 189 if (segment->hash && copied) {
186 /* 190 /*
187 * If a segment is kmapd we must unmap it before sending 191 * If a segment is kmapd we must unmap it before sending
@@ -214,8 +218,8 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
214 iscsi_tcp_segment_unmap(segment); 218 iscsi_tcp_segment_unmap(segment);
215 219
216 /* Do we have more scatterlist entries? */ 220 /* Do we have more scatterlist entries? */
217 debug_tcp("total copied %u total size %u\n", segment->total_copied, 221 ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "total copied %u total size %u\n",
218 segment->total_size); 222 segment->total_copied, segment->total_size);
219 if (segment->total_copied < segment->total_size) { 223 if (segment->total_copied < segment->total_size) {
220 /* Proceed to the next entry in the scatterlist. */ 224 /* Proceed to the next entry in the scatterlist. */
221 iscsi_tcp_segment_init_sg(segment, sg_next(segment->sg), 225 iscsi_tcp_segment_init_sg(segment, sg_next(segment->sg),
@@ -229,7 +233,8 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
229 if (!(tcp_conn->iscsi_conn->session->tt->caps & CAP_PADDING_OFFLOAD)) { 233 if (!(tcp_conn->iscsi_conn->session->tt->caps & CAP_PADDING_OFFLOAD)) {
230 pad = iscsi_padding(segment->total_copied); 234 pad = iscsi_padding(segment->total_copied);
231 if (pad != 0) { 235 if (pad != 0) {
232 debug_tcp("consume %d pad bytes\n", pad); 236 ISCSI_DBG_TCP(tcp_conn->iscsi_conn,
237 "consume %d pad bytes\n", pad);
233 segment->total_size += pad; 238 segment->total_size += pad;
234 segment->size = pad; 239 segment->size = pad;
235 segment->data = segment->padbuf; 240 segment->data = segment->padbuf;
@@ -278,13 +283,13 @@ iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn,
278 283
279 while (!iscsi_tcp_segment_done(tcp_conn, segment, 1, copy)) { 284 while (!iscsi_tcp_segment_done(tcp_conn, segment, 1, copy)) {
280 if (copied == len) { 285 if (copied == len) {
281 debug_tcp("iscsi_tcp_segment_recv copied %d bytes\n", 286 ISCSI_DBG_TCP(tcp_conn->iscsi_conn,
282 len); 287 "copied %d bytes\n", len);
283 break; 288 break;
284 } 289 }
285 290
286 copy = min(len - copied, segment->size - segment->copied); 291 copy = min(len - copied, segment->size - segment->copied);
287 debug_tcp("iscsi_tcp_segment_recv copying %d\n", copy); 292 ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "copying %d\n", copy);
288 memcpy(segment->data + segment->copied, ptr + copied, copy); 293 memcpy(segment->data + segment->copied, ptr + copied, copy);
289 copied += copy; 294 copied += copy;
290 } 295 }
@@ -311,7 +316,7 @@ iscsi_tcp_dgst_verify(struct iscsi_tcp_conn *tcp_conn,
311 316
312 if (memcmp(segment->recv_digest, segment->digest, 317 if (memcmp(segment->recv_digest, segment->digest,
313 segment->digest_len)) { 318 segment->digest_len)) {
314 debug_scsi("digest mismatch\n"); 319 ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "digest mismatch\n");
315 return 0; 320 return 0;
316 } 321 }
317 322
@@ -355,12 +360,8 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment,
355 struct scatterlist *sg; 360 struct scatterlist *sg;
356 unsigned int i; 361 unsigned int i;
357 362
358 debug_scsi("iscsi_segment_seek_sg offset %u size %llu\n",
359 offset, size);
360 __iscsi_segment_init(segment, size, done, hash); 363 __iscsi_segment_init(segment, size, done, hash);
361 for_each_sg(sg_list, sg, sg_count, i) { 364 for_each_sg(sg_list, sg, sg_count, i) {
362 debug_scsi("sg %d, len %u offset %u\n", i, sg->length,
363 sg->offset);
364 if (offset < sg->length) { 365 if (offset < sg->length) {
365 iscsi_tcp_segment_init_sg(segment, sg, offset); 366 iscsi_tcp_segment_init_sg(segment, sg, offset);
366 return 0; 367 return 0;
@@ -382,8 +383,9 @@ EXPORT_SYMBOL_GPL(iscsi_segment_seek_sg);
382 */ 383 */
383void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn) 384void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn)
384{ 385{
385 debug_tcp("iscsi_tcp_hdr_recv_prep(%p%s)\n", tcp_conn, 386 ISCSI_DBG_TCP(tcp_conn->iscsi_conn,
386 tcp_conn->iscsi_conn->hdrdgst_en ? ", digest enabled" : ""); 387 "(%s)\n", tcp_conn->iscsi_conn->hdrdgst_en ?
388 "digest enabled" : "digest disabled");
387 iscsi_segment_init_linear(&tcp_conn->in.segment, 389 iscsi_segment_init_linear(&tcp_conn->in.segment,
388 tcp_conn->in.hdr_buf, sizeof(struct iscsi_hdr), 390 tcp_conn->in.hdr_buf, sizeof(struct iscsi_hdr),
389 iscsi_tcp_hdr_recv_done, NULL); 391 iscsi_tcp_hdr_recv_done, NULL);
@@ -446,7 +448,7 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
446 while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) { 448 while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
447 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, 449 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
448 sizeof(void*)); 450 sizeof(void*));
449 debug_scsi("iscsi_tcp_cleanup_task pending r2t dropped\n"); 451 ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
450 } 452 }
451 453
452 r2t = tcp_task->r2t; 454 r2t = tcp_task->r2t;
@@ -476,8 +478,8 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
476 return 0; 478 return 0;
477 479
478 if (tcp_task->exp_datasn != datasn) { 480 if (tcp_task->exp_datasn != datasn) {
479 debug_tcp("%s: task->exp_datasn(%d) != rhdr->datasn(%d)\n", 481 ISCSI_DBG_TCP(conn, "task->exp_datasn(%d) != rhdr->datasn(%d)"
480 __func__, tcp_task->exp_datasn, datasn); 482 "\n", tcp_task->exp_datasn, datasn);
481 return ISCSI_ERR_DATASN; 483 return ISCSI_ERR_DATASN;
482 } 484 }
483 485
@@ -485,9 +487,9 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
485 487
486 tcp_task->data_offset = be32_to_cpu(rhdr->offset); 488 tcp_task->data_offset = be32_to_cpu(rhdr->offset);
487 if (tcp_task->data_offset + tcp_conn->in.datalen > total_in_length) { 489 if (tcp_task->data_offset + tcp_conn->in.datalen > total_in_length) {
488 debug_tcp("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n", 490 ISCSI_DBG_TCP(conn, "data_offset(%d) + data_len(%d) > "
489 __func__, tcp_task->data_offset, 491 "total_length_in(%d)\n", tcp_task->data_offset,
490 tcp_conn->in.datalen, total_in_length); 492 tcp_conn->in.datalen, total_in_length);
491 return ISCSI_ERR_DATA_OFFSET; 493 return ISCSI_ERR_DATA_OFFSET;
492 } 494 }
493 495
@@ -518,8 +520,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
518 } 520 }
519 521
520 if (tcp_task->exp_datasn != r2tsn){ 522 if (tcp_task->exp_datasn != r2tsn){
521 debug_tcp("%s: task->exp_datasn(%d) != rhdr->r2tsn(%d)\n", 523 ISCSI_DBG_TCP(conn, "task->exp_datasn(%d) != rhdr->r2tsn(%d)\n",
522 __func__, tcp_task->exp_datasn, r2tsn); 524 tcp_task->exp_datasn, r2tsn);
523 return ISCSI_ERR_R2TSN; 525 return ISCSI_ERR_R2TSN;
524 } 526 }
525 527
@@ -552,9 +554,9 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
552 } 554 }
553 555
554 if (r2t->data_length > session->max_burst) 556 if (r2t->data_length > session->max_burst)
555 debug_scsi("invalid R2T with data len %u and max burst %u." 557 ISCSI_DBG_TCP(conn, "invalid R2T with data len %u and max "
556 "Attempting to execute request.\n", 558 "burst %u. Attempting to execute request.\n",
557 r2t->data_length, session->max_burst); 559 r2t->data_length, session->max_burst);
558 560
559 r2t->data_offset = be32_to_cpu(rhdr->data_offset); 561 r2t->data_offset = be32_to_cpu(rhdr->data_offset);
560 if (r2t->data_offset + r2t->data_length > scsi_out(task->sc)->length) { 562 if (r2t->data_offset + r2t->data_length > scsi_out(task->sc)->length) {
@@ -641,8 +643,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
641 if (rc) 643 if (rc)
642 return rc; 644 return rc;
643 645
644 debug_tcp("opcode 0x%x ahslen %d datalen %d\n", 646 ISCSI_DBG_TCP(conn, "opcode 0x%x ahslen %d datalen %d\n",
645 opcode, ahslen, tcp_conn->in.datalen); 647 opcode, ahslen, tcp_conn->in.datalen);
646 648
647 switch(opcode) { 649 switch(opcode) {
648 case ISCSI_OP_SCSI_DATA_IN: 650 case ISCSI_OP_SCSI_DATA_IN:
@@ -674,10 +676,10 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
674 !(conn->session->tt->caps & CAP_DIGEST_OFFLOAD)) 676 !(conn->session->tt->caps & CAP_DIGEST_OFFLOAD))
675 rx_hash = tcp_conn->rx_hash; 677 rx_hash = tcp_conn->rx_hash;
676 678
677 debug_tcp("iscsi_tcp_begin_data_in(%p, offset=%d, " 679 ISCSI_DBG_TCP(conn, "iscsi_tcp_begin_data_in( "
678 "datalen=%d)\n", tcp_conn, 680 "offset=%d, datalen=%d)\n",
679 tcp_task->data_offset, 681 tcp_task->data_offset,
680 tcp_conn->in.datalen); 682 tcp_conn->in.datalen);
681 rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, 683 rc = iscsi_segment_seek_sg(&tcp_conn->in.segment,
682 sdb->table.sgl, 684 sdb->table.sgl,
683 sdb->table.nents, 685 sdb->table.nents,
@@ -854,10 +856,10 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
854 unsigned int consumed = 0; 856 unsigned int consumed = 0;
855 int rc = 0; 857 int rc = 0;
856 858
857 debug_tcp("in %d bytes\n", skb->len - offset); 859 ISCSI_DBG_TCP(conn, "in %d bytes\n", skb->len - offset);
858 860
859 if (unlikely(conn->suspend_rx)) { 861 if (unlikely(conn->suspend_rx)) {
860 debug_tcp("conn %d Rx suspended!\n", conn->id); 862 ISCSI_DBG_TCP(conn, "Rx suspended!\n");
861 *status = ISCSI_TCP_SUSPENDED; 863 *status = ISCSI_TCP_SUSPENDED;
862 return 0; 864 return 0;
863 } 865 }
@@ -874,15 +876,16 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
874 876
875 avail = skb_seq_read(consumed, &ptr, &seq); 877 avail = skb_seq_read(consumed, &ptr, &seq);
876 if (avail == 0) { 878 if (avail == 0) {
877 debug_tcp("no more data avail. Consumed %d\n", 879 ISCSI_DBG_TCP(conn, "no more data avail. Consumed %d\n",
878 consumed); 880 consumed);
879 *status = ISCSI_TCP_SKB_DONE; 881 *status = ISCSI_TCP_SKB_DONE;
880 skb_abort_seq_read(&seq); 882 skb_abort_seq_read(&seq);
881 goto skb_done; 883 goto skb_done;
882 } 884 }
883 BUG_ON(segment->copied >= segment->size); 885 BUG_ON(segment->copied >= segment->size);
884 886
885 debug_tcp("skb %p ptr=%p avail=%u\n", skb, ptr, avail); 887 ISCSI_DBG_TCP(conn, "skb %p ptr=%p avail=%u\n", skb, ptr,
888 avail);
886 rc = iscsi_tcp_segment_recv(tcp_conn, segment, ptr, avail); 889 rc = iscsi_tcp_segment_recv(tcp_conn, segment, ptr, avail);
887 BUG_ON(rc == 0); 890 BUG_ON(rc == 0);
888 consumed += rc; 891 consumed += rc;
@@ -895,11 +898,11 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
895 898
896segment_done: 899segment_done:
897 *status = ISCSI_TCP_SEGMENT_DONE; 900 *status = ISCSI_TCP_SEGMENT_DONE;
898 debug_tcp("segment done\n"); 901 ISCSI_DBG_TCP(conn, "segment done\n");
899 rc = segment->done(tcp_conn, segment); 902 rc = segment->done(tcp_conn, segment);
900 if (rc != 0) { 903 if (rc != 0) {
901 *status = ISCSI_TCP_CONN_ERR; 904 *status = ISCSI_TCP_CONN_ERR;
902 debug_tcp("Error receiving PDU, errno=%d\n", rc); 905 ISCSI_DBG_TCP(conn, "Error receiving PDU, errno=%d\n", rc);
903 iscsi_conn_failure(conn, rc); 906 iscsi_conn_failure(conn, rc);
904 return 0; 907 return 0;
905 } 908 }
@@ -929,8 +932,7 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
929 * mgmt tasks do not have a scatterlist since they come 932 * mgmt tasks do not have a scatterlist since they come
930 * in from the iscsi interface. 933 * in from the iscsi interface.
931 */ 934 */
932 debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, 935 ISCSI_DBG_TCP(conn, "mtask deq [itt 0x%x]\n", task->itt);
933 task->itt);
934 936
935 return conn->session->tt->init_pdu(task, 0, task->data_count); 937 return conn->session->tt->init_pdu(task, 0, task->data_count);
936 } 938 }
@@ -939,9 +941,8 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
939 tcp_task->exp_datasn = 0; 941 tcp_task->exp_datasn = 0;
940 942
941 /* Prepare PDU, optionally w/ immediate data */ 943 /* Prepare PDU, optionally w/ immediate data */
942 debug_scsi("task deq [cid %d itt 0x%x imm %d unsol %d]\n", 944 ISCSI_DBG_TCP(conn, "task deq [itt 0x%x imm %d unsol %d]\n",
943 conn->id, task->itt, task->imm_count, 945 task->itt, task->imm_count, task->unsol_r2t.data_length);
944 task->unsol_r2t.data_length);
945 946
946 err = conn->session->tt->init_pdu(task, 0, task->imm_count); 947 err = conn->session->tt->init_pdu(task, 0, task->imm_count);
947 if (err) 948 if (err)
@@ -965,7 +966,8 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
965 r2t = tcp_task->r2t; 966 r2t = tcp_task->r2t;
966 /* Continue with this R2T? */ 967 /* Continue with this R2T? */
967 if (r2t->data_length <= r2t->sent) { 968 if (r2t->data_length <= r2t->sent) {
968 debug_scsi(" done with r2t %p\n", r2t); 969 ISCSI_DBG_TCP(task->conn,
970 " done with r2t %p\n", r2t);
969 __kfifo_put(tcp_task->r2tpool.queue, 971 __kfifo_put(tcp_task->r2tpool.queue,
970 (void *)&tcp_task->r2t, 972 (void *)&tcp_task->r2t,
971 sizeof(void *)); 973 sizeof(void *));
@@ -1019,7 +1021,7 @@ flush:
1019 r2t = iscsi_tcp_get_curr_r2t(task); 1021 r2t = iscsi_tcp_get_curr_r2t(task);
1020 if (r2t == NULL) { 1022 if (r2t == NULL) {
1021 /* Waiting for more R2Ts to arrive. */ 1023 /* Waiting for more R2Ts to arrive. */
1022 debug_tcp("no R2Ts yet\n"); 1024 ISCSI_DBG_TCP(conn, "no R2Ts yet\n");
1023 return 0; 1025 return 0;
1024 } 1026 }
1025 1027
@@ -1028,9 +1030,9 @@ flush:
1028 return rc; 1030 return rc;
1029 iscsi_prep_data_out_pdu(task, r2t, (struct iscsi_data *) task->hdr); 1031 iscsi_prep_data_out_pdu(task, r2t, (struct iscsi_data *) task->hdr);
1030 1032
1031 debug_scsi("sol dout %p [dsn %d itt 0x%x doff %d dlen %d]\n", 1033 ISCSI_DBG_TCP(conn, "sol dout %p [dsn %d itt 0x%x doff %d dlen %d]\n",
1032 r2t, r2t->datasn - 1, task->hdr->itt, 1034 r2t, r2t->datasn - 1, task->hdr->itt,
1033 r2t->data_offset + r2t->sent, r2t->data_count); 1035 r2t->data_offset + r2t->sent, r2t->data_count);
1034 1036
1035 rc = conn->session->tt->init_pdu(task, r2t->data_offset + r2t->sent, 1037 rc = conn->session->tt->init_pdu(task, r2t->data_offset + r2t->sent,
1036 r2t->data_count); 1038 r2t->data_count);