changeset 11617:8854b1d29e96

6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
author allan <Allan.Ou@Sun.COM>
date Wed, 03 Feb 2010 13:17:43 +0800
parents 7253e4e14950
children bfa358dd6301
files usr/src/lib/sun_fc/common/FCHBAPort.cc usr/src/uts/common/io/fibre-channel/impl/fp.c
diffstat 2 files changed, 26 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/sun_fc/common/FCHBAPort.cc	Mon Feb 01 23:03:27 2010 -0800
+++ b/usr/src/lib/sun_fc/common/FCHBAPort.cc	Wed Feb 03 13:17:43 2010 +0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -480,7 +480,7 @@
 	fcio.fcio_xfer = FCIO_XFER_READ;
 	do {
 		retry = false;
-		bufSize = MAXPATHLEN * size + (int) sizeof (fc_hba_npiv_port_list_t) - 1;
+		bufSize = MAXPATHLEN * (size - 1) + (int) sizeof (fc_hba_npiv_port_list_t);
 		pathList = (fc_hba_npiv_port_list_t *) new uchar_t[bufSize];
 		pathList->numAdapters = size;
 		fcio.fcio_olen = bufSize;
--- a/usr/src/uts/common/io/fibre-channel/impl/fp.c	Mon Feb 01 23:03:27 2010 -0800
+++ b/usr/src/uts/common/io/fibre-channel/impl/fp.c	Wed Feb 03 13:17:43 2010 +0800
@@ -6631,15 +6631,18 @@
 				    pkt->pkt_reason, class);
 				cmd_flag = FP_CMD_PLOGI_RETAIN;
 
-				logi_cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
+				logi_cmd = fp_alloc_pkt(port,
+				    sizeof (la_els_logi_t),
 				    sizeof (la_els_logi_t), KM_SLEEP, pd);
 				if (logi_cmd == NULL) {
 					fp_iodone(cmd);
 					return;
 				}
 
-				logi_cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
-				logi_cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
+				logi_cmd->cmd_pkt.pkt_tran_flags =
+				    FC_TRAN_INTR | class;
+				logi_cmd->cmd_pkt.pkt_tran_type =
+				    FC_PKT_EXCHANGE;
 				logi_cmd->cmd_flags = cmd_flag;
 				logi_cmd->cmd_retry_count = fp_retry_count;
 				logi_cmd->cmd_ulp_pkt = NULL;
@@ -7683,15 +7686,24 @@
 
 		list = kmem_zalloc(fcio->fcio_olen, KM_SLEEP);
 		list->version = FC_HBA_LIST_VERSION;
-		/* build npiv port list */
-		count = fc_ulp_get_npiv_port_list(port, (char *)list->hbaPaths);
-		if (count < 0) {
-			rval = ENXIO;
-			FP_TRACE(FP_NHEAD1(1, 0), "Build NPIV Port List error");
-			kmem_free(list, fcio->fcio_olen);
-			break;
-		}
-		list->numAdapters = count;
+
+		count = (fcio->fcio_olen -
+		    (int)sizeof (fc_hba_npiv_port_list_t))/MAXPATHLEN  + 1;
+		if (port->fp_npiv_portnum > count) {
+			list->numAdapters = port->fp_npiv_portnum;
+		} else {
+			/* build npiv port list */
+			count = fc_ulp_get_npiv_port_list(port,
+			    (char *)list->hbaPaths);
+			if (count < 0) {
+				rval = ENXIO;
+				FP_TRACE(FP_NHEAD1(1, 0),
+				    "Build NPIV Port List error");
+				kmem_free(list, fcio->fcio_olen);
+				break;
+			}
+			list->numAdapters = count;
+		}
 
 		if (fp_copyout((void *)list, (void *)fcio->fcio_obuf,
 		    fcio->fcio_olen, mode) == 0) {