fault_mgr.c revision 724365f7556fc4201fdb11766ebc6bd918523130
/*
* 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"
#include <assert.h>
#include <atomic.h>
#include <time.h>
#include "sfx4500-disk.h"
#include "fault_mgr.h"
#include "schg_mgr.h"
/* Fault-polling thread data */
static boolean_t
{
/*
* Errors accessing the disk are not counted as faults:
*/
}
static void
{
/* We just want the low bits of hrtime anyway */
}
}
static void
{
} else if (diskp->fault_inject_count != 0 &&
diskp->analysis_generation = 0;
} else {
}
}
/*
* The fault monitor thread polls each disk in the disk list, at the
* fault polling frequency specified in the global property (or the default
* if no such property exists). This thread is also responsible for injecting
* fake faults, in accordance with the global fault injection property.
*
* When the thread starts, it performs a fault analysis on each disk whose
* `due' time is 0 (disks that have not yet been analyzed), then sets the
* due time to the current time + the fault polling interval.
*/
static void
{
int i;
== 0)
fault_polling_interval = (time_t)i;
== 0 && i > 0) {
}
while (g_fmt_req_state != TS_EXIT_REQUESTED) {
/*
* Analyze all disks that are due for analysis
*/
earliest_due = -1;
/*
* If the disk is configured (it has a device node
* associated with it that we can talk to), and if
* there are no faults outstanding (faults that we
* previously informed the state-change thread about
* but that may not have been consumed yet), and
* if we're due for a fault analysis, then do one.
*/
!diskp->faults_outstanding &&
}
/* Keep track of the earliest next due time */
== 0);
}
/*
* earliest_due can be < 0 (if no disks were fault-analyzed)
* but it should NEVER be == 0.
*/
if (earliest_due < 0) {
} else if (earliest_due == 0) {
log_warn("BUG: earliest_due time is == 0-- resetting "
"to %ld\n", nexttime);
}
(void) pthread_cond_timedwait(&g_fmt_cvar,
&g_fmt_mutex, &tspec);
}
}
static int
{
/* fmt_thr_create() is guaranteed to succeed or abort */
return (0);
}
static void
{
if (g_fmt_spawned) {
}
}
int
{
int i;
== 0 && i > 0)
else {
return (0);
}
}
/*
* fault_manager_poke wakes up the fault manager thread so it can
* perform initial fault analysis on new disks.
*/
void
fault_manager_poke(void)
{
}
/*ARGSUSED*/
void
{
}