Print this page
3818 zpool status -x should report pools with removed l2arc devices
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: George Wilson <gwilson@zfsmail.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.

  25  */
  26 
  27 /*
  28  * This file contains the functions which analyze the status of a pool.  This
  29  * include both the status of an active pool, as well as the status exported
  30  * pools.  Returns one of the ZPOOL_STATUS_* defines describing the status of
  31  * the pool.  This status is independent (to a certain degree) from the state of
  32  * the pool.  A pool's state describes only whether or not it is capable of
  33  * providing the necessary fault tolerance for data.  The status describes the
  34  * overall status of devices.  A pool that is online can still have a device
  35  * that is experiencing errors.
  36  *
  37  * Only a subset of the possible faults can be detected using 'zpool status',
  38  * and not all possible errors correspond to a FMA message ID.  The explanation
  39  * is left up to the caller, depending on whether it is a live pool or an
  40  * import.
  41  */
  42 
  43 #include <libzfs.h>
  44 #include <string.h>


 133         verify(nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, &type) == 0);
 134         if (strcmp(type, VDEV_TYPE_REPLACING) == 0)
 135                 return (B_FALSE);
 136 
 137         if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, &child,
 138             &children) == 0) {
 139                 for (c = 0; c < children; c++)
 140                         if (find_vdev_problem(child[c], func))
 141                                 return (B_TRUE);
 142         } else {
 143                 verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS,
 144                     (uint64_t **)&vs, &c) == 0);
 145 
 146                 if (func(vs->vs_state, vs->vs_aux,
 147                     vs->vs_read_errors +
 148                     vs->vs_write_errors +
 149                     vs->vs_checksum_errors))
 150                         return (B_TRUE);
 151         }
 152 










 153         return (B_FALSE);
 154 }
 155 
 156 /*
 157  * Active pool health status.
 158  *
 159  * To determine the status for a pool, we make several passes over the config,
 160  * picking the most egregious error we find.  In order of importance, we do the
 161  * following:
 162  *
 163  *      - Check for a complete and valid configuration
 164  *      - Look for any faulted or missing devices in a non-replicated config
 165  *      - Check for any data errors
 166  *      - Check for any faulted or missing devices in a replicated config
 167  *      - Look for any devices showing errors
 168  *      - Check for any resilvering devices
 169  *
 170  * There can obviously be multiple errors within a single pool, so this routine
 171  * only picks the most damaging of all the current errors to report.
 172  */




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  26  */
  27 
  28 /*
  29  * This file contains the functions which analyze the status of a pool.  This
  30  * include both the status of an active pool, as well as the status exported
  31  * pools.  Returns one of the ZPOOL_STATUS_* defines describing the status of
  32  * the pool.  This status is independent (to a certain degree) from the state of
  33  * the pool.  A pool's state describes only whether or not it is capable of
  34  * providing the necessary fault tolerance for data.  The status describes the
  35  * overall status of devices.  A pool that is online can still have a device
  36  * that is experiencing errors.
  37  *
  38  * Only a subset of the possible faults can be detected using 'zpool status',
  39  * and not all possible errors correspond to a FMA message ID.  The explanation
  40  * is left up to the caller, depending on whether it is a live pool or an
  41  * import.
  42  */
  43 
  44 #include <libzfs.h>
  45 #include <string.h>


 134         verify(nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, &type) == 0);
 135         if (strcmp(type, VDEV_TYPE_REPLACING) == 0)
 136                 return (B_FALSE);
 137 
 138         if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, &child,
 139             &children) == 0) {
 140                 for (c = 0; c < children; c++)
 141                         if (find_vdev_problem(child[c], func))
 142                                 return (B_TRUE);
 143         } else {
 144                 verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS,
 145                     (uint64_t **)&vs, &c) == 0);
 146 
 147                 if (func(vs->vs_state, vs->vs_aux,
 148                     vs->vs_read_errors +
 149                     vs->vs_write_errors +
 150                     vs->vs_checksum_errors))
 151                         return (B_TRUE);
 152         }
 153 
 154         /*
 155          * Check any L2 cache devs
 156          */
 157         if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_L2CACHE, &child,
 158             &children) == 0) {
 159                 for (c = 0; c < children; c++)
 160                         if (find_vdev_problem(child[c], func))
 161                                 return (B_TRUE);
 162         }
 163 
 164         return (B_FALSE);
 165 }
 166 
 167 /*
 168  * Active pool health status.
 169  *
 170  * To determine the status for a pool, we make several passes over the config,
 171  * picking the most egregious error we find.  In order of importance, we do the
 172  * following:
 173  *
 174  *      - Check for a complete and valid configuration
 175  *      - Look for any faulted or missing devices in a non-replicated config
 176  *      - Check for any data errors
 177  *      - Check for any faulted or missing devices in a replicated config
 178  *      - Look for any devices showing errors
 179  *      - Check for any resilvering devices
 180  *
 181  * There can obviously be multiple errors within a single pool, so this routine
 182  * only picks the most damaging of all the current errors to report.
 183  */