1252867Sdelphij/* $Id: array.h,v 1.46 2010/02/05 06:57:43 mah Exp $ */ 2252867Sdelphij/*- 3252867Sdelphij * Copyright (C) 2004-2011 HighPoint Technologies, Inc. 4252867Sdelphij * All rights reserved. 5252867Sdelphij * 6252867Sdelphij * Redistribution and use in source and binary forms, with or without 7252867Sdelphij * modification, are permitted provided that the following conditions 8252867Sdelphij * are met: 9252867Sdelphij * 1. Redistributions of source code must retain the above copyright 10252867Sdelphij * notice, this list of conditions and the following disclaimer. 11252867Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 12252867Sdelphij * notice, this list of conditions and the following disclaimer in the 13252867Sdelphij * documentation and/or other materials provided with the distribution. 14252867Sdelphij * 15252867Sdelphij * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16252867Sdelphij * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17252867Sdelphij * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18252867Sdelphij * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19252867Sdelphij * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20252867Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21252867Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22252867Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23252867Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24252867Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25252867Sdelphij * SUCH DAMAGE. 26252867Sdelphij * 27252867Sdelphij * $FreeBSD$ 28252867Sdelphij */ 29252867Sdelphij#include <dev/hptnr/hptnr_config.h> 30252867Sdelphij#ifndef _HPT_ARRAY_H_ 31252867Sdelphij#define _HPT_ARRAY_H_ 32252867Sdelphij 33252867Sdelphij#define VERMAGIC_ARRAY 46 34252867Sdelphij 35252867Sdelphij#if defined(__cplusplus) 36252867Sdelphijextern "C" { 37252867Sdelphij#endif 38252867Sdelphij 39252867Sdelphij#define MAX_ARRAY_NAME 16 40252867Sdelphij 41252867Sdelphij#ifndef MAX_MEMBERS 42252867Sdelphij#define MAX_MEMBERS 16 43252867Sdelphij#endif 44252867Sdelphij 45252867Sdelphij#if MAX_MEMBERS<=16 46252867Sdelphijtypedef HPT_U16 HPT_MMASK; 47252867Sdelphij#elif MAX_MEMBERS<=32 48252867Sdelphijtypedef HPT_U32 HPT_MMASK; 49252867Sdelphij#elif MAX_MEMBERS<=64 50252867Sdelphijtypedef HPT_U64 HPT_MMASK; 51252867Sdelphij#else 52252867Sdelphij#error "MAX_MEMBERS too large" 53252867Sdelphij#endif 54252867Sdelphij 55252867Sdelphij#define HPT_MMASK_VALUE(x) (HPT_MMASK)((HPT_MMASK)1<<(x)) 56252867Sdelphij 57252867Sdelphij#if MAX_MEMBERS<32 58252867Sdelphij#define HPT_MMASK_VALUE_SAFE(x) HPT_MMASK_VALUE(x) 59252867Sdelphij#else 60252867Sdelphij#define HPT_MMASK_VALUE_SAFE(x) ((x)>=MAX_MEMBERS? (HPT_MMASK)0 : HPT_MMASK_VALUE(x)) 61252867Sdelphij#endif 62252867Sdelphij 63252867Sdelphij#define MAX_REBUILD_SECTORS 128 64252867Sdelphij 65252867Sdelphijtypedef struct _RAID_FLAGS { 66252867Sdelphij HPT_UINT rf_need_initialize : 1; 67252867Sdelphij HPT_UINT rf_need_rebuild: 1; 68252867Sdelphij HPT_UINT rf_need_sync: 1; 69252867Sdelphij /* ioctl flags */ 70252867Sdelphij HPT_UINT rf_auto_rebuild: 1; 71252867Sdelphij HPT_UINT rf_rebuilding: 1; 72252867Sdelphij HPT_UINT rf_verifying: 1; 73252867Sdelphij HPT_UINT rf_initializing: 1; 74252867Sdelphij HPT_UINT rf_abort_verifying: 1; 75252867Sdelphij HPT_UINT rf_raid15: 1; 76252867Sdelphij HPT_UINT rf_v3_format : 1; 77252867Sdelphij HPT_UINT rf_need_transform : 1; 78252867Sdelphij HPT_UINT rf_transforming : 1; 79252867Sdelphij HPT_UINT rf_abort_transform : 1; 80252867Sdelphij HPT_UINT rf_log_write: 1; 81252867Sdelphij} RAID_FLAGS; 82252867Sdelphij 83252867Sdelphijtypedef struct transform_cmd_ext 84252867Sdelphij{ 85252867Sdelphij HPT_LBA lba; 86252867Sdelphij HPT_U16 total_sectors; 87252867Sdelphij HPT_U16 finished_sectors; 88252867Sdelphij} TRANSFORM_CMD_EXT , *PTRANSFORM_CMD_EXT; 89252867Sdelphij 90252867Sdelphij 91252867Sdelphij#define TO_MOVE_DATA 0 92252867Sdelphij#define TO_INITIALIZE 1 93252867Sdelphij#define TO_INITIALIZE_ONLY 2 94252867Sdelphij#define TO_MOVE_DATA_ONLY 3 95252867Sdelphijtypedef struct hpt_transform 96252867Sdelphij{ 97252867Sdelphij HPT_U32 stamp; 98252867Sdelphij PVDEV source; 99252867Sdelphij PVDEV target; 100252867Sdelphij struct list_head link; 101252867Sdelphij HPT_U8 transform_from_tail; 102252867Sdelphij struct tq_item task; 103252867Sdelphij 104252867Sdelphij struct lock_request lock; 105252867Sdelphij TRANSFORM_CMD_EXT cmdext; 106252867Sdelphij 107252867Sdelphij HPT_U64 transform_point; 108252867Sdelphij HPT_U16 transform_sectors_per_step; 109252867Sdelphij HPT_U8 operation; 110252867Sdelphij HPT_U8 disabled; 111252867Sdelphij} HPT_TRANSFORM, *PHPT_TRANSFORM; 112252867Sdelphij 113252867Sdelphijtypedef struct hpt_array 114252867Sdelphij{ 115252867Sdelphij HPT_U32 array_stamp; 116252867Sdelphij HPT_U32 data_stamp; 117252867Sdelphij HPT_U32 array_sn; 118252867Sdelphij 119252867Sdelphij HPT_U8 ndisk; 120252867Sdelphij HPT_U8 block_size_shift; 121252867Sdelphij HPT_U16 strip_width; 122252867Sdelphij HPT_U8 sector_size_shift; /*sector size = 512B<<sector_size_shift*/ 123252867Sdelphij HPT_U8 jid; 124252867Sdelphij HPT_U8 reserved[2]; 125252867Sdelphij 126252867Sdelphij 127252867Sdelphij HPT_MMASK outdated_members; 128252867Sdelphij HPT_MMASK offline_members; 129252867Sdelphij 130252867Sdelphij PVDEV member[MAX_MEMBERS]; 131252867Sdelphij 132252867Sdelphij RAID_FLAGS flags; 133252867Sdelphij 134252867Sdelphij HPT_U64 rebuilt_sectors; 135252867Sdelphij 136252867Sdelphij 137252867Sdelphij HPT_U8 name[MAX_ARRAY_NAME]; 138252867Sdelphij PHPT_TRANSFORM transform; 139252867Sdelphij 140252867Sdelphij TIME_RECORD create_time; 141252867Sdelphij HPT_U8 description[64]; 142252867Sdelphij HPT_U8 create_manager[16]; 143252867Sdelphij 144252867Sdelphij#ifdef OS_SUPPORT_TASK 145252867Sdelphij int floating_priority; 146252867Sdelphij OSM_TASK ioctl_task; 147252867Sdelphij IOCTL_ARG ioctl_arg; 148252867Sdelphij 149252867Sdelphij char ioctl_inbuf[sizeof(PVDEV)+sizeof(HPT_U64)+sizeof(HPT_U16)]; 150252867Sdelphij char ioctl_outbuf[sizeof(HPT_UINT)]; 151252867Sdelphij#endif 152252867Sdelphij 153252867Sdelphij} HPT_ARRAY, *PHPT_ARRAY; 154252867Sdelphij 155252867Sdelphij#ifdef OS_SUPPORT_TASK 156252867Sdelphijvoid ldm_start_rebuild(struct _VDEV *pArray); 157252867Sdelphij#else 158252867Sdelphij#define ldm_start_rebuild(pArray) 159252867Sdelphij#endif 160252867Sdelphij 161252867Sdelphijtypedef struct _raw_partition{ 162252867Sdelphij struct _raw_partition * next; 163252867Sdelphij __HPT_RAW_LBA start; 164252867Sdelphij __HPT_RAW_LBA capacity; 165252867Sdelphij PVDEV vd_part; 166252867Sdelphij} RAW_PARTITION, *PRAW_PARTITION; 167252867Sdelphij 168252867Sdelphijtypedef struct hpt_partiton 169252867Sdelphij{ 170252867Sdelphij PVDEV raw_disk; 171252867Sdelphij __HPT_RAW_LBA des_location; 172252867Sdelphij PRAW_PARTITION raw_part; 173252867Sdelphij HPT_U8 del_mbr; 174252867Sdelphij HPT_U8 reserved[3]; 175252867Sdelphij} HPT_PARTITION, *PHPT_PARTITION; 176252867Sdelphij 177252867Sdelphijvoid ldm_check_array_online(PVDEV pArray); 178252867Sdelphijvoid ldm_generic_member_failed(PVDEV member); 179252867Sdelphijvoid ldm_sync_array_info(PVDEV pArray); 180252867Sdelphijvoid ldm_sync_array_stamp(PVDEV pArray); 181252867Sdelphijvoid ldm_add_spare_to_array(PVDEV pArray, PVDEV spare_partition); 182252867Sdelphij 183252867Sdelphij#if defined(__cplusplus) 184252867Sdelphij} 185252867Sdelphij#endif 186252867Sdelphij#endif 187