Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] iscsi_tcp: replace scsi_debug/tcp_debug logging with iscsi conn logging

This makes the logging a compile time option and replaces
the tcp_debug macro with a iscsi connection one that prints
out a driver model id prefix.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Mike Christie and committed by
James Bottomley
c93f87c7 0ab1c252

+34 -23
+34 -23
drivers/scsi/iscsi_tcp.c
··· 48 48 "Alex Aizman <itn780@yahoo.com>"); 49 49 MODULE_DESCRIPTION("iSCSI/TCP data-path"); 50 50 MODULE_LICENSE("GPL"); 51 - #undef DEBUG_TCP 52 - 53 - #ifdef DEBUG_TCP 54 - #define debug_tcp(fmt...) printk(KERN_INFO "tcp: " fmt) 55 - #else 56 - #define debug_tcp(fmt...) 57 - #endif 58 51 59 52 static struct scsi_transport_template *iscsi_sw_tcp_scsi_transport; 60 53 static struct scsi_host_template iscsi_sw_tcp_sht; ··· 55 62 56 63 static unsigned int iscsi_max_lun = 512; 57 64 module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO); 65 + 66 + static int iscsi_sw_tcp_dbg; 67 + module_param_named(debug_iscsi_tcp, iscsi_sw_tcp_dbg, int, 68 + S_IRUGO | S_IWUSR); 69 + MODULE_PARM_DESC(debug_iscsi_tcp, "Turn on debugging for iscsi_tcp module " 70 + "Set to 1 to turn on, and zero to turn off. Default is off."); 71 + 72 + #define ISCSI_SW_TCP_DBG(_conn, dbg_fmt, arg...) \ 73 + do { \ 74 + if (iscsi_sw_tcp_dbg) \ 75 + iscsi_conn_printk(KERN_INFO, _conn, \ 76 + "%s " dbg_fmt, \ 77 + __func__, ##arg); \ 78 + } while (0); 79 + 58 80 59 81 /** 60 82 * iscsi_sw_tcp_recv - TCP receive in sendfile fashion ··· 85 77 unsigned int consumed, total_consumed = 0; 86 78 int status; 87 79 88 - debug_tcp("in %d bytes\n", skb->len - offset); 80 + ISCSI_SW_TCP_DBG(conn, "in %d bytes\n", skb->len - offset); 89 81 90 82 do { 91 83 status = 0; ··· 94 86 total_consumed += consumed; 95 87 } while (consumed != 0 && status != ISCSI_TCP_SKB_DONE); 96 88 97 - debug_tcp("read %d bytes status %d\n", skb->len - offset, status); 89 + ISCSI_SW_TCP_DBG(conn, "read %d bytes status %d\n", 90 + skb->len - offset, status); 98 91 return total_consumed; 99 92 } 100 93 ··· 140 131 if ((sk->sk_state == TCP_CLOSE_WAIT || 141 132 sk->sk_state == TCP_CLOSE) && 142 133 !atomic_read(&sk->sk_rmem_alloc)) { 143 - debug_tcp("iscsi_tcp_state_change: TCP_CLOSE|TCP_CLOSE_WAIT\n"); 134 + ISCSI_SW_TCP_DBG(conn, "iscsi_tcp_state_change: " 135 + "TCP_CLOSE|TCP_CLOSE_WAIT\n"); 144 136 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 145 137 } 146 138 ··· 165 155 struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; 166 156 167 157 tcp_sw_conn->old_write_space(sk); 168 - debug_tcp("iscsi_write_space: cid %d\n", conn->id); 158 + ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n"); 169 159 scsi_queue_work(conn->session->host, &conn->xmitwork); 170 160 } 171 161 ··· 293 283 } 294 284 } 295 285 296 - debug_tcp("xmit %d bytes\n", consumed); 286 + ISCSI_SW_TCP_DBG(conn, "xmit %d bytes\n", consumed); 297 287 298 288 conn->txdata_octets += consumed; 299 289 return consumed; ··· 301 291 error: 302 292 /* Transmit error. We could initiate error recovery 303 293 * here. */ 304 - debug_tcp("Error sending PDU, errno=%d\n", rc); 294 + ISCSI_SW_TCP_DBG(conn, "Error sending PDU, errno=%d\n", rc); 305 295 iscsi_conn_failure(conn, rc); 306 296 return -EIO; 307 297 } ··· 344 334 struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; 345 335 346 336 tcp_sw_conn->out.segment = tcp_sw_conn->out.data_segment; 347 - debug_tcp("Header done. Next segment size %u total_size %u\n", 348 - tcp_sw_conn->out.segment.size, 349 - tcp_sw_conn->out.segment.total_size); 337 + ISCSI_SW_TCP_DBG(tcp_conn->iscsi_conn, 338 + "Header done. Next segment size %u total_size %u\n", 339 + tcp_sw_conn->out.segment.size, 340 + tcp_sw_conn->out.segment.total_size); 350 341 return 0; 351 342 } 352 343 ··· 357 346 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 358 347 struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; 359 348 360 - debug_tcp("%s(%p%s)\n", __func__, tcp_conn, 361 - conn->hdrdgst_en? ", digest enabled" : ""); 349 + ISCSI_SW_TCP_DBG(conn, "%s\n", conn->hdrdgst_en ? 350 + "digest enabled" : "digest disabled"); 362 351 363 352 /* Clear the data segment - needs to be filled in by the 364 353 * caller using iscsi_tcp_send_data_prep() */ ··· 400 389 struct hash_desc *tx_hash = NULL; 401 390 unsigned int hdr_spec_len; 402 391 403 - debug_tcp("%s(%p, offset=%d, datalen=%d%s)\n", __func__, 404 - tcp_conn, offset, len, 405 - conn->datadgst_en? ", digest enabled" : ""); 392 + ISCSI_SW_TCP_DBG(conn, "offset=%d, datalen=%d %s\n", offset, len, 393 + conn->datadgst_en ? 394 + "digest enabled" : "digest disabled"); 406 395 407 396 /* Make sure the datalen matches what the caller 408 397 said he would send. */ ··· 426 415 struct hash_desc *tx_hash = NULL; 427 416 unsigned int hdr_spec_len; 428 417 429 - debug_tcp("%s(%p, datalen=%d%s)\n", __func__, tcp_conn, len, 430 - conn->datadgst_en? ", digest enabled" : ""); 418 + ISCSI_SW_TCP_DBG(conn, "datalen=%zd %s\n", len, conn->datadgst_en ? 419 + "digest enabled" : "digest disabled"); 431 420 432 421 /* Make sure the datalen matches what the caller 433 422 said he would send. */