src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
/*
 * Spares are tracked globally due to the following constraints:
 *
 *	- A spare may be part of multiple pools.
 *	- A spare may be added to a pool even if it's actively in use within
 *	  another pool.
 *	- A spare in use in any pool can only be the source of a replacement if
 *	  the target is a spare in the same pool.
 *
 * We keep track of all spares on the system through the use of a reference
 * counted AVL tree.  When a vdev is added as a spare, or used as a replacement
 * spare, then we bump the reference count in the AVL tree.  In addition, we set
 * the 'vdev_isspare' member to indicate that the device is a spare (active or
 * inactive).  When a spare is made active (used to replace a device in the
 * pool), we also keep track of which pool its been made a part of.
 *
 * The 'spa_spare_lock' protects the AVL tree.  These functions are normally
 * called under the spa_namespace lock as part of vdev reconfiguration.  The
 * separate spare lock exists for the status query path, which does not need to
 * be completely consistent with respect to other vdev configuration changes.
 */
Spares are tracked globally due to the following constraints:
- A spare may be part of multiple pools.
- A spare may be added to a pool even if it's actively in use within
another pool.
- A spare in use in any pool can only be the source of a replacement if
the target is a spare in the same pool.

We keep track of all spares on the system through the use of a reference
counted AVL tree.  When a vdev is added as a spare, or used as a replacement
spare, then we bump the reference count in the AVL tree.  In addition, we set
the 'vdev_isspare' member to indicate that the device is a spare (active or
inactive).  When a spare is made active (used to replace a device in the
pool), we also keep track of which pool its been made a part of.

The 'spa_spare_lock' protects the AVL tree.  These functions are normally
called under the spa_namespace lock as part of vdev reconfiguration.  The
separate spare lock exists for the status query path, which does not need to
be completely consistent with respect to other vdev configuration changes.
Spares are tracked globally due to the following constraints : - A spare may be part of multiple pools . - A spare may be added to a pool even if it ' s actively in use within another pool . - A spare in use in any pool can only be the source of a replacement if the target is a spare in the same pool . We keep track of all spares on the system through the use of a reference counted AVL tree . When a vdev is added as a spare or used as a replacement spare then we bump the reference count in the AVL tree . In addition we set the ' vdev_isspare ' member to indicate that the device is a spare ( active or inactive ) . When a spare is made active ( used to replace a device in the pool ) we also keep track of which pool its been made a part of . The ' spa_spare_lock ' protects the AVL tree . These functions are normally called under the spa_namespace lock as part of vdev reconfiguration . The separate spare lock exists for the status query path which does not need to be completely consistent with respect to other vdev configuration changes .
static int
spa_spare_compare(const void *a, const void *b)
{
	return (spa_aux_compare(a, b));
}
static int spa_spare_compare ( const void * a , const void * b ) { return ( spa_aux_compare ( a , b ) ) ; }
Spares are tracked globally due to the following constraints:
      - A spare may be part of multiple pools.
Spares are tracked globally due to the following constraints : - A spare may be part of multiple pools .