Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jan 2017 08:29:41 +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-11@freebsd.org
Subject:   svn commit: r312570 - stable/11/sys/cam/ctl
Message-ID:  <201701210829.v0L8TfDL016809@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Jan 21 08:29:40 2017
New Revision: 312570
URL: https://svnweb.freebsd.org/changeset/base/312570

Log:
  MFC r310539: Remove CTL_MAX_LUNS from places where it is not required.

Modified:
  stable/11/sys/cam/ctl/ctl.c
  stable/11/sys/cam/ctl/ctl_frontend.c
  stable/11/sys/cam/ctl/ctl_tpc.c
  stable/11/sys/cam/ctl/ctl_tpc_local.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cam/ctl/ctl.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl.c	Sat Jan 21 08:19:42 2017	(r312569)
+++ stable/11/sys/cam/ctl/ctl.c	Sat Jan 21 08:29:40 2017	(r312570)
@@ -1218,7 +1218,7 @@ ctl_isc_port_sync(struct ctl_softc *soft
 	}
 	mtx_lock(&softc->ctl_lock);
 	STAILQ_FOREACH(lun, &softc->lun_list, links) {
-		if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		mtx_lock(&lun->lun_lock);
 		ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);
@@ -2906,18 +2906,18 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		break;
 	}
 	case CTL_DUMP_STRUCTS: {
-		int i, j, k;
+		int j, k;
 		struct ctl_port *port;
 		struct ctl_frontend *fe;
 
 		mtx_lock(&softc->ctl_lock);
 		printf("CTL Persistent Reservation information start:\n");
-		for (i = 0; i < CTL_MAX_LUNS; i++) {
-			lun = softc->ctl_luns[i];
-
-			if ((lun == NULL)
-			 || ((lun->flags & CTL_LUN_DISABLED) != 0))
+		STAILQ_FOREACH(lun, &softc->lun_list, links) {
+			mtx_lock(&lun->lun_lock);
+			if ((lun->flags & CTL_LUN_DISABLED) != 0) {
+				mtx_unlock(&lun->lun_lock);
 				continue;
+			}
 
 			for (j = 0; j < CTL_MAX_PORTS; j++) {
 				if (lun->pr_keys[j] == NULL)
@@ -2925,11 +2925,12 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 				for (k = 0; k < CTL_MAX_INIT_PER_PORT; k++){
 					if (lun->pr_keys[j][k] == 0)
 						continue;
-					printf("  LUN %d port %d iid %d key "
-					       "%#jx\n", i, j, k,
+					printf("  LUN %ju port %d iid %d key "
+					       "%#jx\n", lun->lun, j, k,
 					       (uintmax_t)lun->pr_keys[j][k]);
 				}
 			}
+			mtx_unlock(&lun->lun_lock);
 		}
 		printf("CTL Persistent Reservation information end\n");
 		printf("CTL Ports:\n");
@@ -3312,7 +3313,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 				sbuf_printf(sb, "\t<lun_map>on</lun_map>\n");
 				for (j = 0; j < CTL_MAX_LUNS; j++) {
 					plun = ctl_lun_map_from_port(port, j);
-					if (plun >= CTL_MAX_LUNS)
+					if (plun == UINT32_MAX)
 						continue;
 					sbuf_printf(sb,
 					    "\t<lun id=\"%u\">%u</lun>\n",
@@ -3380,8 +3381,8 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		}
 		if (port->status & CTL_PORT_STATUS_ONLINE) {
 			STAILQ_FOREACH(lun, &softc->lun_list, links) {
-				if (ctl_lun_map_to_port(port, lun->lun) >=
-				    CTL_MAX_LUNS)
+				if (ctl_lun_map_to_port(port, lun->lun) ==
+				    UINT32_MAX)
 					continue;
 				mtx_lock(&lun->lun_lock);
 				ctl_est_ua_port(lun, lm->port, -1,
@@ -3509,7 +3510,7 @@ ctl_lun_map_set(struct ctl_port *port, u
 	}
 	old = port->lun_map[plun];
 	port->lun_map[plun] = glun;
-	if ((port->status & CTL_PORT_STATUS_ONLINE) && old >= CTL_MAX_LUNS) {
+	if ((port->status & CTL_PORT_STATUS_ONLINE) && old == UINT32_MAX) {
 		if (port->lun_enable != NULL)
 			port->lun_enable(port->targ_lun_arg, plun);
 		ctl_isc_announce_port(port);
@@ -3526,7 +3527,7 @@ ctl_lun_map_unset(struct ctl_port *port,
 		return (0);
 	old = port->lun_map[plun];
 	port->lun_map[plun] = UINT32_MAX;
-	if ((port->status & CTL_PORT_STATUS_ONLINE) && old < CTL_MAX_LUNS) {
+	if ((port->status & CTL_PORT_STATUS_ONLINE) && old != UINT32_MAX) {
 		if (port->lun_disable != NULL)
 			port->lun_disable(port->targ_lun_arg, plun);
 		ctl_isc_announce_port(port);
@@ -3540,7 +3541,7 @@ ctl_lun_map_from_port(struct ctl_port *p
 
 	if (port == NULL)
 		return (UINT32_MAX);
-	if (port->lun_map == NULL || lun_id >= CTL_MAX_LUNS)
+	if (port->lun_map == NULL || lun_id == UINT32_MAX)
 		return (lun_id);
 	return (port->lun_map[lun_id]);
 }
@@ -7142,7 +7143,7 @@ ctl_report_tagret_port_groups(struct ctl
 	STAILQ_FOREACH(port, &softc->port_list, links) {
 		if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
 			continue;
-		if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		num_target_ports++;
 		if (port->status & CTL_PORT_STATUS_HA_SHARED)
@@ -7234,7 +7235,7 @@ ctl_report_tagret_port_groups(struct ctl
 			if (!softc->is_single &&
 			    (port->status & CTL_PORT_STATUS_HA_SHARED) == 0)
 				continue;
-			if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+			if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 				continue;
 			scsi_ulto2b(port->targ_port, tpg_desc->descriptors[pc].
 			    relative_target_port_identifier);
@@ -7259,7 +7260,7 @@ ctl_report_tagret_port_groups(struct ctl
 				continue;
 			if (port->status & CTL_PORT_STATUS_HA_SHARED)
 				continue;
-			if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+			if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 				continue;
 			scsi_ulto2b(port->targ_port, tpg_desc->descriptors[pc].
 			    relative_target_port_identifier);
@@ -9078,7 +9079,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio
 	mtx_lock(&softc->ctl_lock);
 	num_luns = 0;
 	for (targ_lun_id = 0; targ_lun_id < CTL_MAX_LUNS; targ_lun_id++) {
-		if (ctl_lun_map_from_port(port, targ_lun_id) < CTL_MAX_LUNS)
+		if (ctl_lun_map_from_port(port, targ_lun_id) != UINT32_MAX)
 			num_luns++;
 	}
 	mtx_unlock(&softc->ctl_lock);
@@ -9138,7 +9139,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio
 	mtx_lock(&softc->ctl_lock);
 	for (targ_lun_id = 0, num_filled = 0; targ_lun_id < CTL_MAX_LUNS && num_filled < num_luns; targ_lun_id++) {
 		lun_id = ctl_lun_map_from_port(port, targ_lun_id);
-		if (lun_id >= CTL_MAX_LUNS)
+		if (lun_id == UINT32_MAX)
 			continue;
 		lun = softc->ctl_luns[lun_id];
 		if (lun == NULL)
@@ -9774,7 +9775,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s
 		if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
 			continue;
 		if (lun != NULL &&
-		    ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		    ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		num_target_ports++;
 		if (port->init_devid)
@@ -9825,7 +9826,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s
 		if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
 			continue;
 		if (lun != NULL &&
-		    ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		    ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		scsi_ulto2b(port->targ_port, pd->relative_port_id);
 		if (port->init_devid) {
@@ -11882,7 +11883,7 @@ ctl_target_reset(struct ctl_softc *softc
 	port = ctl_io_port(&io->io_hdr);
 	STAILQ_FOREACH(lun, &softc->lun_list, links) {
 		if (port != NULL &&
-		    ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		    ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		retval += ctl_do_lun_reset(lun, io, ua_type);
 	}

Modified: stable/11/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl_frontend.c	Sat Jan 21 08:19:42 2017	(r312569)
+++ stable/11/sys/cam/ctl/ctl_frontend.c	Sat Jan 21 08:29:40 2017	(r312570)
@@ -316,8 +316,8 @@ ctl_port_online(struct ctl_port *port)
 	if (port->lun_enable != NULL) {
 		if (port->lun_map) {
 			for (l = 0; l < CTL_MAX_LUNS; l++) {
-				if (ctl_lun_map_from_port(port, l) >=
-				    CTL_MAX_LUNS)
+				if (ctl_lun_map_from_port(port, l) ==
+				    UINT32_MAX)
 					continue;
 				port->lun_enable(port->targ_lun_arg, l);
 			}
@@ -338,7 +338,7 @@ ctl_port_online(struct ctl_port *port)
 	}
 	port->status |= CTL_PORT_STATUS_ONLINE;
 	STAILQ_FOREACH(lun, &softc->lun_list, links) {
-		if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		mtx_lock(&lun->lun_lock);
 		ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);
@@ -360,8 +360,8 @@ ctl_port_offline(struct ctl_port *port)
 	if (port->lun_disable != NULL) {
 		if (port->lun_map) {
 			for (l = 0; l < CTL_MAX_LUNS; l++) {
-				if (ctl_lun_map_from_port(port, l) >=
-				    CTL_MAX_LUNS)
+				if (ctl_lun_map_from_port(port, l) ==
+				    UINT32_MAX)
 					continue;
 				port->lun_disable(port->targ_lun_arg, l);
 			}
@@ -373,7 +373,7 @@ ctl_port_offline(struct ctl_port *port)
 	mtx_lock(&softc->ctl_lock);
 	port->status &= ~CTL_PORT_STATUS_ONLINE;
 	STAILQ_FOREACH(lun, &softc->lun_list, links) {
-		if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		if (ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		mtx_lock(&lun->lun_lock);
 		ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);

Modified: stable/11/sys/cam/ctl/ctl_tpc.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl_tpc.c	Sat Jan 21 08:19:42 2017	(r312569)
+++ stable/11/sys/cam/ctl/ctl_tpc.c	Sat Jan 21 08:29:40 2017	(r312570)
@@ -894,7 +894,7 @@ tpc_process_b2b(struct tpc_list *list)
 	dcscd = scsi_2btoul(seg->dst_cscd);
 	sl = tpc_resolve(list, scscd, &srcblock, NULL, NULL);
 	dl = tpc_resolve(list, dcscd, &dstblock, &pb, &pbo);
-	if (sl >= CTL_MAX_LUNS || dl >= CTL_MAX_LUNS) {
+	if (sl == UINT64_MAX || dl == UINT64_MAX) {
 		ctl_set_sense(list->ctsio, /*current_error*/ 1,
 		    /*sense_key*/ SSD_KEY_COPY_ABORTED,
 		    /*asc*/ 0x08, /*ascq*/ 0x04,
@@ -1042,7 +1042,7 @@ tpc_process_verify(struct tpc_list *list
 	seg = (struct scsi_ec_segment_verify *)list->seg[list->curseg];
 	cscd = scsi_2btoul(seg->src_cscd);
 	sl = tpc_resolve(list, cscd, NULL, NULL, NULL);
-	if (sl >= CTL_MAX_LUNS) {
+	if (sl == UINT64_MAX) {
 		ctl_set_sense(list->ctsio, /*current_error*/ 1,
 		    /*sense_key*/ SSD_KEY_COPY_ABORTED,
 		    /*asc*/ 0x08, /*ascq*/ 0x04,
@@ -1106,7 +1106,7 @@ tpc_process_register_key(struct tpc_list
 	seg = (struct scsi_ec_segment_register_key *)list->seg[list->curseg];
 	cscd = scsi_2btoul(seg->dst_cscd);
 	dl = tpc_resolve(list, cscd, NULL, NULL, NULL);
-	if (dl >= CTL_MAX_LUNS) {
+	if (dl == UINT64_MAX) {
 		ctl_set_sense(list->ctsio, /*current_error*/ 1,
 		    /*sense_key*/ SSD_KEY_COPY_ABORTED,
 		    /*asc*/ 0x08, /*ascq*/ 0x04,

Modified: stable/11/sys/cam/ctl/ctl_tpc_local.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl_tpc_local.c	Sat Jan 21 08:19:42 2017	(r312569)
+++ stable/11/sys/cam/ctl/ctl_tpc_local.c	Sat Jan 21 08:29:40 2017	(r312570)
@@ -290,7 +290,7 @@ tpcl_resolve(struct ctl_softc *softc, in
 		port = NULL;
 	STAILQ_FOREACH(lun, &softc->lun_list, links) {
 		if (port != NULL &&
-		    ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+		    ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX)
 			continue;
 		if (lun->lun_devid == NULL)
 			continue;



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