1174604Sscottl/* 2174604Sscottl * Copyright (c) HighPoint Technologies, Inc. 3174604Sscottl * All rights reserved. 4174604Sscottl * 5174604Sscottl * Redistribution and use in source and binary forms, with or without 6174604Sscottl * modification, are permitted provided that the following conditions 7174604Sscottl * are met: 8174604Sscottl * 1. Redistributions of source code must retain the above copyright 9174604Sscottl * notice, this list of conditions and the following disclaimer. 10174604Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11174604Sscottl * notice, this list of conditions and the following disclaimer in the 12174604Sscottl * documentation and/or other materials provided with the distribution. 13174604Sscottl * 14174604Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15174604Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16174604Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17174604Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18174604Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19174604Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20174604Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21174604Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22174604Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23174604Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24174604Sscottl * SUCH DAMAGE. 25174604Sscottl * 26174604Sscottl * $FreeBSD$ 27174604Sscottl */ 28174604Sscottl#include <dev/hptrr/hptrr_config.h> 29174604Sscottl/* 30176018Sscottl * $Id: array.h,v 1.44 2007/11/01 03:05:27 gmm Exp $ 31174604Sscottl * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved. 32174604Sscottl */ 33174604Sscottl#ifndef _HPT_ARRAY_H_ 34174604Sscottl#define _HPT_ARRAY_H_ 35174604Sscottl 36176018Sscottl#define VERMAGIC_ARRAY 43 37174604Sscottl 38174604Sscottl#if defined(__cplusplus) 39174604Sscottlextern "C" { 40174604Sscottl#endif 41174604Sscottl 42174604Sscottl#define MAX_ARRAY_NAME 16 43174604Sscottl 44174604Sscottl#ifndef MAX_MEMBERS 45174604Sscottl#define MAX_MEMBERS 16 46174604Sscottl#endif 47174604Sscottl 48174604Sscottl#if MAX_MEMBERS<=16 49174604Sscottltypedef HPT_U16 HPT_MMASK; 50174604Sscottl#elif MAX_MEMBERS<=32 51174604Sscottltypedef HPT_U32 HPT_MMASK; 52174604Sscottl#elif MAX_MEMBERS<=64 53174604Sscottltypedef HPT_U64 HPT_MMASK; 54174604Sscottl#else 55174604Sscottl#error "MAX_MEMBERS too large" 56174604Sscottl#endif 57174604Sscottl 58174604Sscottl#define HPT_MMASK_VALUE(x) (HPT_MMASK)((HPT_MMASK)1<<(x)) 59174604Sscottl 60174604Sscottl#if MAX_MEMBERS<32 61174604Sscottl#define HPT_MMASK_VALUE_SAFE(x) HPT_MMASK_VALUE(x) 62174604Sscottl#else 63174604Sscottl#define HPT_MMASK_VALUE_SAFE(x) ((x)>=MAX_MEMBERS? (HPT_MMASK)0 : HPT_MMASK_VALUE(x)) 64174604Sscottl#endif 65174604Sscottl 66174604Sscottl#define MAX_REBUILD_SECTORS 128 67174604Sscottl 68174604Sscottltypedef struct _RAID_FLAGS { 69174604Sscottl HPT_UINT rf_need_initialize : 1; 70174604Sscottl HPT_UINT rf_need_rebuild: 1; 71174604Sscottl HPT_UINT rf_need_sync: 1; 72174604Sscottl /* ioctl flags */ 73174604Sscottl HPT_UINT rf_auto_rebuild: 1; 74174604Sscottl HPT_UINT rf_rebuilding: 1; 75174604Sscottl HPT_UINT rf_verifying: 1; 76174604Sscottl HPT_UINT rf_initializing: 1; 77174604Sscottl HPT_UINT rf_abort_verifying: 1; 78174604Sscottl HPT_UINT rf_raid15: 1; 79174604Sscottl HPT_UINT rf_v3_format : 1; 80174604Sscottl HPT_UINT rf_need_transform : 1; 81174604Sscottl HPT_UINT rf_transforming : 1; 82174604Sscottl HPT_UINT rf_abort_transform : 1; 83174604Sscottl HPT_UINT rf_log_write: 1; 84174604Sscottl} RAID_FLAGS; 85174604Sscottl 86174604Sscottltypedef struct transform_cmd_ext 87174604Sscottl{ 88174604Sscottl HPT_LBA lba; 89174604Sscottl HPT_U16 total_sectors; 90174604Sscottl HPT_U16 finished_sectors; 91174604Sscottl} TRANSFORM_CMD_EXT , *PTRANSFORM_CMD_EXT; 92174604Sscottl 93174604Sscottl 94174604Sscottl#define TO_MOVE_DATA 0 95174604Sscottl#define TO_INITIALIZE 1 96174604Sscottl#define TO_INITIALIZE_ONLY 2 97174604Sscottl#define TO_MOVE_DATA_ONLY 3 98174604Sscottltypedef struct hpt_transform 99174604Sscottl{ 100174604Sscottl HPT_U32 stamp; 101174604Sscottl PVDEV source; 102174604Sscottl PVDEV target; 103174604Sscottl struct list_head link; 104174604Sscottl HPT_U8 transform_from_tail; 105174604Sscottl struct tq_item task; 106174604Sscottl 107174604Sscottl struct lock_request lock; 108174604Sscottl TRANSFORM_CMD_EXT cmdext; 109174604Sscottl 110174604Sscottl HPT_U64 transform_point; 111174604Sscottl HPT_U16 transform_sectors_per_step; 112174604Sscottl HPT_U8 operation; 113174604Sscottl HPT_U8 disabled; 114174604Sscottl} HPT_TRANSFORM, *PHPT_TRANSFORM; 115174604Sscottl 116174604Sscottltypedef struct hpt_array 117174604Sscottl{ 118174604Sscottl HPT_U32 array_stamp; 119174604Sscottl HPT_U32 data_stamp; 120174604Sscottl 121174604Sscottl HPT_U8 ndisk; 122174604Sscottl HPT_U8 block_size_shift; 123174604Sscottl HPT_U16 strip_width; 124176018Sscottl HPT_U8 sector_size_shift; /*sector size = 512B<<sector_size_shift*/ 125176018Sscottl HPT_U8 jid; 126176018Sscottl HPT_U8 reserved[2]; 127174604Sscottl 128174604Sscottl 129174604Sscottl HPT_MMASK outdated_members; 130174604Sscottl HPT_MMASK offline_members; 131174604Sscottl 132174604Sscottl PVDEV member[MAX_MEMBERS]; 133174604Sscottl 134174604Sscottl RAID_FLAGS flags; 135174604Sscottl 136174604Sscottl HPT_U64 rebuilt_sectors; 137174604Sscottl 138174604Sscottl 139174604Sscottl HPT_U8 name[MAX_ARRAY_NAME]; 140174604Sscottl PHPT_TRANSFORM transform; 141174604Sscottl 142174604Sscottl TIME_RECORD create_time; 143174604Sscottl HPT_U8 description[64]; 144174604Sscottl HPT_U8 create_manager[16]; 145174604Sscottl 146174604Sscottl#ifdef OS_SUPPORT_TASK 147174604Sscottl int floating_priority; 148174604Sscottl OSM_TASK ioctl_task; 149174604Sscottl IOCTL_ARG ioctl_arg; 150174604Sscottl 151174604Sscottl char ioctl_inbuf[sizeof(PVDEV)+sizeof(HPT_U64)+sizeof(HPT_U16)]; 152174604Sscottl char ioctl_outbuf[sizeof(HPT_UINT)]; 153174604Sscottl#endif 154174604Sscottl 155174604Sscottl} HPT_ARRAY, *PHPT_ARRAY; 156174604Sscottl 157174604Sscottl#ifdef OS_SUPPORT_TASK 158174604Sscottlvoid ldm_start_rebuild(struct _VDEV *pArray); 159174604Sscottl#else 160174604Sscottl#define ldm_start_rebuild(pArray) 161174604Sscottl#endif 162174604Sscottl 163174604Sscottltypedef struct _raw_partition{ 164174604Sscottl struct _raw_partition * next; 165176018Sscottl __HPT_RAW_LBA start; 166176018Sscottl __HPT_RAW_LBA capacity; 167174604Sscottl PVDEV vd_part; 168174604Sscottl} RAW_PARTITION, *PRAW_PARTITION; 169174604Sscottl 170174604Sscottltypedef struct hpt_partiton 171174604Sscottl{ 172174604Sscottl PVDEV raw_disk; 173176018Sscottl __HPT_RAW_LBA des_location; 174174604Sscottl PRAW_PARTITION raw_part; 175174604Sscottl HPT_U8 del_mbr; 176174604Sscottl HPT_U8 reserved[3]; 177174604Sscottl} HPT_PARTITION, *PHPT_PARTITION; 178174604Sscottl 179174604SscottlHPT_U16 get_strip_size(PVDEV vd); 180174604Sscottl 181174604Sscottlvoid ldm_check_array_online(PVDEV pArray); 182174604Sscottlvoid ldm_generic_member_failed(PVDEV member); 183174604Sscottlvoid ldm_sync_array_info(PVDEV pArray); 184174604Sscottlvoid ldm_sync_array_stamp(PVDEV pArray); 185174604Sscottlvoid ldm_add_spare_to_array(PVDEV pArray, PVDEV spare_partition); 186174604Sscottl 187174604Sscottl#if defined(__cplusplus) 188174604Sscottl} 189174604Sscottl#endif 190174604Sscottl#endif 191