Print this page
8074 need to add FMA event for SSD wearout

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/libdiskstatus/common/libdiskstatus.c
          +++ new/usr/src/lib/fm/libdiskstatus/common/libdiskstatus.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  24   25   */
  25   26  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   27  /*
  29   28   * Disk status library
  30   29   *
  31   30   * This library is responsible for querying health and other status information
  32   31   * from disk drives.  It is intended to be a generic interface, however only
  33   32   * SCSI (and therefore SATA) disks are currently supported.  The library is
  34   33   * capable of detecting the following status conditions:
  35   34   *
  36      - *      - Predictive failure
  37      - *      - Overtemp
  38      - *      - Self-test failure
       35 + *      - Predictive failure
       36 + *      - Overtemp
       37 + *      - Self-test failure
       38 + *      - Solid State Media wearout
  39   39   */
  40   40  
  41   41  #include <assert.h>
  42   42  #include <errno.h>
  43   43  #include <fcntl.h>
  44   44  #include <libdevinfo.h>
  45   45  #include <libdiskstatus.h>
  46   46  #include <stdlib.h>
  47   47  #include <string.h>
  48   48  #include <sys/fm/io/scsi.h>
↓ open down ↓ 75 lines elided ↑ open up ↑
 124  124  /*
 125  125   * Close a handle to a disk.
 126  126   */
 127  127  void
 128  128  disk_status_close(disk_status_t *dsp)
 129  129  {
 130  130          nvlist_free(dsp->ds_state);
 131  131          nvlist_free(dsp->ds_predfail);
 132  132          nvlist_free(dsp->ds_overtemp);
 133  133          nvlist_free(dsp->ds_testfail);
      134 +        nvlist_free(dsp->ds_ssmwearout);
 134  135          if (dsp->ds_data)
 135  136                  dsp->ds_transport->dt_close(dsp->ds_data);
 136  137          (void) close(dsp->ds_fd);
 137  138          free(dsp->ds_path);
 138  139          free(dsp);
 139  140  }
 140  141  
 141  142  void
 142  143  disk_status_set_debug(boolean_t value)
 143  144  {
↓ open down ↓ 21 lines elided ↑ open up ↑
 165  166          nvlist_t *nvl = NULL;
 166  167          nvlist_t *faults = NULL;
 167  168          int err;
 168  169  
 169  170          /*
 170  171           * Scan (or rescan) the current device.
 171  172           */
 172  173          nvlist_free(dsp->ds_testfail);
 173  174          nvlist_free(dsp->ds_predfail);
 174  175          nvlist_free(dsp->ds_overtemp);
      176 +        nvlist_free(dsp->ds_ssmwearout);
      177 +        dsp->ds_ssmwearout = NULL;
 175  178          dsp->ds_testfail = dsp->ds_overtemp = dsp->ds_predfail = NULL;
 176  179          dsp->ds_faults = 0;
 177  180  
 178  181          /*
 179  182           * Even if there is an I/O failure when trying to scan the device, we
 180  183           * can still return the current state.
 181  184           */
 182  185          if (dsp->ds_transport->dt_scan(dsp->ds_data) != 0 &&
 183  186              dsp->ds_error != EDS_IO)
 184  187                  return (NULL);
↓ open down ↓ 30 lines elided ↑ open up ↑
 215  218          }
 216  219  
 217  220          if (dsp->ds_overtemp != NULL) {
 218  221                  if ((err = nvlist_add_boolean_value(faults,
 219  222                      FM_EREPORT_SCSI_OVERTEMP,
 220  223                      (dsp->ds_faults & DS_FAULT_OVERTEMP) != 0)) != 0 ||
 221  224                      (err = nvlist_add_nvlist(nvl, FM_EREPORT_SCSI_OVERTEMP,
 222  225                      dsp->ds_overtemp)) != 0)
 223  226                          goto nverror;
 224  227          }
      228 +
      229 +        if (dsp->ds_ssmwearout != NULL) {
      230 +                if ((err = nvlist_add_boolean_value(faults,
      231 +                    FM_EREPORT_SCSI_SSMWEAROUT,
      232 +                    (dsp->ds_faults & DS_FAULT_SSMWEAROUT) != 0)) != 0 ||
      233 +                    (err = nvlist_add_nvlist(nvl, FM_EREPORT_SCSI_SSMWEAROUT,
      234 +                    dsp->ds_ssmwearout)) != 0)
      235 +                        goto nverror;
      236 +        }
 225  237  
 226  238          if ((err = nvlist_add_nvlist(nvl, "faults", faults)) != 0)
 227  239                  goto nverror;
 228  240  
 229  241          nvlist_free(faults);
 230  242          return (nvl);
 231  243  
 232  244  nverror:
 233  245          assert(err == ENOMEM);
 234  246          nvlist_free(nvl);
 235  247          nvlist_free(faults);
 236  248          (void) ds_set_errno(dsp, EDS_NOMEM);
 237  249          return (NULL);
 238  250  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX