svn commit: r256197 - head/sys/cam/ctl

Edward Tomasz Napierala trasz at FreeBSD.org
Wed Oct 9 17:06:05 UTC 2013


Author: trasz
Date: Wed Oct  9 17:06:03 2013
New Revision: 256197
URL: http://svnweb.freebsd.org/changeset/base/256197

Log:
  Make the error handling more consistant.  Shouldn't make any functional
  difference.
  
  Approved by:	re (gjb)
  Sponsored by:	FreeBSD Foundation

Modified:
  head/sys/cam/ctl/ctl_frontend_iscsi.c

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c	Wed Oct  9 17:05:02 2013	(r256196)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c	Wed Oct  9 17:06:03 2013	(r256197)
@@ -288,8 +288,8 @@ cfiscsi_pdu_handle(struct icl_pdu *reque
 		CFISCSI_SESSION_WARN(cs, "received PDU with unsupported "
 		    "opcode 0x%x; dropping connection",
 		    request->ip_bhs->bhs_opcode);
-		cfiscsi_session_terminate(cs);
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 	}
 
 }
@@ -532,14 +532,16 @@ cfiscsi_pdu_handle_scsi_command(struct i
 	if (request->ip_data_len > 0 && cs->cs_immediate_data == false) {
 		CFISCSI_SESSION_WARN(cs, "unsolicited data with "
 		    "ImmediateData=No; dropping connection");
-		cfiscsi_session_terminate(cs);
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 		return;
 	}
 	io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
 	if (io == NULL) {
-		CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
+		CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io; "
+		    "dropping connection");
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 		return;
 	}
 	ctl_zero_io(io);
@@ -579,10 +581,12 @@ cfiscsi_pdu_handle_scsi_command(struct i
 	refcount_acquire(&cs->cs_outstanding_ctl_pdus);
 	error = ctl_queue(io);
 	if (error != CTL_RETVAL_COMPLETE) {
-		CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error);
+		CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d; "
+		    "dropping connection", error);
 		ctl_free_io(io);
 		refcount_release(&cs->cs_outstanding_ctl_pdus);
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 	}
 }
 
@@ -600,8 +604,10 @@ cfiscsi_pdu_handle_task_request(struct i
 	bhstmr = (struct iscsi_bhs_task_management_request *)request->ip_bhs;
 	io = ctl_alloc_io(cs->cs_target->ct_softc->fe.ctl_pool_ref);
 	if (io == NULL) {
-		CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io");
+		CFISCSI_SESSION_WARN(cs, "can't allocate ctl_io;"
+		    "dropping connection");
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 		return;
 	}
 	ctl_zero_io(io);
@@ -642,7 +648,10 @@ cfiscsi_pdu_handle_task_request(struct i
 
 		response = cfiscsi_pdu_new_response(request, M_NOWAIT);
 		if (response == NULL) {
+			CFISCSI_SESSION_WARN(cs, "failed to allocate memory; "
+			    "dropping connection");
 			icl_pdu_free(request);
+			cfiscsi_session_terminate(cs);
 			return;
 		}
 		bhstmr2 = (struct iscsi_bhs_task_management_response *)
@@ -661,10 +670,12 @@ cfiscsi_pdu_handle_task_request(struct i
 	refcount_acquire(&cs->cs_outstanding_ctl_pdus);
 	error = ctl_queue(io);
 	if (error != CTL_RETVAL_COMPLETE) {
-		CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d", error);
+		CFISCSI_SESSION_WARN(cs, "ctl_queue() failed; error %d; "
+		    "dropping connection", error);
 		ctl_free_io(io);
 		refcount_release(&cs->cs_outstanding_ctl_pdus);
 		icl_pdu_free(request);
+		cfiscsi_session_terminate(cs);
 	}
 }
 
@@ -859,8 +870,8 @@ cfiscsi_pdu_handle_data_out(struct icl_p
 	CFISCSI_SESSION_UNLOCK(cs);
 	if (cdw == NULL) {
 		CFISCSI_SESSION_WARN(cs, "data transfer tag 0x%x, initiator task tag "
-		    "0x%x, not found", bhsdo->bhsdo_target_transfer_tag,
-		    bhsdo->bhsdo_initiator_task_tag);
+		    "0x%x, not found; dropping connection",
+		    bhsdo->bhsdo_target_transfer_tag, bhsdo->bhsdo_initiator_task_tag);
 		icl_pdu_free(request);
 		cfiscsi_session_terminate(cs);
 		return;
@@ -897,6 +908,7 @@ cfiscsi_pdu_handle_logout_request(struct
 	case BHSLR_REASON_CLOSE_CONNECTION:
 		response = cfiscsi_pdu_new_response(request, M_NOWAIT);
 		if (response == NULL) {
+			CFISCSI_SESSION_DEBUG(cs, "failed to allocate memory");
 			icl_pdu_free(request);
 			cfiscsi_session_terminate(cs);
 			return;
@@ -914,6 +926,8 @@ cfiscsi_pdu_handle_logout_request(struct
 	case BHSLR_REASON_REMOVE_FOR_RECOVERY:
 		response = cfiscsi_pdu_new_response(request, M_NOWAIT);
 		if (response == NULL) {
+			CFISCSI_SESSION_WARN(cs,
+			    "failed to allocate memory; dropping connection");
 			icl_pdu_free(request);
 			cfiscsi_session_terminate(cs);
 			return;
@@ -985,7 +999,7 @@ cfiscsi_callout(void *context)
 
 	cp = icl_pdu_new_bhs(cs->cs_conn, M_NOWAIT);
 	if (cp == NULL) {
-		CFISCSI_SESSION_WARN(cs, "failed to allocate PDU");
+		CFISCSI_SESSION_WARN(cs, "failed to allocate memory");
 		return;
 	}
 	bhsni = (struct iscsi_bhs_nop_in *)cp->ip_bhs;


More information about the svn-src-head mailing list