1*718cf2ccSPedro F. Giffuni /*- 2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*718cf2ccSPedro F. Giffuni * 4b063a422SScott Long * Copyright (c) HighPoint Technologies, Inc. 5b063a422SScott Long * All rights reserved. 6b063a422SScott Long * 7b063a422SScott Long * Redistribution and use in source and binary forms, with or without 8b063a422SScott Long * modification, are permitted provided that the following conditions 9b063a422SScott Long * are met: 10b063a422SScott Long * 1. Redistributions of source code must retain the above copyright 11b063a422SScott Long * notice, this list of conditions and the following disclaimer. 12b063a422SScott Long * 2. Redistributions in binary form must reproduce the above copyright 13b063a422SScott Long * notice, this list of conditions and the following disclaimer in the 14b063a422SScott Long * documentation and/or other materials provided with the distribution. 15b063a422SScott Long * 16b063a422SScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17b063a422SScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18b063a422SScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19b063a422SScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20b063a422SScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21b063a422SScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22b063a422SScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23b063a422SScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24b063a422SScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25b063a422SScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26b063a422SScott Long * SUCH DAMAGE. 27b063a422SScott Long * 28b063a422SScott Long * $FreeBSD$ 29b063a422SScott Long */ 30b063a422SScott Long #include <dev/hptrr/hptrr_config.h> 31b063a422SScott Long /* 324fdb276aSScott Long * $Id: array.h,v 1.44 2007/11/01 03:05:27 gmm Exp $ 33b063a422SScott Long * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved. 34b063a422SScott Long */ 35b063a422SScott Long #ifndef _HPT_ARRAY_H_ 36b063a422SScott Long #define _HPT_ARRAY_H_ 37b063a422SScott Long 384fdb276aSScott Long #define VERMAGIC_ARRAY 43 39b063a422SScott Long 40b063a422SScott Long #if defined(__cplusplus) 41b063a422SScott Long extern "C" { 42b063a422SScott Long #endif 43b063a422SScott Long 44b063a422SScott Long #define MAX_ARRAY_NAME 16 45b063a422SScott Long 46b063a422SScott Long #ifndef MAX_MEMBERS 47b063a422SScott Long #define MAX_MEMBERS 16 48b063a422SScott Long #endif 49b063a422SScott Long 50b063a422SScott Long #if MAX_MEMBERS<=16 51b063a422SScott Long typedef HPT_U16 HPT_MMASK; 52b063a422SScott Long #elif MAX_MEMBERS<=32 53b063a422SScott Long typedef HPT_U32 HPT_MMASK; 54b063a422SScott Long #elif MAX_MEMBERS<=64 55b063a422SScott Long typedef HPT_U64 HPT_MMASK; 56b063a422SScott Long #else 57b063a422SScott Long #error "MAX_MEMBERS too large" 58b063a422SScott Long #endif 59b063a422SScott Long 60b063a422SScott Long #define HPT_MMASK_VALUE(x) (HPT_MMASK)((HPT_MMASK)1<<(x)) 61b063a422SScott Long 62b063a422SScott Long #if MAX_MEMBERS<32 63b063a422SScott Long #define HPT_MMASK_VALUE_SAFE(x) HPT_MMASK_VALUE(x) 64b063a422SScott Long #else 65b063a422SScott Long #define HPT_MMASK_VALUE_SAFE(x) ((x)>=MAX_MEMBERS? (HPT_MMASK)0 : HPT_MMASK_VALUE(x)) 66b063a422SScott Long #endif 67b063a422SScott Long 68b063a422SScott Long #define MAX_REBUILD_SECTORS 128 69b063a422SScott Long 70b063a422SScott Long typedef struct _RAID_FLAGS { 71b063a422SScott Long HPT_UINT rf_need_initialize : 1; 72b063a422SScott Long HPT_UINT rf_need_rebuild: 1; 73b063a422SScott Long HPT_UINT rf_need_sync: 1; 74b063a422SScott Long /* ioctl flags */ 75b063a422SScott Long HPT_UINT rf_auto_rebuild: 1; 76b063a422SScott Long HPT_UINT rf_rebuilding: 1; 77b063a422SScott Long HPT_UINT rf_verifying: 1; 78b063a422SScott Long HPT_UINT rf_initializing: 1; 79b063a422SScott Long HPT_UINT rf_abort_verifying: 1; 80b063a422SScott Long HPT_UINT rf_raid15: 1; 81b063a422SScott Long HPT_UINT rf_v3_format : 1; 82b063a422SScott Long HPT_UINT rf_need_transform : 1; 83b063a422SScott Long HPT_UINT rf_transforming : 1; 84b063a422SScott Long HPT_UINT rf_abort_transform : 1; 85b063a422SScott Long HPT_UINT rf_log_write: 1; 86b063a422SScott Long } RAID_FLAGS; 87b063a422SScott Long 88b063a422SScott Long typedef struct transform_cmd_ext 89b063a422SScott Long { 90b063a422SScott Long HPT_LBA lba; 91b063a422SScott Long HPT_U16 total_sectors; 92b063a422SScott Long HPT_U16 finished_sectors; 93b063a422SScott Long } TRANSFORM_CMD_EXT , *PTRANSFORM_CMD_EXT; 94b063a422SScott Long 95b063a422SScott Long 96b063a422SScott Long #define TO_MOVE_DATA 0 97b063a422SScott Long #define TO_INITIALIZE 1 98b063a422SScott Long #define TO_INITIALIZE_ONLY 2 99b063a422SScott Long #define TO_MOVE_DATA_ONLY 3 100b063a422SScott Long typedef struct hpt_transform 101b063a422SScott Long { 102b063a422SScott Long HPT_U32 stamp; 103b063a422SScott Long PVDEV source; 104b063a422SScott Long PVDEV target; 105b063a422SScott Long struct list_head link; 106b063a422SScott Long HPT_U8 transform_from_tail; 107b063a422SScott Long struct tq_item task; 108b063a422SScott Long 109b063a422SScott Long struct lock_request lock; 110b063a422SScott Long TRANSFORM_CMD_EXT cmdext; 111b063a422SScott Long 112b063a422SScott Long HPT_U64 transform_point; 113b063a422SScott Long HPT_U16 transform_sectors_per_step; 114b063a422SScott Long HPT_U8 operation; 115b063a422SScott Long HPT_U8 disabled; 116b063a422SScott Long } HPT_TRANSFORM, *PHPT_TRANSFORM; 117b063a422SScott Long 118b063a422SScott Long typedef struct hpt_array 119b063a422SScott Long { 120b063a422SScott Long HPT_U32 array_stamp; 121b063a422SScott Long HPT_U32 data_stamp; 122b063a422SScott Long 123b063a422SScott Long HPT_U8 ndisk; 124b063a422SScott Long HPT_U8 block_size_shift; 125b063a422SScott Long HPT_U16 strip_width; 1264fdb276aSScott Long HPT_U8 sector_size_shift; /*sector size = 512B<<sector_size_shift*/ 1274fdb276aSScott Long HPT_U8 jid; 1284fdb276aSScott Long HPT_U8 reserved[2]; 129b063a422SScott Long 130b063a422SScott Long 131b063a422SScott Long HPT_MMASK outdated_members; 132b063a422SScott Long HPT_MMASK offline_members; 133b063a422SScott Long 134b063a422SScott Long PVDEV member[MAX_MEMBERS]; 135b063a422SScott Long 136b063a422SScott Long RAID_FLAGS flags; 137b063a422SScott Long 138b063a422SScott Long HPT_U64 rebuilt_sectors; 139b063a422SScott Long 140b063a422SScott Long 141b063a422SScott Long HPT_U8 name[MAX_ARRAY_NAME]; 142b063a422SScott Long PHPT_TRANSFORM transform; 143b063a422SScott Long 144b063a422SScott Long TIME_RECORD create_time; 145b063a422SScott Long HPT_U8 description[64]; 146b063a422SScott Long HPT_U8 create_manager[16]; 147b063a422SScott Long 148b063a422SScott Long #ifdef OS_SUPPORT_TASK 149b063a422SScott Long int floating_priority; 150b063a422SScott Long OSM_TASK ioctl_task; 151b063a422SScott Long IOCTL_ARG ioctl_arg; 152b063a422SScott Long 153b063a422SScott Long char ioctl_inbuf[sizeof(PVDEV)+sizeof(HPT_U64)+sizeof(HPT_U16)]; 154b063a422SScott Long char ioctl_outbuf[sizeof(HPT_UINT)]; 155b063a422SScott Long #endif 156b063a422SScott Long 157b063a422SScott Long } HPT_ARRAY, *PHPT_ARRAY; 158b063a422SScott Long 159b063a422SScott Long #ifdef OS_SUPPORT_TASK 160b063a422SScott Long void ldm_start_rebuild(struct _VDEV *pArray); 161b063a422SScott Long #else 162b063a422SScott Long #define ldm_start_rebuild(pArray) 163b063a422SScott Long #endif 164b063a422SScott Long 165b063a422SScott Long typedef struct _raw_partition{ 166b063a422SScott Long struct _raw_partition * next; 1674fdb276aSScott Long __HPT_RAW_LBA start; 1684fdb276aSScott Long __HPT_RAW_LBA capacity; 169b063a422SScott Long PVDEV vd_part; 170b063a422SScott Long } RAW_PARTITION, *PRAW_PARTITION; 171b063a422SScott Long 172b063a422SScott Long typedef struct hpt_partiton 173b063a422SScott Long { 174b063a422SScott Long PVDEV raw_disk; 1754fdb276aSScott Long __HPT_RAW_LBA des_location; 176b063a422SScott Long PRAW_PARTITION raw_part; 177b063a422SScott Long HPT_U8 del_mbr; 178b063a422SScott Long HPT_U8 reserved[3]; 179b063a422SScott Long } HPT_PARTITION, *PHPT_PARTITION; 180b063a422SScott Long 181b063a422SScott Long HPT_U16 get_strip_size(PVDEV vd); 182b063a422SScott Long 183b063a422SScott Long void ldm_check_array_online(PVDEV pArray); 184b063a422SScott Long void ldm_generic_member_failed(PVDEV member); 185b063a422SScott Long void ldm_sync_array_info(PVDEV pArray); 186b063a422SScott Long void ldm_sync_array_stamp(PVDEV pArray); 187b063a422SScott Long void ldm_add_spare_to_array(PVDEV pArray, PVDEV spare_partition); 188b063a422SScott Long 189b063a422SScott Long #if defined(__cplusplus) 190b063a422SScott Long } 191b063a422SScott Long #endif 192b063a422SScott Long #endif 193