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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*734Smw145384 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_MD_HOTSPARES_H 280Sstevel@tonic-gate #define _SYS_MD_HOTSPARES_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/lvm/mdvar.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * ioctl parameter structures 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate typedef enum set_hs_command { 430Sstevel@tonic-gate ADD_HOT_SPARE, DELETE_HOT_SPARE, REPLACE_HOT_SPARE, FIX_HOT_SPARE 440Sstevel@tonic-gate } set_hs_command_t; 450Sstevel@tonic-gate 460Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 470Sstevel@tonic-gate #pragma pack(4) 480Sstevel@tonic-gate #endif 490Sstevel@tonic-gate typedef struct set_hs_params { 500Sstevel@tonic-gate MD_DRIVER 510Sstevel@tonic-gate md_error_t mde; /* error return */ 520Sstevel@tonic-gate set_hs_command_t shs_cmd; /* ioctl command */ 530Sstevel@tonic-gate hsp_t shs_hot_spare_pool; /* hsp identifier */ 540Sstevel@tonic-gate md_dev64_t shs_component_old; /* dev for add, del, repl */ 550Sstevel@tonic-gate md_dev64_t shs_component_new; /* new dev for repl */ 560Sstevel@tonic-gate mdkey_t shs_key_old; /* key */ 570Sstevel@tonic-gate mdkey_t shs_key_new; /* new key for repl */ 580Sstevel@tonic-gate uint_t shs_options; /* see HS_OPT_* below */ 590Sstevel@tonic-gate diskaddr_t shs_start_blk; /* used by add/repl */ 600Sstevel@tonic-gate int shs_has_label; /* used by add/repl */ 610Sstevel@tonic-gate diskaddr_t shs_number_blks; /* used by add/repl */ 620Sstevel@tonic-gate int shs_size_option; /* big or small */ 630Sstevel@tonic-gate } set_hs_params_t; 640Sstevel@tonic-gate 650Sstevel@tonic-gate #define HS_OPT_NONE 0x0000 /* Nothing special */ 660Sstevel@tonic-gate #define HS_OPT_FORCE 0x0001 /* force flag */ 670Sstevel@tonic-gate #define HS_OPT_POOL 0x0002 /* work on a hs pool */ 680Sstevel@tonic-gate #define HS_OPT_DRYRUN 0x0004 /* just check if operation would be possible */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate typedef struct get_hs_params { 710Sstevel@tonic-gate MD_DRIVER 720Sstevel@tonic-gate md_error_t mde; /* error return */ 730Sstevel@tonic-gate mdkey_t ghs_key; /* hs name key */ 740Sstevel@tonic-gate md_dev64_t ghs_devnum; /* returned hs dev_t */ 750Sstevel@tonic-gate diskaddr_t ghs_start_blk; /* returned start blk */ 760Sstevel@tonic-gate diskaddr_t ghs_number_blks; /* returned # of blks */ 770Sstevel@tonic-gate hotspare_states_t ghs_state; /* returned state */ 780Sstevel@tonic-gate md_timeval32_t ghs_timestamp; /* returned timestamp */ 790Sstevel@tonic-gate uint_t ghs_revision; /* returned revision */ 800Sstevel@tonic-gate } get_hs_params_t; 810Sstevel@tonic-gate 820Sstevel@tonic-gate typedef struct get_hsp { 830Sstevel@tonic-gate hsp_t ghsp_id; /* hsp id */ 840Sstevel@tonic-gate int ghsp_refcount; /* # metadevices using hsp */ 850Sstevel@tonic-gate int ghsp_nhotspares; /* # of hs in hsp */ 860Sstevel@tonic-gate mdkey_t ghsp_hs_keys[1]; /* array of keys */ 870Sstevel@tonic-gate } get_hsp_t; 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define MD_IOCSET_HS (MDIOC_MISC|0) 900Sstevel@tonic-gate #define MD_IOCGET_HS (MDIOC_MISC|1) 910Sstevel@tonic-gate #define HSP_REC 1 920Sstevel@tonic-gate #define HS_REC 2 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * Hot spare and hot spare pool data structures 960Sstevel@tonic-gate * Note that hot_spare32_od is for old 32 bit format only 970Sstevel@tonic-gate */ 980Sstevel@tonic-gate typedef struct hot_spare32_od { 990Sstevel@tonic-gate uint_t hs_revision; /* revision number */ 1000Sstevel@tonic-gate mddb_recid_t hs_record_id; /* db record id */ 1010Sstevel@tonic-gate caddr32_t xx_hs_next; /* hs list, link */ 1020Sstevel@tonic-gate dev32_t hs_devnum; /* hs device number */ 1030Sstevel@tonic-gate mdkey_t hs_key; /* namespace key */ 1040Sstevel@tonic-gate daddr32_t hs_start_blk; /* hs starting block */ 1050Sstevel@tonic-gate int hs_has_label; /* hs has a label */ 1060Sstevel@tonic-gate int hs_number_blks; /* hs # of blocks */ 1070Sstevel@tonic-gate hotspare_states_t hs_state; /* hs state */ 1080Sstevel@tonic-gate int hs_refcount; /* # hsp using the hs */ 1090Sstevel@tonic-gate int hs_isopen; /* is open flag */ 1100Sstevel@tonic-gate struct timeval32 hs_timestamp; /* time of last state change */ 1110Sstevel@tonic-gate /* 1120Sstevel@tonic-gate * Incore elements in this old format are not used by 64 bit kernel 1130Sstevel@tonic-gate * Comment out here for maintenance history 1140Sstevel@tonic-gate * struct hot_spare *hs_next; 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate } hot_spare32_od_t; 1170Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 1180Sstevel@tonic-gate #pragma pack() 1190Sstevel@tonic-gate #endif 1200Sstevel@tonic-gate 121*734Smw145384 /* 122*734Smw145384 * The pads are necessary for the hot_spare_t structure to be interpreted 123*734Smw145384 * correctly in userland on the amd64 arch. 124*734Smw145384 */ 1250Sstevel@tonic-gate typedef struct hot_spare { 1260Sstevel@tonic-gate uint_t hs_revision; /* revision number */ 1270Sstevel@tonic-gate mddb_recid_t hs_record_id; /* db record id */ 1280Sstevel@tonic-gate md_dev64_t hs_devnum; /* hs device number */ 1290Sstevel@tonic-gate mdkey_t hs_key; /* namespace key */ 130*734Smw145384 int hs_pad1; 1310Sstevel@tonic-gate diskaddr_t hs_start_blk; /* hs starting block */ 1320Sstevel@tonic-gate int hs_has_label; /* hs has a label */ 133*734Smw145384 int hs_pad2; 1340Sstevel@tonic-gate diskaddr_t hs_number_blks; /* hs # of blocks */ 1350Sstevel@tonic-gate hotspare_states_t hs_state; /* hs state */ 1360Sstevel@tonic-gate int hs_refcount; /* # hsp using the hs */ 1370Sstevel@tonic-gate int hs_isopen; /* is open flag */ 1380Sstevel@tonic-gate md_timeval32_t hs_timestamp; /* time of last state change */ 1390Sstevel@tonic-gate /* 1400Sstevel@tonic-gate * Incore elements. 1410Sstevel@tonic-gate * they should always be at the end of this data structure. 1420Sstevel@tonic-gate */ 1430Sstevel@tonic-gate struct hot_spare *hs_next; 1440Sstevel@tonic-gate } hot_spare_t; 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate #define HS_ONDSK_STR_SIZE offsetof(hot_spare_t, hs_next) 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * Ondisk part of hot_spare_pool 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 1530Sstevel@tonic-gate #pragma pack(4) 1540Sstevel@tonic-gate #endif 1550Sstevel@tonic-gate typedef struct hot_spare_pool_ond { 1560Sstevel@tonic-gate uint_t hsp_revision; 1570Sstevel@tonic-gate hsp_t hsp_self_id; 1580Sstevel@tonic-gate mddb_recid_t hsp_record_id; 1590Sstevel@tonic-gate uint32_t spare[4]; 1600Sstevel@tonic-gate int hsp_refcount; 1610Sstevel@tonic-gate int hsp_nhotspares; 1620Sstevel@tonic-gate mddb_recid_t hsp_hotspares[1]; 1630Sstevel@tonic-gate } hot_spare_pool_ond_t; 1640Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 1650Sstevel@tonic-gate #pragma pack() 1660Sstevel@tonic-gate #endif 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate typedef struct hot_spare_pool { 1690Sstevel@tonic-gate /* 1700Sstevel@tonic-gate * incore only elements 1710Sstevel@tonic-gate */ 1720Sstevel@tonic-gate struct hot_spare_pool *hsp_next; /* hsp list, link */ 1730Sstevel@tonic-gate md_link_t hsp_link; /* next hsp (for IOCGET_NEXT) */ 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate /* 1760Sstevel@tonic-gate * ondisk and should be the same as hot_spare_pool_ond 1770Sstevel@tonic-gate */ 1780Sstevel@tonic-gate uint_t hsp_revision; /* revision number */ 1790Sstevel@tonic-gate hsp_t hsp_self_id; /* hsp identifier */ 1800Sstevel@tonic-gate mddb_recid_t hsp_record_id; /* db record id */ 1810Sstevel@tonic-gate uint32_t spare[4]; 1820Sstevel@tonic-gate int hsp_refcount; /* # metadevices using hsp */ 1830Sstevel@tonic-gate int hsp_nhotspares; /* # hs in the pool */ 1840Sstevel@tonic-gate mddb_recid_t hsp_hotspares[1]; /* array of recid's */ 1850Sstevel@tonic-gate } hot_spare_pool_t; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate #define HSP_ONDSK_STR_OFF ((off_t)(&((hot_spare_pool_t *)0)->hsp_revision)) 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate #ifdef __cplusplus 1910Sstevel@tonic-gate } 1920Sstevel@tonic-gate #endif 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate #endif /* _SYS_MD_HOTSPARES_H */ 195