zfs_retire.c revision 88ecc943b4eb72f7c4fbbd8435997b85ef171fc3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The ZFS retire agent is responsible for managing hot spares across all pools.
* When we see a device fault or a device removal, we try to open the associated
* pool and look for any hot spares. We iterate over any available hot spares
* and attempt a 'zpool replace' for each one.
*
* For vdevs diagnosed as faulty, the agent is also responsible for proactively
* marking the vdev FAULTY (for I/O errors) or DEGRADED (for checksum errors).
*/
#include <libzfs.h>
#include <string.h>
/*
* Find a pool with a matching GUID.
*/
typedef struct find_cbdata {
static int
{
return (1);
}
return (0);
}
/*
* Find a vdev within a tree with a matching GUID.
*/
static nvlist_t *
{
return (nv);
return (NULL);
for (c = 0; c < children; c++) {
return (ret);
}
return (NULL);
for (c = 0; c < children; c++) {
return (ret);
}
return (NULL);
}
/*
* Given a (pool, vdev) GUID pair, find the matching pool and vdev.
*/
static zpool_handle_t *
{
/*
* Find the corresponding pool and make sure the vdev still exists.
*/
return (NULL);
&nvroot) != 0) {
return (NULL);
}
return (NULL);
}
return (zhp);
}
/*
* Given a vdev, attempt to replace it with every known spare until one
* succeeds.
*/
static void
{
char *dev_name;
&nvroot) != 0)
return;
/*
* Find out if there are any hot spares available in the pool.
*/
return;
return;
VDEV_TYPE_ROOT) != 0) {
return;
}
/*
* Try to replace each spare, ending when we successfully
* replace it.
*/
for (s = 0; s < nspares; s++) {
char *spare_name;
&spare_name) != 0)
continue;
continue;
replacement, B_TRUE) == 0)
break;
}
}
/*ARGSUSED*/
static void
const char *class)
{
char *scheme;
char *uuid;
int repair_done = 0;
/*
* If this is a resource notifying us of device removal, then simply
* check for an available spare and continue.
*/
&pool_guid) != 0 ||
&vdev_guid) != 0)
return;
return;
return;
}
return;
else
/*
* We subscribe to zfs faults as well as all repair events.
*/
return;
for (f = 0; f < nfaults; f++) {
continue;
/*
* While we subscribe to fault.fs.zfs.*, we only take action
* for faults targeting a specific vdev (open failure or SERD
* failure).
*/
"fault.fs.zfs.vdev.checksum"))
else
continue;
&resource) != 0 ||
&scheme) != 0)
continue;
continue;
&pool_guid) != 0 ||
&vdev_guid) != 0)
continue;
continue;
/*
* If this is a repair event, then mark the vdev as repaired and
* continue.
*/
if (is_repair) {
repair_done = 1;
continue;
}
/*
* Actively fault the device if needed.
*/
if (fault_device)
if (degrade_device)
/*
* Attempt to substitute a hot spare.
*/
}
}
static const fmd_hdl_ops_t fmd_ops = {
zfs_retire_recv, /* fmdo_recv */
NULL, /* fmdo_timeout */
NULL, /* fmdo_close */
NULL, /* fmdo_stats */
NULL, /* fmdo_gc */
};
static const fmd_prop_t fmd_props[] = {
};
static const fmd_hdl_info_t fmd_info = {
};
void
{
return;
return;
}
}
void
{
}