ソースを参照

Use debug auto-colourisation.

tags/v0.9.3
Michael Brown 18年前
コミット
6ea07b9247
1個のファイルの変更47行の追加42行の削除
  1. 47
    42
      src/net/tcp/iscsi.c

+ 47
- 42
src/net/tcp/iscsi.c ファイルの表示

@@ -164,11 +164,11 @@ static void iscsi_start_command ( struct iscsi_session *iscsi ) {
164 164
 	command->cmdsn = htonl ( iscsi->cmdsn );
165 165
 	command->expstatsn = htonl ( iscsi->statsn + 1 );
166 166
 	memcpy ( &command->cdb, &iscsi->command->cdb, sizeof ( command->cdb ));
167
-	DBG ( "iSCSI %p start " SCSI_CDB_FORMAT " %s %#x\n",
168
-	      iscsi, SCSI_CDB_DATA ( command->cdb ),
169
-	      ( iscsi->command->data_in ? "in" : "out" ),
170
-	      ( iscsi->command->data_in ?
171
-		iscsi->command->data_in_len : iscsi->command->data_out_len ) );
167
+	DBGC ( iscsi, "iSCSI %p start " SCSI_CDB_FORMAT " %s %#x\n",
168
+	       iscsi, SCSI_CDB_DATA ( command->cdb ),
169
+	       ( iscsi->command->data_in ? "in" : "out" ),
170
+	       ( iscsi->command->data_in ?
171
+		 iscsi->command->data_in_len : iscsi->command->data_out_len ));
172 172
 }
173 173
 
174 174
 /**
@@ -296,8 +296,8 @@ static void iscsi_start_data_out ( struct iscsi_session *iscsi,
296 296
 	data_out->expstatsn = htonl ( iscsi->statsn + 1 );
297 297
 	data_out->datasn = htonl ( datasn );
298 298
 	data_out->offset = htonl ( iscsi->transfer_offset + offset );
299
-	DBG ( "iSCSI %p start data out DataSN %#x len %#lx\n",
300
-	      iscsi, datasn, len );
299
+	DBGC ( iscsi, "iSCSI %p start data out DataSN %#x len %#lx\n",
300
+	       iscsi, datasn, len );
301 301
 }
302 302
 
303 303
 /**
@@ -525,12 +525,12 @@ static void iscsi_handle_targetaddress_value ( struct iscsi_session *iscsi,
525 525
 	struct sockaddr_in *sin = ( struct sockaddr_in * ) &iscsi->target;
526 526
 
527 527
 	if ( inet_aton ( value, &address ) == 0 ) {
528
-		DBG ( "iSCSI %p received invalid TargetAddress \"%s\"\n",
529
-		      iscsi, value );
528
+		DBGC ( iscsi, "iSCSI %p received invalid TargetAddress "
529
+		       "\"%s\"\n", iscsi, value );
530 530
 		return;
531 531
 	}
532 532
 
533
-	DBG ( "iSCSI %p will redirect to %s\n", iscsi, value );
533
+	DBGC ( iscsi, "iSCSI %p will redirect to %s\n", iscsi, value );
534 534
 	sin->sin_addr = address;
535 535
 }
536 536
 
@@ -545,7 +545,8 @@ static void iscsi_handle_authmethod_value ( struct iscsi_session *iscsi,
545 545
 
546 546
 	/* If server requests CHAP, send the CHAP_A string */
547 547
 	if ( strcmp ( value, "CHAP" ) == 0 ) {
548
-		DBG ( "iSCSI %p initiating CHAP authentication\n", iscsi );
548
+		DBGC ( iscsi, "iSCSI %p initiating CHAP authentication\n",
549
+		       iscsi );
549 550
 		iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_ALGORITHM;
550 551
 	}
551 552
 }
@@ -565,13 +566,14 @@ static void iscsi_handle_chap_a_value ( struct iscsi_session *iscsi,
565 566
 	 * violation.
566 567
 	 */
567 568
 	if ( strcmp ( value, "5" ) != 0 ) {
568
-		DBG ( "iSCSI %p got invalid CHAP algorithm \"%s\"\n",
569
-		      iscsi, value );
569
+		DBGC ( iscsi, "iSCSI %p got invalid CHAP algorithm \"%s\"\n",
570
+		       iscsi, value );
570 571
 	}
571 572
 
572 573
 	/* Prepare for CHAP with MD5 */
573 574
 	if ( ( rc = chap_init ( &iscsi->chap, &md5_algorithm ) ) != 0 ) {
574
-		DBG ( "iSCSI %p could not initialise CHAP\n", iscsi );
575
+		DBGC ( iscsi, "iSCSI %p could not initialise CHAP: %s\n",
576
+		       iscsi, strerror ( rc ) );
575 577
 		iscsi_close ( iscsi );
576 578
 		iscsi_done ( iscsi, rc );
577 579
 	}
@@ -591,8 +593,8 @@ static void iscsi_handle_chap_i_value ( struct iscsi_session *iscsi,
591 593
 	/* The CHAP identifier is an integer value */
592 594
 	identifier = strtoul ( value, &endp, 0 );
593 595
 	if ( *endp != '\0' ) {
594
-		DBG ( "iSCSI %p saw invalid CHAP identifier \"%s\"\n",
595
-		      iscsi, value );
596
+		DBGC ( iscsi, "iSCSI %p saw invalid CHAP identifier \"%s\"\n",
597
+		       iscsi, value );
596 598
 	}
597 599
 
598 600
 	/* Identifier and secret are the first two components of the
@@ -619,8 +621,8 @@ static void iscsi_handle_chap_c_value ( struct iscsi_session *iscsi,
619 621
 
620 622
 	/* Check and strip leading "0x" */
621 623
 	if ( ( value[0] != '0' ) || ( value[1] != 'x' ) ) {
622
-		DBG ( "iSCSI %p saw invalid CHAP challenge \"%s\"\n",
623
-		      iscsi, value );
624
+		DBGC ( iscsi, "iSCSI %p saw invalid CHAP challenge \"%s\"\n",
625
+		       iscsi, value );
624 626
 	}
625 627
 	value += 2;
626 628
 
@@ -630,14 +632,14 @@ static void iscsi_handle_chap_c_value ( struct iscsi_session *iscsi,
630 632
 		buf[3] = 0;
631 633
 		byte = strtoul ( buf, &endp, 16 );
632 634
 		if ( *endp != '\0' ) {
633
-			DBG ( "iSCSI %p saw invalid CHAP challenge byte "
634
-			      "\"%s\"\n", iscsi, buf );
635
+			DBGC ( iscsi, "iSCSI %p saw invalid CHAP challenge "
636
+			       "byte \"%s\"\n", iscsi, buf );
635 637
 		}
636 638
 		chap_update ( &iscsi->chap, &byte, sizeof ( byte ) );
637 639
 	}
638 640
 
639 641
 	/* Build CHAP response */
640
-	DBG ( "iSCSI %p sending CHAP response\n", iscsi );
642
+	DBGC ( iscsi, "iSCSI %p sending CHAP response\n", iscsi );
641 643
 	chap_respond ( &iscsi->chap );
642 644
 	iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_RESPONSE;
643 645
 }
@@ -683,12 +685,13 @@ static void iscsi_handle_string ( struct iscsi_session *iscsi,
683 685
 	for ( type = iscsi_string_types ; type->key ; type++ ) {
684 686
 		key_len = strlen ( type->key );
685 687
 		if ( strncmp ( string, type->key, key_len ) == 0 ) {
686
-			DBG ( "iSCSI %p handling %s\n", iscsi, string );
688
+			DBGC ( iscsi, "iSCSI %p handling %s\n",
689
+			       iscsi, string );
687 690
 			type->handle_value ( iscsi, ( string + key_len ) );
688 691
 			return;
689 692
 		}
690 693
 	}
691
-	DBG ( "iSCSI %p ignoring %s\n", iscsi, string );
694
+	DBGC ( iscsi, "iSCSI %p ignoring %s\n", iscsi, string );
692 695
 }
693 696
 
694 697
 /**
@@ -732,7 +735,8 @@ static void iscsi_rx_login_response ( struct iscsi_session *iscsi, void *data,
732 735
 
733 736
 	/* Buffer up the PDU data */
734 737
 	if ( ( rc = iscsi_rx_buffered_data ( iscsi, data, len ) ) != 0 ) {
735
-		DBG ( "iSCSI %p could not buffer login response\n", iscsi );
738
+		DBGC ( iscsi, "iSCSI %p could not buffer login response: %s\n",
739
+		       iscsi, strerror ( rc ) );
736 740
 		iscsi_close ( iscsi );
737 741
 		iscsi_done ( iscsi, rc );
738 742
 		return;
@@ -746,12 +750,12 @@ static void iscsi_rx_login_response ( struct iscsi_session *iscsi, void *data,
746 750
 
747 751
 	/* Check for login redirection */
748 752
 	if ( response->status_class == ISCSI_STATUS_REDIRECT ) {
749
-		DBG ( "iSCSI %p redirecting to new server\n", iscsi );
753
+		DBGC ( iscsi, "iSCSI %p redirecting to new server\n", iscsi );
750 754
 		iscsi_close ( iscsi );
751 755
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
752 756
 					  0 ) ) != 0 ) {
753
-			DBG ( "iSCSI %p could not open TCP connection\n",
754
-			      iscsi );
757
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
758
+			       "connection: %s\n", iscsi, strerror ( rc ) );
755 759
 			iscsi_done ( iscsi, rc );
756 760
 		}
757 761
 		return;
@@ -759,8 +763,8 @@ static void iscsi_rx_login_response ( struct iscsi_session *iscsi, void *data,
759 763
 
760 764
 	/* Check for fatal errors */
761 765
 	if ( response->status_class != 0 ) {
762
-		DBG ( "iSCSI login failure: class %02x detail %02x\n",
763
-		      response->status_class, response->status_detail );
766
+		DBGC ( iscsi, "iSCSI login failure: class %02x detail %02x\n",
767
+		       response->status_class, response->status_detail );
764 768
 		iscsi->instant_rc = -EPERM;
765 769
 		iscsi_close ( iscsi );
766 770
 		iscsi_done ( iscsi, -EPERM );
@@ -779,8 +783,8 @@ static void iscsi_rx_login_response ( struct iscsi_session *iscsi, void *data,
779 783
 			iscsi->status = ISCSI_STATUS_FULL_FEATURE_PHASE;
780 784
 			break;
781 785
 		default:
782
-			DBG ( "iSCSI %p got invalid response flags %02x\n",
783
-			      iscsi, response->flags );
786
+			DBGC ( iscsi, "iSCSI %p got invalid response flags "
787
+			       "%02x\n", iscsi, response->flags );
784 788
 			iscsi_close ( iscsi );
785 789
 			iscsi_done ( iscsi, -EIO );
786 790
 			return;
@@ -1018,7 +1022,8 @@ static void iscsi_rx_data ( struct iscsi_session *iscsi, void *data,
1018 1022
 	default:
1019 1023
 		if ( remaining )
1020 1024
 			return;
1021
-		DBG ( "Unknown iSCSI opcode %02x\n", response->opcode );
1025
+		DBGC ( iscsi, "iSCSI %p unknown opcode %02x\n", iscsi,
1026
+		       response->opcode );
1022 1027
 		iscsi_close ( iscsi );
1023 1028
 		iscsi_done ( iscsi, -EOPNOTSUPP );
1024 1029
 		break;
@@ -1056,9 +1061,9 @@ static void iscsi_rx_bhs ( struct iscsi_session *iscsi, void *data,
1056 1061
 			   size_t len, size_t remaining __unused ) {
1057 1062
 	memcpy ( &iscsi->rx_bhs.bytes[iscsi->rx_offset], data, len );
1058 1063
 	if ( ( iscsi->rx_offset + len ) >= sizeof ( iscsi->rx_bhs ) ) {
1059
-		DBG ( "iSCSI %p received PDU opcode %#x len %#lx\n",
1060
-		      iscsi, iscsi->rx_bhs.common.opcode,
1061
-		      ISCSI_DATA_LEN ( iscsi->rx_bhs.common.lengths ) );
1064
+		DBGC ( iscsi, "iSCSI %p received PDU opcode %#x len %#lx\n",
1065
+		       iscsi, iscsi->rx_bhs.common.opcode,
1066
+		       ISCSI_DATA_LEN ( iscsi->rx_bhs.common.lengths ) );
1062 1067
 	}
1063 1068
 }
1064 1069
 
@@ -1154,15 +1159,15 @@ static void iscsi_closed ( struct tcp_application *app, int status ) {
1154 1159
 
1155 1160
 	/* Retry connection if within the retry limit, otherwise fail */
1156 1161
 	if ( ++iscsi->retry_count <= ISCSI_MAX_RETRIES ) {
1157
-		DBG ( "iSCSI %p retrying connection (retry #%d)\n",
1158
-		      iscsi, iscsi->retry_count );
1162
+		DBGC ( iscsi, "iSCSI %p retrying connection (retry #%d)\n",
1163
+		       iscsi, iscsi->retry_count );
1159 1164
 		if ( ( rc = tcp_connect ( app, &iscsi->target, 0 ) ) != 0 ) {
1160
-			DBG ( "iSCSI %p could not open TCP connection\n",
1161
-			      iscsi );
1165
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
1166
+			       "connection: %s\n", iscsi, strerror ( rc ) );
1162 1167
 			iscsi_done ( iscsi, rc );
1163 1168
 		}
1164 1169
 	} else {
1165
-		DBG ( "iSCSI %p retry count exceeded\n", iscsi );
1170
+		DBGC ( iscsi, "iSCSI %p retry count exceeded\n", iscsi );
1166 1171
 		iscsi->instant_rc = status;
1167 1172
 		iscsi_done ( iscsi, status );
1168 1173
 	}
@@ -1226,8 +1231,8 @@ struct async_operation * iscsi_issue ( struct iscsi_session *iscsi,
1226 1231
 		iscsi->tcp.tcp_op = &iscsi_tcp_operations;
1227 1232
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
1228 1233
 					  0 ) ) != 0 ) {
1229
-			DBG ( "iSCSI %p could not open TCP connection\n",
1230
-			      iscsi );
1234
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
1235
+			       "connection: %s\n", iscsi, strerror ( rc ) );
1231 1236
 			iscsi_done ( iscsi, rc );
1232 1237
 		}
1233 1238
 	}

読み込み中…
キャンセル
保存