static int logpage_selftest_analyze(ds_scsi_info_t *sip, scsi_log_parameter_header_t *lphp, int log_length) { int i, plen = 0; int entries = 0; ushort_t param_code; scsi_selftest_log_param_t *stp; nvlist_t *nvl; assert(sip->si_dsp->ds_testfail == NULL); if (nvlist_alloc(&sip->si_dsp->ds_testfail, NV_UNIQUE_NAME, 0) != 0) return (scsi_set_errno(sip, EDS_NOMEM)); nvl = sip->si_dsp->ds_testfail; for (i = 0; i < log_length; i += plen, entries++) { lphp = (scsi_log_parameter_header_t *)((char *)lphp + plen); param_code = BE_16(lphp->lph_param); stp = (scsi_selftest_log_param_t *)lphp; if (param_code >= LOGPAGE_SELFTEST_MIN_PARAM_CODE && param_code <= LOGPAGE_SELFTEST_MAX_PARAM_CODE && lphp->lph_length >= LOGPAGE_SELFTEST_PARAM_LEN) { /* * We always log the last result, or the result of the * last completed test. */ if ((param_code == 1 || SELFTEST_COMPLETE(stp->st_results))) { if (nvlist_add_uint8(nvl, FM_EREPORT_PAYLOAD_SCSI_RESULTCODE, stp->st_results) != 0 || nvlist_add_uint16(nvl, FM_EREPORT_PAYLOAD_SCSI_TIMESTAMP, BE_16(stp->st_timestamp)) != 0 || nvlist_add_uint8(nvl, FM_EREPORT_PAYLOAD_SCSI_SEGMENT, stp->st_number) != 0 || nvlist_add_uint64(nvl, FM_EREPORT_PAYLOAD_SCSI_ADDRESS, BE_64(stp->st_lba)) != 0) return (scsi_set_errno(sip, EDS_NOMEM)); if (SELFTEST_COMPLETE(stp->st_results)) { if (stp->st_results != SELFTEST_OK) sip->si_dsp->ds_faults |= DS_FAULT_TESTFAIL; return (0); } } } plen = lphp->lph_length + sizeof (scsi_log_parameter_header_t); } return (0); }
/*ARGSUSED*/ void zio_checksum_SHA256(const void *buf, uint64_t size, const void *ctx_template, zio_cksum_t *zcp) { SHA2_CTX ctx; zio_cksum_t tmp; SHA2Init(SHA256, &ctx); SHA2Update(&ctx, buf, size); SHA2Final(&tmp, &ctx); /* * A prior implementation of this function had a * private SHA256 implementation always wrote things out in * Big Endian and there wasn't a byteswap variant of it. * To preseve on disk compatibility we need to force that * behaviour. */ zcp->zc_word[0] = BE_64(tmp.zc_word[0]); zcp->zc_word[1] = BE_64(tmp.zc_word[1]); zcp->zc_word[2] = BE_64(tmp.zc_word[2]); zcp->zc_word[3] = BE_64(tmp.zc_word[3]); }