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
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.
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_MD_HOTSPARES_H
28 #define _SYS_MD_HOTSPARES_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/lvm/mdvar.h>
39 * ioctl parameter structures
42 typedef enum set_hs_command
{
43 ADD_HOT_SPARE
, DELETE_HOT_SPARE
, REPLACE_HOT_SPARE
, FIX_HOT_SPARE
46 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
49 typedef struct set_hs_params
{
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 */
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 */
70 typedef struct get_hs_params
{
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 */
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 */
89 #define MD_IOCSET_HS (MDIOC_MISC|0)
90 #define MD_IOCGET_HS (MDIOC_MISC|1)
95 * Hot spare and hot spare pool data structures
96 * Note that hot_spare32_od is for old 32 bit format only
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 */
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;
117 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
122 * The pads are necessary for the hot_spare_t structure to be interpreted
123 * correctly in userland on the amd64 arch.
125 typedef struct hot_spare
{
126 uint_t hs_revision
; /* revision number */
127 mddb_recid_t hs_record_id
; /* db record id */
128 md_dev64_t hs_devnum
; /* hs device number */
129 mdkey_t hs_key
; /* namespace key */
131 diskaddr_t hs_start_blk
; /* hs starting block */
132 int hs_has_label
; /* hs has a label */
134 diskaddr_t hs_number_blks
; /* hs # of blocks */
135 hotspare_states_t hs_state
; /* hs state */
136 int hs_refcount
; /* # hsp using the hs */
137 int hs_isopen
; /* is open flag */
138 md_timeval32_t hs_timestamp
; /* time of last state change */
141 * they should always be at the end of this data structure.
143 struct hot_spare
*hs_next
;
146 #define HS_ONDSK_STR_SIZE offsetof(hot_spare_t, hs_next)
150 * Ondisk part of hot_spare_pool
152 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
155 typedef struct hot_spare_pool_ond
{
158 mddb_recid_t hsp_record_id
;
162 mddb_recid_t hsp_hotspares
[1];
163 } hot_spare_pool_ond_t
;
164 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
168 typedef struct hot_spare_pool
{
170 * incore only elements
172 struct hot_spare_pool
*hsp_next
; /* hsp list, link */
173 md_link_t hsp_link
; /* next hsp (for IOCGET_NEXT) */
176 * ondisk and should be the same as hot_spare_pool_ond
178 uint_t hsp_revision
; /* revision number */
179 hsp_t hsp_self_id
; /* hsp identifier */
180 mddb_recid_t hsp_record_id
; /* db record id */
182 int hsp_refcount
; /* # metadevices using hsp */
183 int hsp_nhotspares
; /* # hs in the pool */
184 mddb_recid_t hsp_hotspares
[1]; /* array of recid's */
187 #define HSP_ONDSK_STR_OFF ((off_t)(&((hot_spare_pool_t *)0)->hsp_revision))
194 #endif /* _SYS_MD_HOTSPARES_H */