/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* NAME: raid_hotspare.c
* DESCRIPTION: RAID driver source file containing routines related to
* hospare operation.
* ROUTINES PROVIDED FOR EXTERNAL USE:
* raid_hs_release() - release a hotspare device
* raid_hotspares() - prompt the hospare daemon to attempt needed hotspare work
*/
#include <sys/sysmacros.h>
extern mdq_anchor_t md_hs_daemon;
extern md_ops_t raid_md_ops;
/*
* NAME: raid_hs_release
*
* DESCRIPTION: Release the hotspare.
*
* PARAMETERS: int error - indication of error on hotspare
* mr_unit_t *un - raid unit
* mddb_recid_t *recids - output records to commit revised hs info
* int hs_index - component to release
*
* LOCKS: Expects Unit Writer Lock to be held across call.
*/
void
int hs_index
)
{
/* close the hotspare device */
}
/* return the hotspare to the pool */
col->un_hs_pwstart = 0;
col->un_hs_devstart = 0;
}
/*
* NAME: check_comp_4_hs
*
* DESCRIPTION: Check whether the input component has an error and can be
* backed with a hot spare (RCS_ERRED state), and initiate
* a resync if so.
*
* PARAMETERS: mr_unit_t *un - raid unit
* int hs_index - component to check
*
* LOCKS: Expects Unit Writer Lock to be held upon entrance. Releases
* the lock prior to calling raid_resync_unit, then reacquires
* it before returning.
*/
static void
int hs_index
)
{
int err;
/* initialize */
(void) md_io_writerlock(ui);
/*
* add a hotspare for erred column only if not resyncing
*/
goto errout;
}
recids[0] = 0;
recids[1] = 0;
/* if there is already a hotspare then just return */
}
/* quit if resync is already active */
goto errout;
recids[0] = 0;
recids[1] = 0;
/* get a hotspare */
goto errout;
}
/*
* record id is filled in by raid_commit, recids[0] filled in by
* md_hot_spare_ifc if needed
*/
recids[1] = 0;
/*
* close the device and open the hot spare. The device should
* never be a hotspare here.
*/
}
/*
* Try open by device id
*/
/* cannot open return to orig */
goto again;
}
/*
* move the values into the device fields. Since in some cases
* the pwstart is not zero this must be added into the start of
* the hotspare to avoid over writting the label
*/
/* commit unit and hotspare records and release lock */
/* if resync fails, transition back to erred state and reset */
if (err) {
/* reaquire unit writerr lock */
/*
* close the hotspare and return it. Then restore the
* original device back to the original state
*/
return;
}
sizeof (devname));
sizeof (hs_devname));
(void) md_unit_readerlock(ui);
return;
}
/*
* NAME: check_4_hs
*
* DESCRIPTION: Check every component of every raid unit for any device which
* needs to be backed with a hot spare.
*
* PARAMETERS: daemon_request_t *dr - hotspare request daemon
*
* LOCKS: Acquires and releases the Hotspare Request Lock and the RAID
* Driver Lock. Acquires the Unit Writer Lock which is released
* in check_comp_4_hs.
*/
static void
{
int i;
/*
* Scan raid unit list and call component hotspare check routine for
* each component of each unit where resync is inactive.
*/
for (i = 0; i < un->un_totalcolumncnt; i++)
check_comp_4_hs(un, i);
}
}
}
/*
* NAME: raid_hotspares
*
* DESCRIPTION: Initiate a check of all RAID devices for components which
* may require a hot spare, if it is not already running.
*
* PARAMETERS: NONE
*
* LOCKS: Acquires and releases the Hotspare Request Lock.
*/
{
/* if available, make request for hotspare to master daemon */
if (hotspare_request.dr_pending == 0) {
}
return (0);
}