probedev.c revision 80148899834a4078a2bd348504aa2d6de9752837
/*
* 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.
*/
#include "md_monitord.h"
#define MD_PROBE_OPEN_T "probe open test"
/*
* Failure return's a 1
*/
int
hotspare_ok(char *bname)
{
int fd;
char buf[512];
return (0);
return (0);
}
return (1);
}
void
{
md_error_t e = mdnullerror;
int deleted_hs = 0;
/* print hotspare */
if (hotspare_ok(bname))
continue;
"NOTICE: Hotspare %s in %s has failed.\n"
"\tDeleting %s since it is not in use\n\n"),
mde_perror(&e, "");
mdclrerror(&e);
} else {
deleted_hs++;
}
} else {
"%s in use - skipping\n"), cname);
}
}
}
/*
* Generic routine to issue probe ioctls
*/
int
{
mdnamelist_t *p;
int i, retval = 0;
/*
* Allocate space for all the metadevices and fill in
* the minor numbers.
*/
== 0) {
monitord_print(0, "md_probe_ioctl: calloc");
return (-1);
}
gettext("local_set") :
}
}
if (issue_ioctl == True) {
retval = -1;
}
return (retval);
}
/*
*
* - remove p from nlp list
* - put it on the toplp list.
* - update the p to the next element
*/
void
{
p = *curpp;
if (prevp == p) {
/* if first element reset prevp */
nlp = p;
p = prevp;
} else {
nlp = p;
}
*curpp = p;
}
/*
* Scans the given list of metadeivces and returns a list of top level
* metadevices.
* Note: The orignal list is not valid at the end and is set to NULL.
*/
int
{
int ntopmd, i;
md_error_t e = mdnullerror;
i = ntopmd = 0;
while (p) {
mdclrerror(&e);
"......error on (%d)%s\n"), i,
p->namep->devicesname);
prevp = p;
p = p->next;
continue;
}
/* increment the top level md count. */
ntopmd++;
} else {
prevp = p;
p = p->next;
}
i++;
}
return (ntopmd);
}
int
char *dev_type)
{
md_error_t e = mdnullerror;
char *type_name;
int i = 0;
while (np) {
mdclrerror(&e);
return (-1);
}
/* move it to the devlist */
i++;
} else {
}
}
return (i);
}
{
return (np);
} else {
/* error condition below */
"create_nlp: malloc failed\n"));
}
return (0);
}
/*
* Create a list of metadevices associated with trans. top_pp points to
* this list. The number of components in the list are also returned.
*/
int
{
int ntoptrans;
md_error_t e = mdnullerror;
md_trans_t *tp;
ntoptrans = 0;
p = *lpp;
/*
* Scan the current list of trans devices. From that
* extract all the lower level metadevices and put them on
* toplp list.
*/
while (p) {
/*
* Check the master and log devices to see if they
* are metadevices
*/
"master metadevice\n"));
/* get a mdnamelist_t. */
newlp = create_nlp();
} else {
}
ntoptrans++;
}
"log metadevice\n"));
newlp = create_nlp();
} else {
}
ntoptrans++;
}
p = p->next;
} else {
mdclrerror(&e);
}
}
return (ntoptrans);
}
void
{
int cnt;
md_error_t e = mdnullerror;
/*
* We have some mirrors to probe
* get a list of top-level mirrors
*/
"probe_mirror_devs: "
"mirror components %d ioctl error\n"),
cnt);
} else {
mdclrerror(&e);
}
}
void
{
int cnt;
md_error_t e = mdnullerror;
/*
* We have some mirrors to probe
* get a list of top-level mirrors
*/
"probe_raid_devs: "
"RAID-5 components %d ioctl error\n"),
cnt);
} else {
mdclrerror(&e);
}
}
/*
* Trans probes are different. -- so whats new.
* we separate out the master and log device and then issue the
* probe calls.
* Since the underlying device could be disk, stripe, RAID or miror,
* we have to sort them out and then call the ioctl for each.
*/
void
{
int cnt;
md_error_t e = mdnullerror;
/*
* get a list of master and log metadevices.
*/
int i;
"tran: underlying drv %s\n"),
}
}
/* underlying RAID-5 components */
"probe_trans_devs: "
"RAID-5 components %d ioctl error\n"),
cnt);
/* underlying mirror components */
"probe_trans_devs: "
"mirror components %d ioctl error\n"),
cnt);
/* underlying stripe components */
"probe_trans_devs: "
"stripe components %d ioctl error\n"),
cnt);
} else {
mdclrerror(&e);
}
}
/*
* probe hot spares. This is differs from other approaches since
* component level and then delete it if its bad.
*/
void
{
mdhspnamelist_t *p;
md_error_t e = mdnullerror;
mdclrerror(&e);
return;
}
continue;
}
}
mdclrerror(&e);
}