From 28e9047603953b20acb54306be7c48152a1b03e6 Mon Sep 17 00:00:00 2001 From: Ben Sims Date: Sat, 6 Jan 2018 01:09:12 +0000 Subject: 8954 libtopo cannot handle any array type other than string_array. Reviewed by: Andy Stormont Reviewed by: David Höppner <0xffea@gmail.com> Reviewed by: Rob Johnston Approved by: Hans Rosenfeld MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/lib/fm/topo/libtopo/common/topo_xml.c | 71 +++++++++++---------------- 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'usr/src') diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_xml.c b/usr/src/lib/fm/topo/libtopo/common/topo_xml.c index bbac0d17f1..228755c953 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_xml.c +++ b/usr/src/lib/fm/topo/libtopo/common/topo_xml.c @@ -244,35 +244,7 @@ const char *name) case TOPO_TYPE_UINT32_ARRAY: case TOPO_TYPE_INT64_ARRAY: case TOPO_TYPE_UINT64_ARRAY: - for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) - if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || - (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) - nelems++; - - if (nelems < 1) { - topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, "No " - "or elements found for array val"); - return (-1); - } - if ((arrbuf = topo_mod_alloc(mp, (nelems * sizeof (uint64_t)))) - == NULL) - return (topo_mod_seterrno(mp, ETOPO_NOMEM)); - break; case TOPO_TYPE_STRING_ARRAY: - for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) - if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || - (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) - nelems++; - - if (nelems < 1) { - topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, "No " - "or elements found for array val"); - return (-1); - } - if ((strarrbuf = topo_mod_alloc(mp, (nelems * sizeof (char *)))) - == NULL) - return (topo_mod_seterrno(mp, ETOPO_NOMEM)); - break; case TOPO_TYPE_FMRI_ARRAY: for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || @@ -281,12 +253,9 @@ const char *name) if (nelems < 1) { topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, "No " - "elements found for array prop"); + "or elements found for array val"); return (-1); } - if ((nvlarrbuf = topo_mod_alloc(mp, (nelems * - sizeof (nvlist_t *)))) == NULL) - return (topo_mod_seterrno(mp, ETOPO_NOMEM)); break; default: topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, @@ -296,11 +265,14 @@ const char *name) switch (ptype) { case TOPO_TYPE_INT32_ARRAY: + if ((arrbuf = topo_mod_alloc(mp, (nelems * sizeof (int32_t)))) + == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { - if ((str = xmlGetProp(xn, (xmlChar *)Value)) + if ((str = xmlGetProp(cn, (xmlChar *)Value)) == NULL) return (-1); @@ -312,14 +284,17 @@ const char *name) rv = nvlist_add_int32_array(nvl, name, (int32_t *)arrbuf, nelems); - free(arrbuf); + topo_mod_free(mp, arrbuf, (nelems * sizeof (int32_t))); break; case TOPO_TYPE_UINT32_ARRAY: + if ((arrbuf = topo_mod_alloc(mp, (nelems * sizeof (uint32_t)))) + == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { - if ((str = xmlGetProp(xn, (xmlChar *)Value)) + if ((str = xmlGetProp(cn, (xmlChar *)Value)) == NULL) return (-1); @@ -331,14 +306,17 @@ const char *name) rv = nvlist_add_uint32_array(nvl, name, (uint32_t *)arrbuf, nelems); - free(arrbuf); + topo_mod_free(mp, arrbuf, (nelems * sizeof (uint32_t))); break; case TOPO_TYPE_INT64_ARRAY: + if ((arrbuf = topo_mod_alloc(mp, (nelems * sizeof (int64_t)))) + == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { - if ((str = xmlGetProp(xn, (xmlChar *)Value)) + if ((str = xmlGetProp(cn, (xmlChar *)Value)) == NULL) return (-1); @@ -350,14 +328,17 @@ const char *name) rv = nvlist_add_int64_array(nvl, name, (int64_t *)arrbuf, nelems); - free(arrbuf); + topo_mod_free(mp, arrbuf, (nelems * sizeof (int64_t))); break; case TOPO_TYPE_UINT64_ARRAY: + if ((arrbuf = topo_mod_alloc(mp, (nelems * sizeof (uint64_t)))) + == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { - if ((str = xmlGetProp(xn, (xmlChar *)Value)) + if ((str = xmlGetProp(cn, (xmlChar *)Value)) == NULL) return (-1); @@ -369,9 +350,12 @@ const char *name) rv = nvlist_add_uint64_array(nvl, name, arrbuf, nelems); - free(arrbuf); + topo_mod_free(mp, arrbuf, (nelems * sizeof (uint64_t))); break; case TOPO_TYPE_STRING_ARRAY: + if ((strarrbuf = topo_mod_alloc(mp, (nelems * sizeof (char *)))) + == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { @@ -390,11 +374,14 @@ const char *name) strarr_free(mp, strarrbuf, nelems); break; case TOPO_TYPE_FMRI_ARRAY: + if ((nvlarrbuf = topo_mod_alloc(mp, (nelems * + sizeof (nvlist_t *)))) == NULL) + return (topo_mod_seterrno(mp, ETOPO_NOMEM)); for (cn = xn->xmlChildrenNode; cn != NULL; cn = cn->next) { if ((xmlStrcmp(cn->name, (xmlChar *)Propitem) == 0) || (xmlStrcmp(cn->name, (xmlChar *)Argitem) == 0)) { - if ((str = xmlGetProp(xn, (xmlChar *)Value)) + if ((str = xmlGetProp(cn, (xmlChar *)Value)) == NULL) return (-1); @@ -409,7 +396,7 @@ const char *name) rv = nvlist_add_nvlist_array(nvl, name, nvlarrbuf, nelems); - free(nvlarrbuf); + topo_mod_free(mp, nvlarrbuf, (nelems * sizeof (nvlist_t *))); break; } -- cgit v1.2.3 From be93bc991e25533dcbeb10e952fe0b9314390d90 Mon Sep 17 00:00:00 2001 From: Vitaliy Gusev Date: Wed, 15 Nov 2017 01:12:20 +0300 Subject: 8806 xattr_dir_inactive() releases used vnode with kernel panic Reviewed by: Marcel Telka Reviewed by: Gordon Ross Approved by: Dan McDonald --- usr/src/uts/common/fs/xattr.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/fs/xattr.c b/usr/src/uts/common/fs/xattr.c index 7373aaddbe..0c5ddde20d 100644 --- a/usr/src/uts/common/fs/xattr.c +++ b/usr/src/uts/common/fs/xattr.c @@ -1457,22 +1457,15 @@ xattr_dir_readdir(vnode_t *dvp, uio_t *uiop, cred_t *cr, int *eofp, static void xattr_dir_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) { - gfs_file_t *fp; - xattr_dir_t *xattr_dir; - vnode_t *real_vp = NULL; + xattr_dir_t *dp; - mutex_enter(&vp->v_lock); - xattr_dir = vp->v_data; - if (xattr_dir->xattr_realvp) { - real_vp = xattr_dir->xattr_realvp; - xattr_dir->xattr_realvp = NULL; - } - mutex_exit(&vp->v_lock); - if (real_vp != NULL) - VN_RELE(real_vp); - fp = gfs_dir_inactive(vp); - if (fp != NULL) { - kmem_free(fp, fp->gfs_size); + dp = gfs_dir_inactive(vp); /* will track v_count */ + if (dp != NULL) { + /* vp was freed */ + if (dp->xattr_realvp != NULL) + VN_RELE(dp->xattr_realvp); + + kmem_free(dp, ((gfs_file_t *)dp)->gfs_size); } } -- cgit v1.2.3 From b1b183574d0cf2bf3accbbf7717d88bdc3bbfc33 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 12 Jan 2018 14:37:27 +0200 Subject: 8952 VMware Workstation NVMe model is of "Unknown class of pci/pnpbios device" value Reviewed by: Igor Kozhukhov Reviewed by: Hans Rosenfeld Reviewed by: Yuri Pankov Reviewed by: Michal Nowak Approved by: Dan McDonald --- usr/src/common/pci/pci_strings.c | 3 +++ usr/src/common/pci/pci_strings.h | 2 -- usr/src/uts/common/sys/pci.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'usr/src') diff --git a/usr/src/common/pci/pci_strings.c b/usr/src/common/pci/pci_strings.c index fc322641ad..615e3d626c 100644 --- a/usr/src/common/pci/pci_strings.c +++ b/usr/src/common/pci/pci_strings.c @@ -47,6 +47,9 @@ const pci_class_strings_t class_pci[] = { 1, 6, 2, "Serial Storage Bus Interface", "sata", 1, 7, 0, "Serial Attached SCSI Controller", "sas", 1, 7, 1, "Serial Storage Bus Interface", "sas", + 1, 8, 0, "Non-Volatile memory controller", "unknown", + 1, 8, 1, "NVMHCI", "unknown", + 1, 8, 2, "NVM Express", "nvme", 1, 0x80, 0, "Mass storage controller", "unknown", 2, 0, 0, "Ethernet controller", "etherne", diff --git a/usr/src/common/pci/pci_strings.h b/usr/src/common/pci/pci_strings.h index 351d18da81..bea94aad68 100644 --- a/usr/src/common/pci/pci_strings.h +++ b/usr/src/common/pci/pci_strings.h @@ -28,8 +28,6 @@ #ifndef _PCI_STRINGS_H #define _PCI_STRINGS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif diff --git a/usr/src/uts/common/sys/pci.h b/usr/src/uts/common/sys/pci.h index de0cb3e808..364fd0f37e 100644 --- a/usr/src/uts/common/sys/pci.h +++ b/usr/src/uts/common/sys/pci.h @@ -235,6 +235,7 @@ extern "C" { #define PCI_MASS_ATA 0x5 /* ATA Controller */ #define PCI_MASS_SATA 0x6 /* Serial ATA */ #define PCI_MASS_SAS 0x7 /* Serial Attached SCSI (SAS) Cntrlr */ +#define PCI_MASS_NVME 0x8 /* Non-Volatile memory controller */ #define PCI_MASS_OTHER 0x80 /* Other Mass Storage Controller */ /* -- cgit v1.2.3 From 01a059ee0cdece49f47fd4d70086dd5bc7d0b0ff Mon Sep 17 00:00:00 2001 From: Roman Strashkin Date: Thu, 21 Dec 2017 00:25:13 +0300 Subject: 8856 arc_cksum_is_equal() doesn't take into account ABD-logic Reviewed by: Matthew Ahrens Reviewed by: George Wilson Approved by: Gordon Ross --- usr/src/uts/common/fs/zfs/arc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/fs/zfs/arc.c b/usr/src/uts/common/fs/zfs/arc.c index 9fe3d3a170..df319810b5 100644 --- a/usr/src/uts/common/fs/zfs/arc.c +++ b/usr/src/uts/common/fs/zfs/arc.c @@ -23,7 +23,7 @@ * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2017 by Delphix. All rights reserved. * Copyright (c) 2014 by Saso Kiselkov. All rights reserved. - * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. */ /* @@ -1547,8 +1547,9 @@ arc_cksum_is_equal(arc_buf_hdr_t *hdr, zio_t *zio) uint64_t lsize = HDR_GET_LSIZE(hdr); uint64_t csize; - void *cbuf = zio_buf_alloc(HDR_GET_PSIZE(hdr)); - csize = zio_compress_data(compress, zio->io_abd, cbuf, lsize); + abd_t *cdata = abd_alloc_linear(HDR_GET_PSIZE(hdr), B_TRUE); + csize = zio_compress_data(compress, zio->io_abd, + abd_to_buf(cdata), lsize); ASSERT3U(csize, <=, HDR_GET_PSIZE(hdr)); if (csize < HDR_GET_PSIZE(hdr)) { @@ -1564,10 +1565,10 @@ arc_cksum_is_equal(arc_buf_hdr_t *hdr, zio_t *zio) * and zero out any part that should not contain * data. */ - bzero((char *)cbuf + csize, HDR_GET_PSIZE(hdr) - csize); + abd_zero_off(cdata, csize, HDR_GET_PSIZE(hdr) - csize); csize = HDR_GET_PSIZE(hdr); } - zio_push_transform(zio, cbuf, csize, HDR_GET_PSIZE(hdr), NULL); + zio_push_transform(zio, cdata, csize, HDR_GET_PSIZE(hdr), NULL); } /* -- cgit v1.2.3 From 301fd1d6f25595cd8c6d6795f39c72d97aff8cd9 Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Mon, 6 Nov 2017 15:13:23 -0800 Subject: 8959 Add notifications when a scrub is paused or resumed Reviewed by: Alek Pinchuk Reviewed by: Matthew Ahrens Approved by: Gordon Ross --- usr/src/uts/common/fs/zfs/dsl_scan.c | 6 +++++- usr/src/uts/common/sys/sysevent/eventdefs.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/fs/zfs/dsl_scan.c b/usr/src/uts/common/fs/zfs/dsl_scan.c index 9d950d853d..f1a6649199 100644 --- a/usr/src/uts/common/fs/zfs/dsl_scan.c +++ b/usr/src/uts/common/fs/zfs/dsl_scan.c @@ -364,6 +364,7 @@ dsl_scan_cancel_sync(void *arg, dmu_tx_t *tx) dsl_scan_done(scn, B_FALSE, tx); dsl_scan_sync_state(scn, tx); + spa_event_notify(scn->scn_dp->dp_spa, NULL, NULL, ESC_ZFS_SCRUB_ABORT); } int @@ -418,6 +419,7 @@ dsl_scrub_pause_resume_sync(void *arg, dmu_tx_t *tx) spa->spa_scan_pass_scrub_pause = gethrestime_sec(); scn->scn_phys.scn_flags |= DSF_SCRUB_PAUSED; dsl_scan_sync_state(scn, tx); + spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_PAUSED); } else { ASSERT3U(*cmd, ==, POOL_SCRUB_NORMAL); if (dsl_scan_is_paused_scrub(scn)) { @@ -2027,8 +2029,10 @@ dsl_scan(dsl_pool_t *dp, pool_scan_func_t func) /* got scrub start cmd, resume paused scrub */ int err = dsl_scrub_set_pause_resume(scn->scn_dp, POOL_SCRUB_NORMAL); - if (err == 0) + if (err == 0) { + spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_RESUME); return (ECANCELED); + } return (SET_ERROR(err)); } diff --git a/usr/src/uts/common/sys/sysevent/eventdefs.h b/usr/src/uts/common/sys/sysevent/eventdefs.h index f28c32c7a7..cf6e040ee9 100644 --- a/usr/src/uts/common/sys/sysevent/eventdefs.h +++ b/usr/src/uts/common/sys/sysevent/eventdefs.h @@ -203,6 +203,9 @@ extern "C" { #define ESC_ZFS_CONFIG_SYNC "ESC_ZFS_config_sync" #define ESC_ZFS_SCRUB_START "ESC_ZFS_scrub_start" #define ESC_ZFS_SCRUB_FINISH "ESC_ZFS_scrub_finish" +#define ESC_ZFS_SCRUB_ABORT "ESC_ZFS_scrub_abort" +#define ESC_ZFS_SCRUB_RESUME "ESC_ZFS_scrub_resume" +#define ESC_ZFS_SCRUB_PAUSED "ESC_ZFS_scrub_paused" #define ESC_ZFS_VDEV_SPARE "ESC_ZFS_vdev_spare" #define ESC_ZFS_BOOTFS_VDEV_ATTACH "ESC_ZFS_bootfs_vdev_attach" #define ESC_ZFS_POOL_REGUID "ESC_ZFS_pool_reguid" -- cgit v1.2.3 From b10f758d69dd151326d3859af7e1d857ec9a6355 Mon Sep 17 00:00:00 2001 From: Rob Johnston Date: Thu, 11 Jan 2018 16:58:45 -0800 Subject: 8963 default chunk size used by ipmi_fru_read() is too large for some SP's Reviewed by: Yuri Pankov Approved by: Richard Lowe --- usr/src/lib/libipmi/common/ipmi_fru.c | 38 +++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'usr/src') diff --git a/usr/src/lib/libipmi/common/ipmi_fru.c b/usr/src/lib/libipmi/common/ipmi_fru.c index d652c23cd4..b03198b614 100644 --- a/usr/src/lib/libipmi/common/ipmi_fru.c +++ b/usr/src/lib/libipmi/common/ipmi_fru.c @@ -22,9 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" - +/* + * Copyright (c) 2017, Joyent, Inc. + */ #include #include @@ -36,6 +36,13 @@ */ #define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU)) +/* + * The default and minimum size in bytes that will be used when reading + * the FRU inventory area. + */ +#define DEF_CHUNK_SZ 128 +#define MIN_CHUNK_SZ 16 + typedef struct ipmi_fru_read { uint8_t ifr_devid; @@ -52,7 +59,8 @@ int ipmi_fru_read(ipmi_handle_t *ihp, ipmi_sdr_fru_locator_t *fru_loc, char **buf) { ipmi_cmd_t cmd, *resp; - uint8_t count, devid; + int ierrno; + uint8_t count, devid, chunksz; uint16_t sz, offset = 0; ipmi_fru_read_t cmd_data_in; char *tmp; @@ -82,14 +90,15 @@ ipmi_fru_read(ipmi_handle_t *ihp, ipmi_sdr_fru_locator_t *fru_loc, char **buf) return (-1); } + chunksz = DEF_CHUNK_SZ; while (offset < sz) { cmd_data_in.ifr_devid = devid; cmd_data_in.ifr_offset_lsb = BITX(offset, 7, 0); cmd_data_in.ifr_offset_msb = BITX(offset, 15, 8); - if ((sz - offset) < 128) + if ((sz - offset) < chunksz) cmd_data_in.ifr_count = sz - offset; else - cmd_data_in.ifr_count = 128; + cmd_data_in.ifr_count = chunksz; cmd.ic_netfn = IPMI_NETFN_STORAGE; cmd.ic_cmd = IPMI_CMD_READ_FRU_DATA; @@ -97,7 +106,24 @@ ipmi_fru_read(ipmi_handle_t *ihp, ipmi_sdr_fru_locator_t *fru_loc, char **buf) cmd.ic_dlen = sizeof (ipmi_fru_read_t); cmd.ic_lun = 0; + /* + * The FRU area must be read in chunks as its total size will + * be larger than what would fit in a single message. The + * maximum size of a message can vary between platforms so + * if while attempting to read a chunk we receive an error code + * indicating that the requested chunk size is invalid, we will + * perform a reverse exponential backoff of the chunk size until + * either the read succeeds or we hit bottom, at which point + * we'll fail the operation. + */ if ((resp = ipmi_send(ihp, &cmd)) == NULL) { + ierrno = ipmi_errno(ihp); + if (chunksz > MIN_CHUNK_SZ && + (ierrno == EIPMI_DATA_LENGTH_EXCEEDED || + ierrno == EIPMI_INVALID_REQUEST)) { + chunksz = chunksz >> 1; + continue; + } free(tmp); return (-1); } -- cgit v1.2.3