1160814Ssimon/* $Id: array.h,v 1.46 2010/02/05 06:57:43 mah Exp $ */ 2160814Ssimon/*- 3160814Ssimon * Copyright (C) 2004-2011 HighPoint Technologies, Inc. 4160814Ssimon * All rights reserved. 5160814Ssimon * 6160814Ssimon * Redistribution and use in source and binary forms, with or without 7160814Ssimon * modification, are permitted provided that the following conditions 8160814Ssimon * are met: 9160814Ssimon * 1. Redistributions of source code must retain the above copyright 10160814Ssimon * notice, this list of conditions and the following disclaimer. 11160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 12160814Ssimon * notice, this list of conditions and the following disclaimer in the 13160814Ssimon * documentation and/or other materials provided with the distribution. 14160814Ssimon * 15160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16160814Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18160814Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19160814Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20160814Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21160814Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23160814Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24160814Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25160814Ssimon * SUCH DAMAGE. 26160814Ssimon * 27160814Ssimon * $FreeBSD$ 28160814Ssimon */ 29160814Ssimon#include <dev/hptnr/hptnr_config.h> 30160814Ssimon#ifndef _HPT_ARRAY_H_ 31160814Ssimon#define _HPT_ARRAY_H_ 32160814Ssimon 33160814Ssimon#define VERMAGIC_ARRAY 46 34160814Ssimon 35160814Ssimon#if defined(__cplusplus) 36160814Ssimonextern "C" { 37160814Ssimon#endif 38160814Ssimon 39160814Ssimon#define MAX_ARRAY_NAME 16 40160814Ssimon 41160814Ssimon#ifndef MAX_MEMBERS 42160814Ssimon#define MAX_MEMBERS 16 43160814Ssimon#endif 44264331Sjkim 45160814Ssimon#if MAX_MEMBERS<=16 46160814Ssimontypedef HPT_U16 HPT_MMASK; 47160814Ssimon#elif MAX_MEMBERS<=32 48160814Ssimontypedef HPT_U32 HPT_MMASK; 49160814Ssimon#elif MAX_MEMBERS<=64 50160814Ssimontypedef HPT_U64 HPT_MMASK; 51160814Ssimon#else 52160814Ssimon#error "MAX_MEMBERS too large" 53160814Ssimon#endif 54160814Ssimon 55160814Ssimon#define HPT_MMASK_VALUE(x) (HPT_MMASK)((HPT_MMASK)1<<(x)) 56160814Ssimon 57160814Ssimon#if MAX_MEMBERS<32 58160814Ssimon#define HPT_MMASK_VALUE_SAFE(x) HPT_MMASK_VALUE(x) 59160814Ssimon#else 60160814Ssimon#define HPT_MMASK_VALUE_SAFE(x) ((x)>=MAX_MEMBERS? (HPT_MMASK)0 : HPT_MMASK_VALUE(x)) 61160814Ssimon#endif 62160814Ssimon 63160814Ssimon#define MAX_REBUILD_SECTORS 128 64160814Ssimon 65160814Ssimontypedef struct _RAID_FLAGS { 66160814Ssimon HPT_UINT rf_need_initialize : 1; 67160814Ssimon HPT_UINT rf_need_rebuild: 1; 68160814Ssimon HPT_UINT rf_need_sync: 1; 69160814Ssimon /* ioctl flags */ 70160814Ssimon HPT_UINT rf_auto_rebuild: 1; 71160814Ssimon HPT_UINT rf_rebuilding: 1; 72160814Ssimon HPT_UINT rf_verifying: 1; 73160814Ssimon HPT_UINT rf_initializing: 1; 74160814Ssimon HPT_UINT rf_abort_verifying: 1; 75160814Ssimon HPT_UINT rf_raid15: 1; 76160814Ssimon HPT_UINT rf_v3_format : 1; 77160814Ssimon HPT_UINT rf_need_transform : 1; 78160814Ssimon HPT_UINT rf_transforming : 1; 79160814Ssimon HPT_UINT rf_abort_transform : 1; 80160814Ssimon HPT_UINT rf_log_write: 1; 81160814Ssimon} RAID_FLAGS; 82160814Ssimon 83160814Ssimontypedef struct transform_cmd_ext 84160814Ssimon{ 85160814Ssimon HPT_LBA lba; 86160814Ssimon HPT_U16 total_sectors; 87160814Ssimon HPT_U16 finished_sectors; 88160814Ssimon} TRANSFORM_CMD_EXT , *PTRANSFORM_CMD_EXT; 89160814Ssimon 90160814Ssimon 91160814Ssimon#define TO_MOVE_DATA 0 92160814Ssimon#define TO_INITIALIZE 1 93160814Ssimon#define TO_INITIALIZE_ONLY 2 94160814Ssimon#define TO_MOVE_DATA_ONLY 3 95160814Ssimontypedef struct hpt_transform 96160814Ssimon{ 97160814Ssimon HPT_U32 stamp; 98160814Ssimon PVDEV source; 99160814Ssimon PVDEV target; 100160814Ssimon struct list_head link; 101160814Ssimon HPT_U8 transform_from_tail; 102160814Ssimon struct tq_item task; 103160814Ssimon 104160814Ssimon struct lock_request lock; 105160814Ssimon TRANSFORM_CMD_EXT cmdext; 106160814Ssimon 107160814Ssimon HPT_U64 transform_point; 108160814Ssimon HPT_U16 transform_sectors_per_step; 109160814Ssimon HPT_U8 operation; 110160814Ssimon HPT_U8 disabled; 111160814Ssimon} HPT_TRANSFORM, *PHPT_TRANSFORM; 112160814Ssimon 113160814Ssimontypedef struct hpt_array 114160814Ssimon{ 115160814Ssimon HPT_U32 array_stamp; 116160814Ssimon HPT_U32 data_stamp; 117160814Ssimon HPT_U32 array_sn; 118160814Ssimon 119160814Ssimon HPT_U8 ndisk; 120160814Ssimon HPT_U8 block_size_shift; 121160814Ssimon HPT_U16 strip_width; 122160814Ssimon HPT_U8 sector_size_shift; /*sector size = 512B<<sector_size_shift*/ 123160814Ssimon HPT_U8 jid; 124160814Ssimon HPT_U8 reserved[2]; 125160814Ssimon 126160814Ssimon 127160814Ssimon HPT_MMASK outdated_members; 128160814Ssimon HPT_MMASK offline_members; 129160814Ssimon 130160814Ssimon PVDEV member[MAX_MEMBERS]; 131160814Ssimon 132160814Ssimon RAID_FLAGS flags; 133238405Sjkim 134160814Ssimon HPT_U64 rebuilt_sectors; 135160814Ssimon 136160814Ssimon 137160814Ssimon HPT_U8 name[MAX_ARRAY_NAME]; 138160814Ssimon PHPT_TRANSFORM transform; 139160814Ssimon 140160814Ssimon TIME_RECORD create_time; 141160814Ssimon HPT_U8 description[64]; 142160814Ssimon HPT_U8 create_manager[16]; 143160814Ssimon 144160814Ssimon#ifdef OS_SUPPORT_TASK 145160814Ssimon int floating_priority; 146160814Ssimon OSM_TASK ioctl_task; 147160814Ssimon IOCTL_ARG ioctl_arg; 148160814Ssimon 149160814Ssimon char ioctl_inbuf[sizeof(PVDEV)+sizeof(HPT_U64)+sizeof(HPT_U16)]; 150160814Ssimon char ioctl_outbuf[sizeof(HPT_UINT)]; 151160814Ssimon#endif 152160814Ssimon 153160814Ssimon} HPT_ARRAY, *PHPT_ARRAY; 154160814Ssimon 155160814Ssimon#ifdef OS_SUPPORT_TASK 156160814Ssimonvoid ldm_start_rebuild(struct _VDEV *pArray); 157160814Ssimon#else 158160814Ssimon#define ldm_start_rebuild(pArray) 159160814Ssimon#endif 160160814Ssimon 161160814Ssimontypedef struct _raw_partition{ 162160814Ssimon struct _raw_partition * next; 163160814Ssimon __HPT_RAW_LBA start; 164160814Ssimon __HPT_RAW_LBA capacity; 165160814Ssimon PVDEV vd_part; 166160814Ssimon} RAW_PARTITION, *PRAW_PARTITION; 167160814Ssimon 168160814Ssimontypedef struct hpt_partiton 169160814Ssimon{ 170160814Ssimon PVDEV raw_disk; 171160814Ssimon __HPT_RAW_LBA des_location; 172160814Ssimon PRAW_PARTITION raw_part; 173160814Ssimon HPT_U8 del_mbr; 174160814Ssimon HPT_U8 reserved[3]; 175160814Ssimon} HPT_PARTITION, *PHPT_PARTITION; 176160814Ssimon 177160814Ssimonvoid ldm_check_array_online(PVDEV pArray); 178160814Ssimonvoid ldm_generic_member_failed(PVDEV member); 179160814Ssimonvoid ldm_sync_array_info(PVDEV pArray); 180160814Ssimonvoid ldm_sync_array_stamp(PVDEV pArray); 181160814Ssimonvoid ldm_add_spare_to_array(PVDEV pArray, PVDEV spare_partition); 182160814Ssimon 183160814Ssimon#if defined(__cplusplus) 184160814Ssimon} 185160814Ssimon#endif 186160814Ssimon#endif 187160814Ssimon