Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Sep 2015 17:00:37 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287921 - head/sys/cam/ctl
Message-ID:  <201509171700.t8HH0bSm088315@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Sep 17 17:00:36 2015
New Revision: 287921
URL: https://svnweb.freebsd.org/changeset/base/287921

Log:
  When reporting TPT UA, report which of thresholds was reached.

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_error.c
  head/sys/cam/ctl/ctl_io.h
  head/sys/cam/ctl/ctl_private.h

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Thu Sep 17 16:56:49 2015	(r287920)
+++ head/sys/cam/ctl/ctl.c	Thu Sep 17 17:00:36 2015	(r287921)
@@ -703,6 +703,9 @@ ctl_isc_ua(struct ctl_softc *softc, unio
 	    (lun = softc->ctl_luns[msg->hdr.nexus.targ_mapped_lun]) != NULL) {
 		mtx_lock(&lun->lun_lock);
 		mtx_unlock(&softc->ctl_lock);
+		if (msg->ua.ua_type == CTL_UA_THIN_PROV_THRES &&
+		    msg->ua.ua_set)
+			memcpy(lun->ua_tpt_info, msg->ua.ua_info, 8);
 		if (msg->ua.ua_all) {
 			if (msg->ua.ua_set)
 				ctl_est_ua_all(lun, iid, msg->ua.ua_type);
@@ -11131,15 +11134,9 @@ ctl_scsiio_precheck(struct ctl_softc *so
 	 */
 	if ((entry->flags & CTL_CMD_FLAG_NO_SENSE) == 0) {
 		ctl_ua_type ua_type;
-		scsi_sense_data_type sense_format;
-
-		if (lun->flags & CTL_LUN_SENSE_DESC)
-			sense_format = SSD_TYPE_DESC;
-		else
-			sense_format = SSD_TYPE_FIXED;
 
 		ua_type = ctl_build_ua(lun, initidx, &ctsio->sense_data,
-		    sense_format);
+		    SSD_TYPE_NONE);
 		if (ua_type != CTL_UA_NONE) {
 			mtx_unlock(&lun->lun_lock);
 			ctsio->scsi_status = SCSI_STATUS_CHECK_COND;
@@ -13338,12 +13335,16 @@ ctl_thresh_thread(void *arg)
 					continue;
 				if ((page->descr[i].flags & SLBPPD_ARMING_MASK)
 				    == SLBPPD_ARMING_INC)
-					e |= (val >= thres);
+					e = (val >= thres);
 				else
-					e |= (val <= thres);
+					e = (val <= thres);
+				if (e)
+					break;
 			}
 			mtx_lock(&lun->lun_lock);
 			if (e) {
+				scsi_u64to8b((uint8_t *)&page->descr[i] -
+				    (uint8_t *)page, lun->ua_tpt_info);
 				if (lun->lasttpt == 0 ||
 				    time_uptime - lun->lasttpt >= CTL_LBP_UA_PERIOD) {
 					lun->lasttpt = time_uptime;
@@ -13369,6 +13370,7 @@ ctl_thresh_thread(void *arg)
 				msg.ua.ua_all = 1;
 				msg.ua.ua_set = (set > 0);
 				msg.ua.ua_type = CTL_UA_THIN_PROV_THRES;
+				memcpy(msg.ua.ua_info, lun->ua_tpt_info, 8);
 				mtx_unlock(&softc->ctl_lock); // XXX
 				ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg,
 				    sizeof(msg.ua), M_WAITOK);

Modified: head/sys/cam/ctl/ctl_error.c
==============================================================================
--- head/sys/cam/ctl/ctl_error.c	Thu Sep 17 16:56:49 2015	(r287920)
+++ head/sys/cam/ctl/ctl_error.c	Thu Sep 17 17:00:36 2015	(r287921)
@@ -366,8 +366,8 @@ ctl_set_ua(struct ctl_scsiio *ctsio, int
 }
 
 static void
-ctl_ua_to_acsq(ctl_ua_type ua_to_build, int *asc, int *ascq,
-    ctl_ua_type *ua_to_clear)
+ctl_ua_to_acsq(struct ctl_lun *lun, ctl_ua_type ua_to_build, int *asc,
+    int *ascq, ctl_ua_type *ua_to_clear, uint8_t **info)
 {
 
 	switch (ua_to_build) {
@@ -453,6 +453,7 @@ ctl_ua_to_acsq(ctl_ua_type ua_to_build, 
 		/* 38h/07h  THIN PROVISIONING SOFT THRESHOLD REACHED */
 		*asc = 0x38;
 		*ascq = 0x07;
+		*info = lun->ua_tpt_info;
 		break;
 	default:
 		panic("%s: Unknown UA %x", __func__, ua_to_build);
@@ -464,6 +465,7 @@ ctl_build_qae(struct ctl_lun *lun, uint3
 {
 	ctl_ua_type ua;
 	ctl_ua_type ua_to_build, ua_to_clear;
+	uint8_t *info;
 	int asc, ascq;
 	uint32_t p, i;
 
@@ -479,7 +481,8 @@ ctl_build_qae(struct ctl_lun *lun, uint3
 
 	ua_to_build = (1 << (ffs(ua) - 1));
 	ua_to_clear = ua_to_build;
-	ctl_ua_to_acsq(ua_to_build, &asc, &ascq, &ua_to_clear);
+	info = NULL;
+	ctl_ua_to_acsq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info);
 
 	resp[0] = SSD_KEY_UNIT_ATTENTION;
 	if (ua_to_build == ua)
@@ -497,6 +500,7 @@ ctl_build_ua(struct ctl_lun *lun, uint32
 {
 	ctl_ua_type *ua;
 	ctl_ua_type ua_to_build, ua_to_clear;
+	uint8_t *info;
 	int asc, ascq;
 	uint32_t p, i;
 
@@ -522,16 +526,13 @@ ctl_build_ua(struct ctl_lun *lun, uint32
 
 	ua_to_build = (1 << (ffs(ua[i]) - 1));
 	ua_to_clear = ua_to_build;
-	ctl_ua_to_acsq(ua_to_build, &asc, &ascq, &ua_to_clear);
+	info = NULL;
+	ctl_ua_to_acsq(lun, ua_to_build, &asc, &ascq, &ua_to_clear, &info);
 
-	ctl_set_sense_data(sense,
-			   /*lun*/ NULL,
-			   sense_format,
-			   /*current_error*/ 1,
-			   /*sense_key*/ SSD_KEY_UNIT_ATTENTION,
-			   asc,
-			   ascq,
-			   SSD_ELEM_NONE);
+	ctl_set_sense_data(sense, lun, sense_format, /*current_error*/ 1,
+	    /*sense_key*/ SSD_KEY_UNIT_ATTENTION, asc, ascq,
+	    ((info != NULL) ? SSD_ELEM_INFO : SSD_ELEM_SKIP), 8, info,
+	    SSD_ELEM_NONE);
 
 	/* We're reporting this UA, so clear it */
 	ua[i] &= ~ua_to_clear;

Modified: head/sys/cam/ctl/ctl_io.h
==============================================================================
--- head/sys/cam/ctl/ctl_io.h	Thu Sep 17 16:56:49 2015	(r287920)
+++ head/sys/cam/ctl/ctl_io.h	Thu Sep 17 17:00:36 2015	(r287921)
@@ -408,6 +408,7 @@ struct ctl_ha_msg_ua {
 	int			ua_all;
 	int			ua_set;
 	int			ua_type;
+	uint8_t			ua_info[8];
 };
 
 /*

Modified: head/sys/cam/ctl/ctl_private.h
==============================================================================
--- head/sys/cam/ctl/ctl_private.h	Thu Sep 17 16:56:49 2015	(r287920)
+++ head/sys/cam/ctl/ctl_private.h	Thu Sep 17 17:00:36 2015	(r287921)
@@ -393,6 +393,7 @@ struct ctl_lun {
 	struct scsi_sense_data		pending_sense[CTL_MAX_INITIATORS];
 #endif
 	ctl_ua_type			*pending_ua[CTL_MAX_PORTS];
+	uint8_t				ua_tpt_info[8];
 	time_t				lasttpt;
 	struct ctl_mode_pages		mode_pages;
 	struct ctl_log_pages		log_pages;



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