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_HOTSPARES_H 28*0Sstevel@tonic-gate #define _SYS_MD_HOTSPARES_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 34*0Sstevel@tonic-gate #ifdef __cplusplus 35*0Sstevel@tonic-gate extern "C" { 36*0Sstevel@tonic-gate #endif 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate /* 39*0Sstevel@tonic-gate * ioctl parameter structures 40*0Sstevel@tonic-gate */ 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate typedef enum set_hs_command { 43*0Sstevel@tonic-gate ADD_HOT_SPARE, DELETE_HOT_SPARE, REPLACE_HOT_SPARE, FIX_HOT_SPARE 44*0Sstevel@tonic-gate } set_hs_command_t; 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 47*0Sstevel@tonic-gate #pragma pack(4) 48*0Sstevel@tonic-gate #endif 49*0Sstevel@tonic-gate typedef struct set_hs_params { 50*0Sstevel@tonic-gate MD_DRIVER 51*0Sstevel@tonic-gate md_error_t mde; /* error return */ 52*0Sstevel@tonic-gate set_hs_command_t shs_cmd; /* ioctl command */ 53*0Sstevel@tonic-gate hsp_t shs_hot_spare_pool; /* hsp identifier */ 54*0Sstevel@tonic-gate md_dev64_t shs_component_old; /* dev for add, del, repl */ 55*0Sstevel@tonic-gate md_dev64_t shs_component_new; /* new dev for repl */ 56*0Sstevel@tonic-gate mdkey_t shs_key_old; /* key */ 57*0Sstevel@tonic-gate mdkey_t shs_key_new; /* new key for repl */ 58*0Sstevel@tonic-gate uint_t shs_options; /* see HS_OPT_* below */ 59*0Sstevel@tonic-gate diskaddr_t shs_start_blk; /* used by add/repl */ 60*0Sstevel@tonic-gate int shs_has_label; /* used by add/repl */ 61*0Sstevel@tonic-gate diskaddr_t shs_number_blks; /* used by add/repl */ 62*0Sstevel@tonic-gate int shs_size_option; /* big or small */ 63*0Sstevel@tonic-gate } set_hs_params_t; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #define HS_OPT_NONE 0x0000 /* Nothing special */ 66*0Sstevel@tonic-gate #define HS_OPT_FORCE 0x0001 /* force flag */ 67*0Sstevel@tonic-gate #define HS_OPT_POOL 0x0002 /* work on a hs pool */ 68*0Sstevel@tonic-gate #define HS_OPT_DRYRUN 0x0004 /* just check if operation would be possible */ 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate typedef struct get_hs_params { 71*0Sstevel@tonic-gate MD_DRIVER 72*0Sstevel@tonic-gate md_error_t mde; /* error return */ 73*0Sstevel@tonic-gate mdkey_t ghs_key; /* hs name key */ 74*0Sstevel@tonic-gate md_dev64_t ghs_devnum; /* returned hs dev_t */ 75*0Sstevel@tonic-gate diskaddr_t ghs_start_blk; /* returned start blk */ 76*0Sstevel@tonic-gate diskaddr_t ghs_number_blks; /* returned # of blks */ 77*0Sstevel@tonic-gate hotspare_states_t ghs_state; /* returned state */ 78*0Sstevel@tonic-gate md_timeval32_t ghs_timestamp; /* returned timestamp */ 79*0Sstevel@tonic-gate uint_t ghs_revision; /* returned revision */ 80*0Sstevel@tonic-gate } get_hs_params_t; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate typedef struct get_hsp { 83*0Sstevel@tonic-gate hsp_t ghsp_id; /* hsp id */ 84*0Sstevel@tonic-gate int ghsp_refcount; /* # metadevices using hsp */ 85*0Sstevel@tonic-gate int ghsp_nhotspares; /* # of hs in hsp */ 86*0Sstevel@tonic-gate mdkey_t ghsp_hs_keys[1]; /* array of keys */ 87*0Sstevel@tonic-gate } get_hsp_t; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate #define MD_IOCSET_HS (MDIOC_MISC|0) 90*0Sstevel@tonic-gate #define MD_IOCGET_HS (MDIOC_MISC|1) 91*0Sstevel@tonic-gate #define HSP_REC 1 92*0Sstevel@tonic-gate #define HS_REC 2 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 95*0Sstevel@tonic-gate * Hot spare and hot spare pool data structures 96*0Sstevel@tonic-gate * Note that hot_spare32_od is for old 32 bit format only 97*0Sstevel@tonic-gate */ 98*0Sstevel@tonic-gate typedef struct hot_spare32_od { 99*0Sstevel@tonic-gate uint_t hs_revision; /* revision number */ 100*0Sstevel@tonic-gate mddb_recid_t hs_record_id; /* db record id */ 101*0Sstevel@tonic-gate caddr32_t xx_hs_next; /* hs list, link */ 102*0Sstevel@tonic-gate dev32_t hs_devnum; /* hs device number */ 103*0Sstevel@tonic-gate mdkey_t hs_key; /* namespace key */ 104*0Sstevel@tonic-gate daddr32_t hs_start_blk; /* hs starting block */ 105*0Sstevel@tonic-gate int hs_has_label; /* hs has a label */ 106*0Sstevel@tonic-gate int hs_number_blks; /* hs # of blocks */ 107*0Sstevel@tonic-gate hotspare_states_t hs_state; /* hs state */ 108*0Sstevel@tonic-gate int hs_refcount; /* # hsp using the hs */ 109*0Sstevel@tonic-gate int hs_isopen; /* is open flag */ 110*0Sstevel@tonic-gate struct timeval32 hs_timestamp; /* time of last state change */ 111*0Sstevel@tonic-gate /* 112*0Sstevel@tonic-gate * Incore elements in this old format are not used by 64 bit kernel 113*0Sstevel@tonic-gate * Comment out here for maintenance history 114*0Sstevel@tonic-gate * struct hot_spare *hs_next; 115*0Sstevel@tonic-gate */ 116*0Sstevel@tonic-gate } hot_spare32_od_t; 117*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 118*0Sstevel@tonic-gate #pragma pack() 119*0Sstevel@tonic-gate #endif 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate typedef struct hot_spare { 122*0Sstevel@tonic-gate uint_t hs_revision; /* revision number */ 123*0Sstevel@tonic-gate mddb_recid_t hs_record_id; /* db record id */ 124*0Sstevel@tonic-gate md_dev64_t hs_devnum; /* hs device number */ 125*0Sstevel@tonic-gate mdkey_t hs_key; /* namespace key */ 126*0Sstevel@tonic-gate diskaddr_t hs_start_blk; /* hs starting block */ 127*0Sstevel@tonic-gate int hs_has_label; /* hs has a label */ 128*0Sstevel@tonic-gate diskaddr_t hs_number_blks; /* hs # of blocks */ 129*0Sstevel@tonic-gate hotspare_states_t hs_state; /* hs state */ 130*0Sstevel@tonic-gate int hs_refcount; /* # hsp using the hs */ 131*0Sstevel@tonic-gate int hs_isopen; /* is open flag */ 132*0Sstevel@tonic-gate md_timeval32_t hs_timestamp; /* time of last state change */ 133*0Sstevel@tonic-gate /* 134*0Sstevel@tonic-gate * Incore elements. 135*0Sstevel@tonic-gate * they should always be at the end of this data structure. 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate struct hot_spare *hs_next; 138*0Sstevel@tonic-gate } hot_spare_t; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate #define HS_ONDSK_STR_SIZE offsetof(hot_spare_t, hs_next) 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate /* 144*0Sstevel@tonic-gate * Ondisk part of hot_spare_pool 145*0Sstevel@tonic-gate */ 146*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 147*0Sstevel@tonic-gate #pragma pack(4) 148*0Sstevel@tonic-gate #endif 149*0Sstevel@tonic-gate typedef struct hot_spare_pool_ond { 150*0Sstevel@tonic-gate uint_t hsp_revision; 151*0Sstevel@tonic-gate hsp_t hsp_self_id; 152*0Sstevel@tonic-gate mddb_recid_t hsp_record_id; 153*0Sstevel@tonic-gate uint32_t spare[4]; 154*0Sstevel@tonic-gate int hsp_refcount; 155*0Sstevel@tonic-gate int hsp_nhotspares; 156*0Sstevel@tonic-gate mddb_recid_t hsp_hotspares[1]; 157*0Sstevel@tonic-gate } hot_spare_pool_ond_t; 158*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 159*0Sstevel@tonic-gate #pragma pack() 160*0Sstevel@tonic-gate #endif 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate typedef struct hot_spare_pool { 163*0Sstevel@tonic-gate /* 164*0Sstevel@tonic-gate * incore only elements 165*0Sstevel@tonic-gate */ 166*0Sstevel@tonic-gate struct hot_spare_pool *hsp_next; /* hsp list, link */ 167*0Sstevel@tonic-gate md_link_t hsp_link; /* next hsp (for IOCGET_NEXT) */ 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate /* 170*0Sstevel@tonic-gate * ondisk and should be the same as hot_spare_pool_ond 171*0Sstevel@tonic-gate */ 172*0Sstevel@tonic-gate uint_t hsp_revision; /* revision number */ 173*0Sstevel@tonic-gate hsp_t hsp_self_id; /* hsp identifier */ 174*0Sstevel@tonic-gate mddb_recid_t hsp_record_id; /* db record id */ 175*0Sstevel@tonic-gate uint32_t spare[4]; 176*0Sstevel@tonic-gate int hsp_refcount; /* # metadevices using hsp */ 177*0Sstevel@tonic-gate int hsp_nhotspares; /* # hs in the pool */ 178*0Sstevel@tonic-gate mddb_recid_t hsp_hotspares[1]; /* array of recid's */ 179*0Sstevel@tonic-gate } hot_spare_pool_t; 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate #define HSP_ONDSK_STR_OFF ((off_t)(&((hot_spare_pool_t *)0)->hsp_revision)) 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate #ifdef __cplusplus 185*0Sstevel@tonic-gate } 186*0Sstevel@tonic-gate #endif 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate #endif /* _SYS_MD_HOTSPARES_H */ 189