Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Feb 2015 19:18:24 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r278398 - head/sys/cam/ctl
Message-ID:  <201502081918.t18JIODf050578@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sun Feb  8 19:18:23 2015
New Revision: 278398
URL: https://svnweb.freebsd.org/changeset/base/278398

Log:
  Fix ordering of "*logout" and "*terminate"; no functional changes.
  
  MFC after:	1 month
  Sponsored by:	The 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	Sun Feb  8 19:15:14 2015	(r278397)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c	Sun Feb  8 19:18:23 2015	(r278398)
@@ -1702,41 +1702,40 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
 }
 
 static void
-cfiscsi_ioctl_terminate(struct ctl_iscsi *ci)
+cfiscsi_ioctl_logout(struct ctl_iscsi *ci)
 {
 	struct icl_pdu *response;
 	struct iscsi_bhs_asynchronous_message *bhsam;
-	struct ctl_iscsi_terminate_params *citp;
+	struct ctl_iscsi_logout_params *cilp;
 	struct cfiscsi_session *cs;
 	struct cfiscsi_softc *softc;
 	int found = 0;
 
-	citp = (struct ctl_iscsi_terminate_params *)&(ci->data);
+	cilp = (struct ctl_iscsi_logout_params *)&(ci->data);
 	softc = &cfiscsi_softc;
 
 	mtx_lock(&softc->lock);
 	TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
-		if (citp->all == 0 && cs->cs_id != citp->connection_id &&
-		    strcmp(cs->cs_initiator_name, citp->initiator_name) != 0 &&
-		    strcmp(cs->cs_initiator_addr, citp->initiator_addr) != 0)
+		if (cilp->all == 0 && cs->cs_id != cilp->connection_id &&
+		    strcmp(cs->cs_initiator_name, cilp->initiator_name) != 0 &&
+		    strcmp(cs->cs_initiator_addr, cilp->initiator_addr) != 0)
 			continue;
 
 		response = icl_pdu_new(cs->cs_conn, M_NOWAIT);
 		if (response == NULL) {
-			/*
-			 * Oh well.  Just terminate the connection.
-			 */
-		} else {
-			bhsam = (struct iscsi_bhs_asynchronous_message *)
-			    response->ip_bhs;
-			bhsam->bhsam_opcode = ISCSI_BHS_OPCODE_ASYNC_MESSAGE;
-			bhsam->bhsam_flags = 0x80;
-			bhsam->bhsam_0xffffffff = 0xffffffff;
-			bhsam->bhsam_async_event =
-			    BHSAM_EVENT_TARGET_TERMINATES_SESSION;
-			cfiscsi_pdu_queue(response);
+			ci->status = CTL_ISCSI_ERROR;
+			snprintf(ci->error_str, sizeof(ci->error_str),
+			    "Unable to allocate memory");
+			mtx_unlock(&softc->lock);
+			return;
 		}
-		cfiscsi_session_terminate(cs);
+		bhsam =
+		    (struct iscsi_bhs_asynchronous_message *)response->ip_bhs;
+		bhsam->bhsam_opcode = ISCSI_BHS_OPCODE_ASYNC_MESSAGE;
+		bhsam->bhsam_flags = 0x80;
+		bhsam->bhsam_async_event = BHSAM_EVENT_TARGET_REQUESTS_LOGOUT;
+		bhsam->bhsam_parameter3 = htons(10);
+		cfiscsi_pdu_queue(response);
 		found++;
 	}
 	mtx_unlock(&softc->lock);
@@ -1752,40 +1751,41 @@ cfiscsi_ioctl_terminate(struct ctl_iscsi
 }
 
 static void
-cfiscsi_ioctl_logout(struct ctl_iscsi *ci)
+cfiscsi_ioctl_terminate(struct ctl_iscsi *ci)
 {
 	struct icl_pdu *response;
 	struct iscsi_bhs_asynchronous_message *bhsam;
-	struct ctl_iscsi_logout_params *cilp;
+	struct ctl_iscsi_terminate_params *citp;
 	struct cfiscsi_session *cs;
 	struct cfiscsi_softc *softc;
 	int found = 0;
 
-	cilp = (struct ctl_iscsi_logout_params *)&(ci->data);
+	citp = (struct ctl_iscsi_terminate_params *)&(ci->data);
 	softc = &cfiscsi_softc;
 
 	mtx_lock(&softc->lock);
 	TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
-		if (cilp->all == 0 && cs->cs_id != cilp->connection_id &&
-		    strcmp(cs->cs_initiator_name, cilp->initiator_name) != 0 &&
-		    strcmp(cs->cs_initiator_addr, cilp->initiator_addr) != 0)
+		if (citp->all == 0 && cs->cs_id != citp->connection_id &&
+		    strcmp(cs->cs_initiator_name, citp->initiator_name) != 0 &&
+		    strcmp(cs->cs_initiator_addr, citp->initiator_addr) != 0)
 			continue;
 
 		response = icl_pdu_new(cs->cs_conn, M_NOWAIT);
 		if (response == NULL) {
-			ci->status = CTL_ISCSI_ERROR;
-			snprintf(ci->error_str, sizeof(ci->error_str),
-			    "Unable to allocate memory");
-			mtx_unlock(&softc->lock);
-			return;
+			/*
+			 * Oh well.  Just terminate the connection.
+			 */
+		} else {
+			bhsam = (struct iscsi_bhs_asynchronous_message *)
+			    response->ip_bhs;
+			bhsam->bhsam_opcode = ISCSI_BHS_OPCODE_ASYNC_MESSAGE;
+			bhsam->bhsam_flags = 0x80;
+			bhsam->bhsam_0xffffffff = 0xffffffff;
+			bhsam->bhsam_async_event =
+			    BHSAM_EVENT_TARGET_TERMINATES_SESSION;
+			cfiscsi_pdu_queue(response);
 		}
-		bhsam =
-		    (struct iscsi_bhs_asynchronous_message *)response->ip_bhs;
-		bhsam->bhsam_opcode = ISCSI_BHS_OPCODE_ASYNC_MESSAGE;
-		bhsam->bhsam_flags = 0x80;
-		bhsam->bhsam_async_event = BHSAM_EVENT_TARGET_REQUESTS_LOGOUT;
-		bhsam->bhsam_parameter3 = htons(10);
-		cfiscsi_pdu_queue(response);
+		cfiscsi_session_terminate(cs);
 		found++;
 	}
 	mtx_unlock(&softc->lock);
@@ -2241,12 +2241,12 @@ cfiscsi_ioctl(struct cdev *dev,
 	case CTL_ISCSI_LIST:
 		cfiscsi_ioctl_list(ci);
 		break;
-	case CTL_ISCSI_TERMINATE:
-		cfiscsi_ioctl_terminate(ci);
-		break;
 	case CTL_ISCSI_LOGOUT:
 		cfiscsi_ioctl_logout(ci);
 		break;
+	case CTL_ISCSI_TERMINATE:
+		cfiscsi_ioctl_terminate(ci);
+		break;
 	case CTL_ISCSI_LIMITS:
 		cfiscsi_ioctl_limits(ci);
 		break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502081918.t18JIODf050578>