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

This commit is contained in:
Alexander Motin 2015-09-17 17:00:36 +00:00
parent 60d978a75b
commit 6213882769
4 changed files with 26 additions and 21 deletions

View File

@ -703,6 +703,9 @@ ctl_isc_ua(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
(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 *softc, struct ctl_scsiio *ctsio)
*/
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);

View File

@ -366,8 +366,8 @@ ctl_set_ua(struct ctl_scsiio *ctsio, int asc, int ascq)
}
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, int *asc, int *ascq,
/* 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, uint32_t initidx, uint8_t *resp)
{
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, uint32_t initidx, uint8_t *resp)
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_t initidx,
{
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_t initidx,
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;

View File

@ -408,6 +408,7 @@ struct ctl_ha_msg_ua {
int ua_all;
int ua_set;
int ua_type;
uint8_t ua_info[8];
};
/*

View File

@ -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;