Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2015 09:09:49 +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: r288746 - stable/10/sys/cam/ctl
Message-ID:  <201510050909.t9599nox023941@repo.freebsd.org>

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

Log:
  MFC r287754: Report CTL_UA_LUN_CHANGE on LUN map change.

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

Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 09:08:58 2015	(r288745)
+++ stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 09:09:48 2015	(r288746)
@@ -408,6 +408,8 @@ static int ctl_scsiio_lun_check(struct c
 				struct ctl_scsiio *ctsio);
 static void ctl_failover_lun(struct ctl_lun *lun);
 static void ctl_est_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
+static void ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except,
+    ctl_ua_type ua);
 static void ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
 static void ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
 static void ctl_clr_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
@@ -1215,24 +1217,32 @@ ctl_est_ua(struct ctl_lun *lun, uint32_t
 }
 
 static void
-ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
+ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except, ctl_ua_type ua)
 {
-	struct ctl_softc *softc = lun->ctl_softc;
-	int i, j;
+	int i;
 
 	mtx_assert(&lun->lun_lock, MA_OWNED);
-	for (i = softc->port_min; i < softc->port_max; i++) {
-		if (lun->pending_ua[i] == NULL)
+	if (lun->pending_ua[port] == NULL)
+		return;
+	for (i = 0; i < CTL_MAX_INIT_PER_PORT; i++) {
+		if (port * CTL_MAX_INIT_PER_PORT + i == except)
 			continue;
-		for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) {
-			if (i * CTL_MAX_INIT_PER_PORT + j == except)
-				continue;
-			lun->pending_ua[i][j] |= ua;
-		}
+		lun->pending_ua[port][i] |= ua;
 	}
 }
 
 static void
+ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
+{
+	struct ctl_softc *softc = lun->ctl_softc;
+	int i;
+
+	mtx_assert(&lun->lun_lock, MA_OWNED);
+	for (i = softc->port_min; i < softc->port_max; i++)
+		ctl_est_ua_port(lun, i, except, ua);
+}
+
+static void
 ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua)
 {
 	struct ctl_softc *softc = lun->ctl_softc;
@@ -2117,6 +2127,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	  struct thread *td)
 {
 	struct ctl_softc *softc;
+	struct ctl_lun *lun;
 	int retval;
 
 	softc = control_softc;
@@ -2275,7 +2286,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		break;
 	}
 	case CTL_DUMP_OOA: {
-		struct ctl_lun *lun;
 		union ctl_io *io;
 		char printbuf[128];
 		struct sbuf sb;
@@ -2312,7 +2322,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		break;
 	}
 	case CTL_GET_OOA: {
-		struct ctl_lun *lun;
 		struct ctl_ooa *ooa_hdr;
 		struct ctl_ooa_entry *entries;
 		uint32_t cur_fill_num;
@@ -2404,7 +2413,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_CHECK_OOA: {
 		union ctl_io *io;
-		struct ctl_lun *lun;
 		struct ctl_ooa_info *ooa_info;
 
 
@@ -2437,9 +2445,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_DELAY_IO: {
 		struct ctl_io_delay_info *delay_info;
-#ifdef CTL_IO_DELAY
-		struct ctl_lun *lun;
-#endif /* CTL_IO_DELAY */
 
 		delay_info = (struct ctl_io_delay_info *)addr;
 
@@ -2530,7 +2535,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	case CTL_SETSYNC:
 	case CTL_GETSYNC: {
 		struct ctl_sync_info *sync_info;
-		struct ctl_lun *lun;
 
 		sync_info = (struct ctl_sync_info *)addr;
 
@@ -2560,7 +2564,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_GETSTATS: {
 		struct ctl_stats *stats;
-		struct ctl_lun *lun;
 		int i;
 
 		stats = (struct ctl_stats *)addr;
@@ -2596,7 +2599,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_ERROR_INJECT: {
 		struct ctl_error_desc *err_desc, *new_err_desc;
-		struct ctl_lun *lun;
 
 		err_desc = (struct ctl_error_desc *)addr;
 
@@ -2643,7 +2645,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_ERROR_INJECT_DELETE: {
 		struct ctl_error_desc *delete_desc, *desc, *desc2;
-		struct ctl_lun *lun;
 		int delete_done;
 
 		delete_desc = (struct ctl_error_desc *)addr;
@@ -2687,8 +2688,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		mtx_lock(&softc->ctl_lock);
 		printf("CTL Persistent Reservation information start:\n");
 		for (i = 0; i < CTL_MAX_LUNS; i++) {
-			struct ctl_lun *lun;
-
 			lun = softc->ctl_luns[i];
 
 			if ((lun == NULL)
@@ -2782,7 +2781,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	}
 	case CTL_LUN_LIST: {
 		struct sbuf *sb;
-		struct ctl_lun *lun;
 		struct ctl_lun_list *list;
 		struct ctl_option *opt;
 
@@ -3155,6 +3153,13 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 			mtx_unlock(&softc->ctl_lock);
 			return (ENXIO);
 		}
+		STAILQ_FOREACH(lun, &softc->lun_list, links) {
+			if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+				continue;
+			mtx_lock(&lun->lun_lock);
+			ctl_est_ua_port(lun, lm->port, -1, CTL_UA_LUN_CHANGE);
+			mtx_unlock(&lun->lun_lock);
+		}
 		mtx_unlock(&softc->ctl_lock); // XXX: port_enable sleeps
 		if (lm->plun < CTL_MAX_LUNS) {
 			if (lm->lun == UINT32_MAX)



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