1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_MD_HOTSPARES_H 28 #define _SYS_MD_HOTSPARES_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/lvm/mdvar.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* 39 * ioctl parameter structures 40 */ 41 42 typedef enum set_hs_command { 43 ADD_HOT_SPARE, DELETE_HOT_SPARE, REPLACE_HOT_SPARE, FIX_HOT_SPARE 44 } set_hs_command_t; 45 46 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 47 #pragma pack(4) 48 #endif 49 typedef struct set_hs_params { 50 MD_DRIVER 51 md_error_t mde; /* error return */ 52 set_hs_command_t shs_cmd; /* ioctl command */ 53 hsp_t shs_hot_spare_pool; /* hsp identifier */ 54 md_dev64_t shs_component_old; /* dev for add, del, repl */ 55 md_dev64_t shs_component_new; /* new dev for repl */ 56 mdkey_t shs_key_old; /* key */ 57 mdkey_t shs_key_new; /* new key for repl */ 58 uint_t shs_options; /* see HS_OPT_* below */ 59 diskaddr_t shs_start_blk; /* used by add/repl */ 60 int shs_has_label; /* used by add/repl */ 61 diskaddr_t shs_number_blks; /* used by add/repl */ 62 int shs_size_option; /* big or small */ 63 } set_hs_params_t; 64 65 #define HS_OPT_NONE 0x0000 /* Nothing special */ 66 #define HS_OPT_FORCE 0x0001 /* force flag */ 67 #define HS_OPT_POOL 0x0002 /* work on a hs pool */ 68 #define HS_OPT_DRYRUN 0x0004 /* just check if operation would be possible */ 69 70 typedef struct get_hs_params { 71 MD_DRIVER 72 md_error_t mde; /* error return */ 73 mdkey_t ghs_key; /* hs name key */ 74 md_dev64_t ghs_devnum; /* returned hs dev_t */ 75 diskaddr_t ghs_start_blk; /* returned start blk */ 76 diskaddr_t ghs_number_blks; /* returned # of blks */ 77 hotspare_states_t ghs_state; /* returned state */ 78 md_timeval32_t ghs_timestamp; /* returned timestamp */ 79 uint_t ghs_revision; /* returned revision */ 80 } get_hs_params_t; 81 82 typedef struct get_hsp { 83 hsp_t ghsp_id; /* hsp id */ 84 int ghsp_refcount; /* # metadevices using hsp */ 85 int ghsp_nhotspares; /* # of hs in hsp */ 86 mdkey_t ghsp_hs_keys[1]; /* array of keys */ 87 } get_hsp_t; 88 89 #define MD_IOCSET_HS (MDIOC_MISC|0) 90 #define MD_IOCGET_HS (MDIOC_MISC|1) 91 #define HSP_REC 1 92 #define HS_REC 2 93 94 /* 95 * Hot spare and hot spare pool data structures 96 * Note that hot_spare32_od is for old 32 bit format only 97 */ 98 typedef struct hot_spare32_od { 99 uint_t hs_revision; /* revision number */ 100 mddb_recid_t hs_record_id; /* db record id */ 101 caddr32_t xx_hs_next; /* hs list, link */ 102 dev32_t hs_devnum; /* hs device number */ 103 mdkey_t hs_key; /* namespace key */ 104 daddr32_t hs_start_blk; /* hs starting block */ 105 int hs_has_label; /* hs has a label */ 106 int hs_number_blks; /* hs # of blocks */ 107 hotspare_states_t hs_state; /* hs state */ 108 int hs_refcount; /* # hsp using the hs */ 109 int hs_isopen; /* is open flag */ 110 struct timeval32 hs_timestamp; /* time of last state change */ 111 /* 112 * Incore elements in this old format are not used by 64 bit kernel 113 * Comment out here for maintenance history 114 * struct hot_spare *hs_next; 115 */ 116 } hot_spare32_od_t; 117 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 118 #pragma pack() 119 #endif 120 121 typedef struct hot_spare { 122 uint_t hs_revision; /* revision number */ 123 mddb_recid_t hs_record_id; /* db record id */ 124 md_dev64_t hs_devnum; /* hs device number */ 125 mdkey_t hs_key; /* namespace key */ 126 diskaddr_t hs_start_blk; /* hs starting block */ 127 int hs_has_label; /* hs has a label */ 128 diskaddr_t hs_number_blks; /* hs # of blocks */ 129 hotspare_states_t hs_state; /* hs state */ 130 int hs_refcount; /* # hsp using the hs */ 131 int hs_isopen; /* is open flag */ 132 md_timeval32_t hs_timestamp; /* time of last state change */ 133 /* 134 * Incore elements. 135 * they should always be at the end of this data structure. 136 */ 137 struct hot_spare *hs_next; 138 } hot_spare_t; 139 140 #define HS_ONDSK_STR_SIZE offsetof(hot_spare_t, hs_next) 141 142 143 /* 144 * Ondisk part of hot_spare_pool 145 */ 146 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 147 #pragma pack(4) 148 #endif 149 typedef struct hot_spare_pool_ond { 150 uint_t hsp_revision; 151 hsp_t hsp_self_id; 152 mddb_recid_t hsp_record_id; 153 uint32_t spare[4]; 154 int hsp_refcount; 155 int hsp_nhotspares; 156 mddb_recid_t hsp_hotspares[1]; 157 } hot_spare_pool_ond_t; 158 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 159 #pragma pack() 160 #endif 161 162 typedef struct hot_spare_pool { 163 /* 164 * incore only elements 165 */ 166 struct hot_spare_pool *hsp_next; /* hsp list, link */ 167 md_link_t hsp_link; /* next hsp (for IOCGET_NEXT) */ 168 169 /* 170 * ondisk and should be the same as hot_spare_pool_ond 171 */ 172 uint_t hsp_revision; /* revision number */ 173 hsp_t hsp_self_id; /* hsp identifier */ 174 mddb_recid_t hsp_record_id; /* db record id */ 175 uint32_t spare[4]; 176 int hsp_refcount; /* # metadevices using hsp */ 177 int hsp_nhotspares; /* # hs in the pool */ 178 mddb_recid_t hsp_hotspares[1]; /* array of recid's */ 179 } hot_spare_pool_t; 180 181 #define HSP_ONDSK_STR_OFF ((off_t)(&((hot_spare_pool_t *)0)->hsp_revision)) 182 183 184 #ifdef __cplusplus 185 } 186 #endif 187 188 #endif /* _SYS_MD_HOTSPARES_H */ 189