Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2015 07:29:27 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r288697 - stable/10/sys/cam/ctl
Message-ID:  <201510050729.t957TR1p076282@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Oct  5 07:29:26 2015
New Revision: 288697
URL: https://svnweb.freebsd.org/changeset/base/288697

Log:
  MFC r278398 (by trasz):
  Fix ordering of "*logout" and "*terminate"; no functional changes.

Modified:
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c	Mon Oct  5 07:21:26 2015	(r288696)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c	Mon Oct  5 07:29:26 2015	(r288697)
@@ -1652,41 +1652,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);
@@ -1702,40 +1701,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);
@@ -2170,12 +2170,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;
 #ifdef ICL_KERNEL_PROXY
 	case CTL_ISCSI_LISTEN:
 		cfiscsi_ioctl_listen(ci);



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