10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1623Stw21770 * Common Development and Distribution License (the "License"). 6*1623Stw21770 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1623Stw21770 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * replace components in metadevices 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <meta.h> 330Sstevel@tonic-gate #include <sys/lvm/md_stripe.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * replace named device 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate int 390Sstevel@tonic-gate meta_replace_byname( 400Sstevel@tonic-gate mdsetname_t *sp, 410Sstevel@tonic-gate mdname_t *np, 420Sstevel@tonic-gate mdname_t *oldnp, 430Sstevel@tonic-gate mdname_t *newnp, 440Sstevel@tonic-gate mdcmdopts_t options, 450Sstevel@tonic-gate md_error_t *ep 460Sstevel@tonic-gate ) 470Sstevel@tonic-gate { 480Sstevel@tonic-gate char *miscname; 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* should have a set */ 510Sstevel@tonic-gate assert(sp != NULL); 520Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(np->dev))); 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* get type */ 550Sstevel@tonic-gate if (metachkmeta(np, ep) != 0) 560Sstevel@tonic-gate return (-1); 570Sstevel@tonic-gate if ((miscname = metagetmiscname(np, ep)) == NULL) 580Sstevel@tonic-gate return (-1); 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* dispatch */ 610Sstevel@tonic-gate if (strcmp(miscname, MD_RAID) == 0) { 620Sstevel@tonic-gate return (meta_raid_replace(sp, np, oldnp, newnp, options, ep)); 630Sstevel@tonic-gate } else if (strcmp(miscname, MD_MIRROR) == 0) { 640Sstevel@tonic-gate return (meta_mirror_replace(sp, np, oldnp, newnp, options, ep)); 650Sstevel@tonic-gate } else { 660Sstevel@tonic-gate return (mdmderror(ep, MDE_UNKNOWN_TYPE, meta_getminor(np->dev), 670Sstevel@tonic-gate np->cname)); 680Sstevel@tonic-gate } 690Sstevel@tonic-gate } 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * enable named device 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate int 750Sstevel@tonic-gate meta_enable_byname( 760Sstevel@tonic-gate mdsetname_t *sp, 770Sstevel@tonic-gate mdname_t *np, 780Sstevel@tonic-gate mdname_t *compnp, 790Sstevel@tonic-gate mdcmdopts_t options, 800Sstevel@tonic-gate md_error_t *ep 810Sstevel@tonic-gate ) 820Sstevel@tonic-gate { 830Sstevel@tonic-gate char *miscname; 840Sstevel@tonic-gate 850Sstevel@tonic-gate /* should have a set */ 860Sstevel@tonic-gate assert(sp != NULL); 870Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(np->dev))); 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* get type */ 900Sstevel@tonic-gate if (metachkmeta(np, ep) != 0) 910Sstevel@tonic-gate return (-1); 920Sstevel@tonic-gate if ((miscname = metagetmiscname(np, ep)) == NULL) 930Sstevel@tonic-gate return (-1); 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* dispatch */ 960Sstevel@tonic-gate if (strcmp(miscname, MD_RAID) == 0) { 970Sstevel@tonic-gate return (meta_raid_enable(sp, np, compnp, options, ep)); 980Sstevel@tonic-gate } else if (strcmp(miscname, MD_MIRROR) == 0) { 990Sstevel@tonic-gate return (meta_mirror_enable(sp, np, compnp, options, ep)); 1000Sstevel@tonic-gate } else { 1010Sstevel@tonic-gate return (mdmderror(ep, MDE_UNKNOWN_TYPE, meta_getminor(np->dev), 1020Sstevel@tonic-gate np->cname)); 1030Sstevel@tonic-gate } 1040Sstevel@tonic-gate } 105