1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS__MD_STRIPE_H 28*0Sstevel@tonic-gate #define _SYS__MD_STRIPE_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/lvm/mdvar.h> 33*0Sstevel@tonic-gate #include <sys/lvm/md_mirror_shared.h> 34*0Sstevel@tonic-gate #include <sys/lvm/md_rename.h> 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * ms_comp32_od is for old 32 bit format only 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 44*0Sstevel@tonic-gate #pragma pack(4) 45*0Sstevel@tonic-gate #endif 46*0Sstevel@tonic-gate typedef struct ms_comp32_od { 47*0Sstevel@tonic-gate mdkey_t un_key; 48*0Sstevel@tonic-gate dev32_t un_dev; 49*0Sstevel@tonic-gate daddr32_t un_start_block; /* comp start blkno */ 50*0Sstevel@tonic-gate md_m_shared32_od_t un_mirror; 51*0Sstevel@tonic-gate } ms_comp32_od_t; 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate typedef struct ms_comp { /* components */ 55*0Sstevel@tonic-gate mdkey_t un_key; /* namespace key */ 56*0Sstevel@tonic-gate md_dev64_t un_dev; /* device number, 64 bit */ 57*0Sstevel@tonic-gate diskaddr_t un_start_block; /* comp start blkno */ 58*0Sstevel@tonic-gate md_m_shared_t un_mirror; /* mirror shared data */ 59*0Sstevel@tonic-gate } ms_comp_t; 60*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 61*0Sstevel@tonic-gate #pragma pack() 62*0Sstevel@tonic-gate #endif 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* 65*0Sstevel@tonic-gate * ms_unit32_od is for old 32 bit format only 66*0Sstevel@tonic-gate */ 67*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 68*0Sstevel@tonic-gate #pragma pack(4) 69*0Sstevel@tonic-gate #endif 70*0Sstevel@tonic-gate typedef struct ms_unit32_od { 71*0Sstevel@tonic-gate mdc_unit32_od_t c; 72*0Sstevel@tonic-gate int un_hsp_id; /* hot spare pool db record id */ 73*0Sstevel@tonic-gate uint_t un_nrows; /* number of rows */ 74*0Sstevel@tonic-gate uint_t un_ocomp; /* offset of ms_comp array */ 75*0Sstevel@tonic-gate struct ms_row32_od { 76*0Sstevel@tonic-gate int un_icomp; /* ms_comp array index of first comp */ 77*0Sstevel@tonic-gate uint_t un_ncomp; /* # comps in this row */ 78*0Sstevel@tonic-gate int un_blocks; /* total blocks in this row */ 79*0Sstevel@tonic-gate int un_cum_blocks; /* cum. blks in this and prev. rows */ 80*0Sstevel@tonic-gate int un_interlace; /* # blks from each disk in a stripe */ 81*0Sstevel@tonic-gate }un_row[1]; 82*0Sstevel@tonic-gate } ms_unit32_od_t; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate typedef struct ms_unit { 86*0Sstevel@tonic-gate mdc_unit_t c; 87*0Sstevel@tonic-gate int un_hsp_id; /* hot spare pool db record id */ 88*0Sstevel@tonic-gate uint_t un_nrows; /* number of rows */ 89*0Sstevel@tonic-gate uint_t un_ocomp; /* offset of ms_comp array */ 90*0Sstevel@tonic-gate struct ms_row { 91*0Sstevel@tonic-gate int un_icomp; /* ms_comp array index of first comp */ 92*0Sstevel@tonic-gate uint_t un_ncomp; /* # comps in this row */ 93*0Sstevel@tonic-gate diskaddr_t un_blocks; /* total blocks in this row */ 94*0Sstevel@tonic-gate diskaddr_t un_cum_blocks; /* cum. blks in rows */ 95*0Sstevel@tonic-gate diskaddr_t un_interlace; /* # blks from each disk */ 96*0Sstevel@tonic-gate }un_row[1]; 97*0Sstevel@tonic-gate } ms_unit_t; 98*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 99*0Sstevel@tonic-gate #pragma pack() 100*0Sstevel@tonic-gate #endif 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #ifdef _KERNEL 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate typedef struct md_sps { /* stripe parent save */ 105*0Sstevel@tonic-gate DAEMON_QUEUE 106*0Sstevel@tonic-gate ms_unit_t *ps_un; 107*0Sstevel@tonic-gate mdi_unit_t *ps_ui; 108*0Sstevel@tonic-gate buf_t *ps_bp; 109*0Sstevel@tonic-gate caddr_t ps_addr; 110*0Sstevel@tonic-gate int ps_frags; 111*0Sstevel@tonic-gate int ps_flags; 112*0Sstevel@tonic-gate ms_comp_t *ps_errcomp; 113*0Sstevel@tonic-gate /* 114*0Sstevel@tonic-gate * New structure members should be added here; fields added 115*0Sstevel@tonic-gate * after ps_mx will not be zeroed during initialization. 116*0Sstevel@tonic-gate */ 117*0Sstevel@tonic-gate kmutex_t ps_mx; 118*0Sstevel@tonic-gate } md_sps_t; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate #define MD_SPS_ERROR 0x0001 121*0Sstevel@tonic-gate #define MD_SPS_DONTFREE 0x0002 122*0Sstevel@tonic-gate #define MD_SPS_DONE 0x0004 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate #define SPS_FREE(kc, ps) \ 125*0Sstevel@tonic-gate { \ 126*0Sstevel@tonic-gate if ((ps)->ps_flags & MD_SPS_DONTFREE) \ 127*0Sstevel@tonic-gate (ps)->ps_flags |= MD_SPS_DONE; \ 128*0Sstevel@tonic-gate else \ 129*0Sstevel@tonic-gate kmem_cache_free((kc), (ps)); \ 130*0Sstevel@tonic-gate } 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate typedef struct md_scs { 133*0Sstevel@tonic-gate DAEMON_QUEUE 134*0Sstevel@tonic-gate minor_t cs_mdunit; 135*0Sstevel@tonic-gate md_sps_t *cs_ps; 136*0Sstevel@tonic-gate ms_comp_t *cs_comp; 137*0Sstevel@tonic-gate /* Add new structure members HERE!! */ 138*0Sstevel@tonic-gate buf_t cs_buf; 139*0Sstevel@tonic-gate /* DO NOT add struture members here; cs_buf is dynamically sized */ 140*0Sstevel@tonic-gate } md_scs_t; 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate /* Externals from stripe.c */ 143*0Sstevel@tonic-gate extern int stripe_build_incore(void *, int); 144*0Sstevel@tonic-gate extern void reset_stripe(ms_unit_t *, minor_t, int); 145*0Sstevel@tonic-gate extern intptr_t stripe_component_count(md_dev64_t, void *); 146*0Sstevel@tonic-gate extern intptr_t stripe_get_dev(md_dev64_t, void *, int, ms_cd_info_t *); 147*0Sstevel@tonic-gate extern intptr_t stripe_replace_dev(md_dev64_t, void *, int, ms_new_dev_t *, 148*0Sstevel@tonic-gate mddb_recid_t *, int, void (**)(), void **); 149*0Sstevel@tonic-gate extern void stripe_replace_done(md_dev64_t, sv_dev_t *); 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate /* Externals from stripe_ioctl.c */ 152*0Sstevel@tonic-gate extern int md_stripe_ioctl(dev_t dev, int cmd, void *data, 153*0Sstevel@tonic-gate int mode, IOLOCK *lockp); 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate /* rename named service functions (stripe_ioctl.c) */ 156*0Sstevel@tonic-gate md_ren_svc_t stripe_rename_check; 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate #endif /* _KERNEL */ 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate #ifdef __cplusplus 161*0Sstevel@tonic-gate } 162*0Sstevel@tonic-gate #endif 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate #endif /* _SYS__MD_STRIPE_H */ 165