zfs_retire.c revision 99653d4ee642c6528e88224f12409a5f23060994
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The ZFS retire agent is responsible for managing hot spares across all pools.
* When we see a device fault, 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.
*/
#include <libzfs.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);
}
/*ARGSUSED*/
static void
const char *class)
{
char *dev_name;
/*
* Get information from the fault.
*/
return;
for (f = 0; f < nfaults; f++) {
&resource) != 0 ||
&pool_guid) != 0 ||
&vdev_guid) != 0)
continue;
/*
* From the pool guid and vdev guid, get the pool name and
* device name.
*/
continue;
&nvroot) != 0) {
continue;
}
continue;
}
/*
* Find out if there are any hot spares available in the pool.
*/
continue;
}
continue;
}
VDEV_TYPE_ROOT) != 0) {
continue;
}
/*
* 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;
}
}
}
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
{
}