/* * Return the current root filesystem block device name. This is only valid * when root is either a slice, a stripe or a mirror. */ mdname_t * meta_get_current_root_dev( mdsetname_t *sp, md_error_t *ep ) { md_stripe_t *stripep; md_mirror_t *mirrorp; md_row_t *rp; md_comp_t *cp; mdname_t *rootnp; void *curroot; char *miscname; int smi; if ((curroot = meta_get_current_root(ep)) == NULL) return (NULL); if ((rootnp = metaname(&sp, curroot, UNKNOWN, ep)) == NULL) return (NULL); if (metaismeta(rootnp)) { if ((miscname = metagetmiscname(rootnp, ep)) == NULL) return (NULL); if ((strcmp(miscname, MD_MIRROR) == 0) && ((mirrorp = meta_get_mirror(sp, rootnp, ep)) != NULL)) { for (smi = 0; smi < NMIRROR; smi++) { md_submirror_t *mdsp = &mirrorp->submirrors[smi]; rootnp = mdsp->submirnamep; /* skip unused submirrors */ if (rootnp == NULL) { assert(mdsp->state == SMS_UNUSED); continue; } if ((miscname = metagetmiscname(rootnp, ep)) == NULL) { (void) mdmderror(ep, MDE_UNKNOWN_TYPE, meta_getminor(rootnp->dev), rootnp->cname); return (NULL); } break; } } if ((strcmp(miscname, MD_STRIPE) == 0) && ((stripep = meta_get_stripe(sp, rootnp, ep)) != NULL)) { rp = &stripep->rows.rows_val[0]; cp = &rp->comps.comps_val[0]; if (metachkcomp(cp->compnamep, ep) == 0) return (cp->compnamep); } /* Root is not a single stripe metadevice */ (void) mddeverror(ep, MDE_INV_ROOT, rootnp->dev, rootnp->cname); return (NULL); } else return (rootnp); }
int get_namelist(mdnamelist_t **transdevlist, mdnamelist_t **devlist, char *dev_type) { mdnamelist_t *np, *prevp; md_error_t e = mdnullerror; char *type_name; int i = 0; prevp = np = *transdevlist; while (np) { if ((type_name = metagetmiscname(np->namep, &e)) == NULL) { *devlist = NULL; return (-1); } if (strcmp(type_name, dev_type) == 0) { /* move it to the devlist */ add_to_list(&np, &prevp, devlist); i++; } else { prevp = np; np = np->next; } } return (i); }
/* * resync raid */ int meta_raid_resync( mdsetname_t *sp, mdname_t *raidnp, daddr_t size, md_error_t *ep ) { char *miscname; md_resync_ioctl_t ri; /* should have a set */ assert(sp != NULL); assert(sp->setno == MD_MIN2SET(meta_getminor(raidnp->dev))); /* make sure we have a raid */ if ((miscname = metagetmiscname(raidnp, ep)) == NULL) return (-1); if (strcmp(miscname, MD_RAID) != 0) { return (mdmderror(ep, MDE_NOT_RAID, meta_getminor(raidnp->dev), raidnp->cname)); } /* start resync */ (void) memset(&ri, 0, sizeof (ri)); MD_SETDRIVERNAME(&ri, MD_RAID, sp->setno); ri.ri_mnum = meta_getminor(raidnp->dev); ri.ri_copysize = size; if (metaioctl(MD_IOCSETSYNC, &ri, &ri.mde, raidnp->cname) != 0) return (mdstealerror(ep, &ri.mde)); /* return success */ return (0); }
/* * grow generic device */ int meta_concat_generic( mdsetname_t *sp, mdname_t *namep, u_longlong_t big_or_little, md_error_t *ep ) { md_grow_params_t mgp; char *miscname; /* should have a set */ assert(sp != NULL); assert(sp->setno == MD_MIN2SET(meta_getminor(namep->dev))); /* get type */ if ((miscname = metagetmiscname(namep, ep)) == NULL) return (-1); /* grow device */ (void) memset(&mgp, 0, sizeof (mgp)); if (big_or_little & MD_64BIT_META_DEV) mgp.options = MD_CRO_64BIT; else mgp.options = MD_CRO_32BIT; mgp.mnum = meta_getminor(namep->dev); MD_SETDRIVERNAME(&mgp, miscname, sp->setno); if (metaioctl(MD_IOCGROW, &mgp, &mgp.mde, namep->cname) != 0) return (mdstealerror(ep, &mgp.mde)); /* clear cache */ meta_invalidate_name(namep); /* return success */ return (0); }