Mercurial > illumos > illumos-gate
changeset 13586:a42b5426edb4
1914 libses cannot set more than one properties at once
1984 libses uses threshold diag page wrong way
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | Alexander Stetsenko <ams@nexenta.com> |
---|---|
date | Wed, 01 Feb 2012 20:59:19 +0400 |
parents | 411be0f9d82b |
children | f7bc195459a4 |
files | usr/src/lib/scsi/libses/common/ses_plugin.c usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element_ctl.c usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c |
diffstat | 3 files changed, 58 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/scsi/libses/common/ses_plugin.c Tue Jan 31 22:25:52 2012 -0800 +++ b/usr/src/lib/scsi/libses/common/ses_plugin.c Wed Feb 01 20:59:19 2012 +0400 @@ -22,6 +22,9 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + */ #include <scsi/libses.h> #include "ses_impl.h" @@ -43,7 +46,7 @@ if ((dp = ses_get_pagedesc(tp, pagenum, SES_PAGE_CTL)) == NULL) return (NULL); - if (dp->spd_ctl_fill != NULL) { + if (np != NULL && dp->spd_ctl_fill != NULL) { return (dp->spd_ctl_fill(sp, pp->ssp_page, pp->ssp_len, np)); } else { @@ -135,7 +138,7 @@ if ((pp = ses_snap_find_page(snap, pagenum, B_FALSE)) == NULL) return (NULL); - if (dp->spd_index != NULL) { + if (np != NULL && dp->spd_index != NULL) { return (dp->spd_index(sp, np, pp->ssp_page, pp->ssp_len, lenp)); } else {
--- a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element_ctl.c Tue Jan 31 22:25:52 2012 -0800 +++ b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element_ctl.c Wed Feb 01 20:59:19 2012 +0400 @@ -22,8 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + */ #include <sys/types.h> #include <stddef.h> @@ -689,8 +690,12 @@ ses2_diag_page_t page, nvpair_t *nvp) { ses2_threshold_impl_t *tip; + ses2_threshold_in_page_impl_t *tp; + ses2_threshold_out_page_impl_t *tpout; const char *name; uint64_t v; + size_t len = 0; + size_t i, trnums; ASSERT(page == SES2_DIAGPAGE_THRESHOLD_IO); @@ -698,6 +703,33 @@ page, 0, np, B_FALSE)) == NULL) return (-1); + /* Get whole IN and OUT pages to copy filled thresholds */ + if ((tpout = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np), + page, 0, NULL, B_FALSE)) == NULL) + return (-1); + if ((tp = ses_plugin_page_lookup(sp, ses_node_snapshot(np), + page, NULL, &len)) == NULL) + return (-1); + + len -= offsetof(ses2_threshold_in_page_impl_t, stipi_thresholds[0]); + trnums = len / sizeof (ses2_threshold_impl_t); + + /* Do copy filled thresholds from In to Out page */ + for (i = 0; i < trnums; i++) { + boolean_t filled = B_FALSE; + ses2_threshold_impl_t *toutp = &tpout->stopi_thresholds[i]; + ses2_threshold_impl_t *tinp = &tp->stipi_thresholds[i]; + + if (tinp->sti_high_crit != 0 || tinp->sti_high_warn != 0 || + tinp->sti_low_crit != 0 || tinp->sti_low_warn != 0) + filled = B_TRUE; + + if (toutp->sti_high_crit == 0 && toutp->sti_high_warn == 0 && + toutp->sti_low_crit == 0 && toutp->sti_low_warn == 0 && + filled) + *toutp = *tinp; + } + name = nvpair_name(nvp); (void) nvpair_value_uint64(nvp, &v);
--- a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c Tue Jan 31 22:25:52 2012 -0800 +++ b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c Wed Feb 01 20:59:19 2012 +0400 @@ -22,6 +22,9 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + */ #include <stddef.h> #include <strings.h> @@ -227,6 +230,7 @@ uint64_t index; nvlist_t *props = ses_node_props(np); ses2_control_page_impl_t *pip = pagedata; + ses2_elem_ctl_impl_t *eip; void *data; ses2_diag_page_t page = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS; @@ -237,7 +241,13 @@ return (NULL); } - data = &pip->scpi_data[index]; + data = eip = &pip->scpi_data[index]; + /* + * if control element was already modified "select" field is non-zero, + * so skip setting default values to avoid fields overriding + */ + if (eip->seci_common.seci_select) + return (data); if (ses2_ctl_common_setdef(np, page, data) != 0 || ses2_element_setdef(np, page, data) != 0 || @@ -274,17 +284,21 @@ uint64_t index; nvlist_t *props = ses_node_props(np); ses2_threshold_out_page_impl_t *pip = pagedata; + ses2_threshold_impl_t *tip; ses2_diag_page_t page = SES2_DIAGPAGE_THRESHOLD_IO; void *data; VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX, &index) == 0); - data = &pip[index]; + data = tip = &pip->stopi_thresholds[index]; - if (ses2_ctl_common_setdef(np, page, data) != 0 || - ses2_element_setdef(np, page, data) != 0 || - ses2_enclosure_setdef(np, page, data) != 0) + /* check if threshold is dirty, so no need to set default values */ + if ((tip->sti_high_crit | tip->sti_low_crit | tip->sti_high_warn | + tip->sti_low_warn) != 0) + return (data); + + if (ses2_element_setdef(np, page, data) != 0) return (NULL); return (data);