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 220Sstevel@tonic-gate /* 23*1623Stw21770 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * attach operations 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <meta.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * grow generic device 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate int 390Sstevel@tonic-gate meta_concat_generic( 400Sstevel@tonic-gate mdsetname_t *sp, 410Sstevel@tonic-gate mdname_t *namep, 420Sstevel@tonic-gate u_longlong_t big_or_little, 430Sstevel@tonic-gate md_error_t *ep 440Sstevel@tonic-gate ) 450Sstevel@tonic-gate { 460Sstevel@tonic-gate md_grow_params_t mgp; 470Sstevel@tonic-gate char *miscname; 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* should have a set */ 500Sstevel@tonic-gate assert(sp != NULL); 510Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(namep->dev))); 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* get type */ 540Sstevel@tonic-gate if ((miscname = metagetmiscname(namep, ep)) == NULL) 550Sstevel@tonic-gate return (-1); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* grow device */ 580Sstevel@tonic-gate (void) memset(&mgp, 0, sizeof (mgp)); 59*1623Stw21770 if (big_or_little & MD_64BIT_META_DEV) 600Sstevel@tonic-gate mgp.options = MD_CRO_64BIT; 610Sstevel@tonic-gate else 620Sstevel@tonic-gate mgp.options = MD_CRO_32BIT; 630Sstevel@tonic-gate 640Sstevel@tonic-gate mgp.mnum = meta_getminor(namep->dev); 650Sstevel@tonic-gate MD_SETDRIVERNAME(&mgp, miscname, sp->setno); 660Sstevel@tonic-gate if (metaioctl(MD_IOCGROW, &mgp, &mgp.mde, namep->cname) != 0) 670Sstevel@tonic-gate return (mdstealerror(ep, &mgp.mde)); 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* clear cache */ 700Sstevel@tonic-gate meta_invalidate_name(namep); 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* return success */ 730Sstevel@tonic-gate return (0); 740Sstevel@tonic-gate } 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * grow the parent of a device 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate int 800Sstevel@tonic-gate meta_concat_parent( 810Sstevel@tonic-gate mdsetname_t *sp, 820Sstevel@tonic-gate mdname_t *childnp, 830Sstevel@tonic-gate md_error_t *ep 840Sstevel@tonic-gate ) 850Sstevel@tonic-gate { 860Sstevel@tonic-gate md_common_t *mdp; 870Sstevel@tonic-gate mdname_t *parentnp; 880Sstevel@tonic-gate md_unit_t *mup; 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* should have a set */ 910Sstevel@tonic-gate assert(sp != NULL); 920Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(childnp->dev))); 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* get parent */ 950Sstevel@tonic-gate if ((mdp = meta_get_unit(sp, childnp, ep)) == NULL) 960Sstevel@tonic-gate return (-1); 970Sstevel@tonic-gate if (! MD_HAS_PARENT(mdp->parent)) 980Sstevel@tonic-gate return (0); 990Sstevel@tonic-gate if (mdp->parent == MD_MULTI_PARENT) 1000Sstevel@tonic-gate return (0); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* single parent */ 1030Sstevel@tonic-gate if ((parentnp = metamnumname(&sp, mdp->parent, 0, ep)) == NULL) 1040Sstevel@tonic-gate return (-1); 1050Sstevel@tonic-gate /* don't grow non-metadevices or soft partitions */ 1060Sstevel@tonic-gate if (! metaismeta(parentnp) || meta_sp_issp(sp, parentnp, ep) == 0) 1070Sstevel@tonic-gate return (0); 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate if ((mup = meta_get_mdunit(sp, childnp, ep)) == NULL) 1100Sstevel@tonic-gate return (-1); 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* grow parent */ 1130Sstevel@tonic-gate if (meta_concat_generic(sp, parentnp, mup->c.un_revision, ep) != 0) 1140Sstevel@tonic-gate return (-1); 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* recursively check for parents of parents */ 1170Sstevel@tonic-gate return (meta_concat_parent(sp, parentnp, ep)); 1180Sstevel@tonic-gate } 119