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