| @@ -1,1387 +1,1387 @@ | | | @@ -1,1387 +1,1387 @@ |
1 | /* $NetBSD: rf_netbsdkintf.c,v 1.273 2010/03/14 21:11:41 jld Exp $ */ | | 1 | /* $NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. | | 3 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to The NetBSD Foundation | | 6 | * This code is derived from software contributed to The NetBSD Foundation |
7 | * by Greg Oster; Jason R. Thorpe. | | 7 | * by Greg Oster; Jason R. Thorpe. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
15 | * notice, this list of conditions and the following disclaimer in the | | 15 | * notice, this list of conditions and the following disclaimer in the |
16 | * documentation and/or other materials provided with the distribution. | | 16 | * documentation and/or other materials provided with the distribution. |
17 | * | | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | * POSSIBILITY OF SUCH DAMAGE. | | 28 | * POSSIBILITY OF SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | /* | | 31 | /* |
32 | * Copyright (c) 1990, 1993 | | 32 | * Copyright (c) 1990, 1993 |
33 | * The Regents of the University of California. All rights reserved. | | 33 | * The Regents of the University of California. All rights reserved. |
34 | * | | 34 | * |
35 | * This code is derived from software contributed to Berkeley by | | 35 | * This code is derived from software contributed to Berkeley by |
36 | * the Systems Programming Group of the University of Utah Computer | | 36 | * the Systems Programming Group of the University of Utah Computer |
37 | * Science Department. | | 37 | * Science Department. |
38 | * | | 38 | * |
39 | * Redistribution and use in source and binary forms, with or without | | 39 | * Redistribution and use in source and binary forms, with or without |
40 | * modification, are permitted provided that the following conditions | | 40 | * modification, are permitted provided that the following conditions |
41 | * are met: | | 41 | * are met: |
42 | * 1. Redistributions of source code must retain the above copyright | | 42 | * 1. Redistributions of source code must retain the above copyright |
43 | * notice, this list of conditions and the following disclaimer. | | 43 | * notice, this list of conditions and the following disclaimer. |
44 | * 2. Redistributions in binary form must reproduce the above copyright | | 44 | * 2. Redistributions in binary form must reproduce the above copyright |
45 | * notice, this list of conditions and the following disclaimer in the | | 45 | * notice, this list of conditions and the following disclaimer in the |
46 | * documentation and/or other materials provided with the distribution. | | 46 | * documentation and/or other materials provided with the distribution. |
47 | * 3. Neither the name of the University nor the names of its contributors | | 47 | * 3. Neither the name of the University nor the names of its contributors |
48 | * may be used to endorse or promote products derived from this software | | 48 | * may be used to endorse or promote products derived from this software |
49 | * without specific prior written permission. | | 49 | * without specific prior written permission. |
50 | * | | 50 | * |
51 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 51 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
61 | * SUCH DAMAGE. | | 61 | * SUCH DAMAGE. |
62 | * | | 62 | * |
63 | * from: Utah $Hdr: cd.c 1.6 90/11/28$ | | 63 | * from: Utah $Hdr: cd.c 1.6 90/11/28$ |
64 | * | | 64 | * |
65 | * @(#)cd.c 8.2 (Berkeley) 11/16/93 | | 65 | * @(#)cd.c 8.2 (Berkeley) 11/16/93 |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * Copyright (c) 1988 University of Utah. | | 69 | * Copyright (c) 1988 University of Utah. |
70 | * | | 70 | * |
71 | * This code is derived from software contributed to Berkeley by | | 71 | * This code is derived from software contributed to Berkeley by |
72 | * the Systems Programming Group of the University of Utah Computer | | 72 | * the Systems Programming Group of the University of Utah Computer |
73 | * Science Department. | | 73 | * Science Department. |
74 | * | | 74 | * |
75 | * Redistribution and use in source and binary forms, with or without | | 75 | * Redistribution and use in source and binary forms, with or without |
76 | * modification, are permitted provided that the following conditions | | 76 | * modification, are permitted provided that the following conditions |
77 | * are met: | | 77 | * are met: |
78 | * 1. Redistributions of source code must retain the above copyright | | 78 | * 1. Redistributions of source code must retain the above copyright |
79 | * notice, this list of conditions and the following disclaimer. | | 79 | * notice, this list of conditions and the following disclaimer. |
80 | * 2. Redistributions in binary form must reproduce the above copyright | | 80 | * 2. Redistributions in binary form must reproduce the above copyright |
81 | * notice, this list of conditions and the following disclaimer in the | | 81 | * notice, this list of conditions and the following disclaimer in the |
82 | * documentation and/or other materials provided with the distribution. | | 82 | * documentation and/or other materials provided with the distribution. |
83 | * 3. All advertising materials mentioning features or use of this software | | 83 | * 3. All advertising materials mentioning features or use of this software |
84 | * must display the following acknowledgement: | | 84 | * must display the following acknowledgement: |
85 | * This product includes software developed by the University of | | 85 | * This product includes software developed by the University of |
86 | * California, Berkeley and its contributors. | | 86 | * California, Berkeley and its contributors. |
87 | * 4. Neither the name of the University nor the names of its contributors | | 87 | * 4. Neither the name of the University nor the names of its contributors |
88 | * may be used to endorse or promote products derived from this software | | 88 | * may be used to endorse or promote products derived from this software |
89 | * without specific prior written permission. | | 89 | * without specific prior written permission. |
90 | * | | 90 | * |
91 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 91 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
92 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 92 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
93 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 93 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
94 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 94 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
95 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 95 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
96 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 96 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
97 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 97 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
98 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 98 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
99 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 99 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
100 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 100 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
101 | * SUCH DAMAGE. | | 101 | * SUCH DAMAGE. |
102 | * | | 102 | * |
103 | * from: Utah $Hdr: cd.c 1.6 90/11/28$ | | 103 | * from: Utah $Hdr: cd.c 1.6 90/11/28$ |
104 | * | | 104 | * |
105 | * @(#)cd.c 8.2 (Berkeley) 11/16/93 | | 105 | * @(#)cd.c 8.2 (Berkeley) 11/16/93 |
106 | */ | | 106 | */ |
107 | | | 107 | |
108 | /* | | 108 | /* |
109 | * Copyright (c) 1995 Carnegie-Mellon University. | | 109 | * Copyright (c) 1995 Carnegie-Mellon University. |
110 | * All rights reserved. | | 110 | * All rights reserved. |
111 | * | | 111 | * |
112 | * Authors: Mark Holland, Jim Zelenka | | 112 | * Authors: Mark Holland, Jim Zelenka |
113 | * | | 113 | * |
114 | * Permission to use, copy, modify and distribute this software and | | 114 | * Permission to use, copy, modify and distribute this software and |
115 | * its documentation is hereby granted, provided that both the copyright | | 115 | * its documentation is hereby granted, provided that both the copyright |
116 | * notice and this permission notice appear in all copies of the | | 116 | * notice and this permission notice appear in all copies of the |
117 | * software, derivative works or modified versions, and any portions | | 117 | * software, derivative works or modified versions, and any portions |
118 | * thereof, and that both notices appear in supporting documentation. | | 118 | * thereof, and that both notices appear in supporting documentation. |
119 | * | | 119 | * |
120 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | | 120 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
121 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | | 121 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND |
122 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | | 122 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. |
123 | * | | 123 | * |
124 | * Carnegie Mellon requests users of this software to return to | | 124 | * Carnegie Mellon requests users of this software to return to |
125 | * | | 125 | * |
126 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | | 126 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
127 | * School of Computer Science | | 127 | * School of Computer Science |
128 | * Carnegie Mellon University | | 128 | * Carnegie Mellon University |
129 | * Pittsburgh PA 15213-3890 | | 129 | * Pittsburgh PA 15213-3890 |
130 | * | | 130 | * |
131 | * any improvements or extensions that they make and grant Carnegie the | | 131 | * any improvements or extensions that they make and grant Carnegie the |
132 | * rights to redistribute these changes. | | 132 | * rights to redistribute these changes. |
133 | */ | | 133 | */ |
134 | | | 134 | |
135 | /*********************************************************** | | 135 | /*********************************************************** |
136 | * | | 136 | * |
137 | * rf_kintf.c -- the kernel interface routines for RAIDframe | | 137 | * rf_kintf.c -- the kernel interface routines for RAIDframe |
138 | * | | 138 | * |
139 | ***********************************************************/ | | 139 | ***********************************************************/ |
140 | | | 140 | |
141 | #include <sys/cdefs.h> | | 141 | #include <sys/cdefs.h> |
142 | __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.273 2010/03/14 21:11:41 jld Exp $"); | | 142 | __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $"); |
143 | | | 143 | |
144 | #ifdef _KERNEL_OPT | | 144 | #ifdef _KERNEL_OPT |
145 | #include "opt_compat_netbsd.h" | | 145 | #include "opt_compat_netbsd.h" |
146 | #include "opt_raid_autoconfig.h" | | 146 | #include "opt_raid_autoconfig.h" |
147 | #include "raid.h" | | 147 | #include "raid.h" |
148 | #endif | | 148 | #endif |
149 | | | 149 | |
150 | #include <sys/param.h> | | 150 | #include <sys/param.h> |
151 | #include <sys/errno.h> | | 151 | #include <sys/errno.h> |
152 | #include <sys/pool.h> | | 152 | #include <sys/pool.h> |
153 | #include <sys/proc.h> | | 153 | #include <sys/proc.h> |
154 | #include <sys/queue.h> | | 154 | #include <sys/queue.h> |
155 | #include <sys/disk.h> | | 155 | #include <sys/disk.h> |
156 | #include <sys/device.h> | | 156 | #include <sys/device.h> |
157 | #include <sys/stat.h> | | 157 | #include <sys/stat.h> |
158 | #include <sys/ioctl.h> | | 158 | #include <sys/ioctl.h> |
159 | #include <sys/fcntl.h> | | 159 | #include <sys/fcntl.h> |
160 | #include <sys/systm.h> | | 160 | #include <sys/systm.h> |
161 | #include <sys/vnode.h> | | 161 | #include <sys/vnode.h> |
162 | #include <sys/disklabel.h> | | 162 | #include <sys/disklabel.h> |
163 | #include <sys/conf.h> | | 163 | #include <sys/conf.h> |
164 | #include <sys/buf.h> | | 164 | #include <sys/buf.h> |
165 | #include <sys/bufq.h> | | 165 | #include <sys/bufq.h> |
166 | #include <sys/reboot.h> | | 166 | #include <sys/reboot.h> |
167 | #include <sys/kauth.h> | | 167 | #include <sys/kauth.h> |
168 | | | 168 | |
169 | #include <prop/proplib.h> | | 169 | #include <prop/proplib.h> |
170 | | | 170 | |
171 | #include <dev/raidframe/raidframevar.h> | | 171 | #include <dev/raidframe/raidframevar.h> |
172 | #include <dev/raidframe/raidframeio.h> | | 172 | #include <dev/raidframe/raidframeio.h> |
173 | #include <dev/raidframe/rf_paritymap.h> | | 173 | #include <dev/raidframe/rf_paritymap.h> |
174 | | | 174 | |
175 | #include "rf_raid.h" | | 175 | #include "rf_raid.h" |
176 | #include "rf_copyback.h" | | 176 | #include "rf_copyback.h" |
177 | #include "rf_dag.h" | | 177 | #include "rf_dag.h" |
178 | #include "rf_dagflags.h" | | 178 | #include "rf_dagflags.h" |
179 | #include "rf_desc.h" | | 179 | #include "rf_desc.h" |
180 | #include "rf_diskqueue.h" | | 180 | #include "rf_diskqueue.h" |
181 | #include "rf_etimer.h" | | 181 | #include "rf_etimer.h" |
182 | #include "rf_general.h" | | 182 | #include "rf_general.h" |
183 | #include "rf_kintf.h" | | 183 | #include "rf_kintf.h" |
184 | #include "rf_options.h" | | 184 | #include "rf_options.h" |
185 | #include "rf_driver.h" | | 185 | #include "rf_driver.h" |
186 | #include "rf_parityscan.h" | | 186 | #include "rf_parityscan.h" |
187 | #include "rf_threadstuff.h" | | 187 | #include "rf_threadstuff.h" |
188 | | | 188 | |
189 | #ifdef COMPAT_50 | | 189 | #ifdef COMPAT_50 |
190 | #include "rf_compat50.h" | | 190 | #include "rf_compat50.h" |
191 | #endif | | 191 | #endif |
192 | | | 192 | |
193 | #ifdef DEBUG | | 193 | #ifdef DEBUG |
194 | int rf_kdebug_level = 0; | | 194 | int rf_kdebug_level = 0; |
195 | #define db1_printf(a) if (rf_kdebug_level > 0) printf a | | 195 | #define db1_printf(a) if (rf_kdebug_level > 0) printf a |
196 | #else /* DEBUG */ | | 196 | #else /* DEBUG */ |
197 | #define db1_printf(a) { } | | 197 | #define db1_printf(a) { } |
198 | #endif /* DEBUG */ | | 198 | #endif /* DEBUG */ |
199 | | | 199 | |
200 | static RF_Raid_t **raidPtrs; /* global raid device descriptors */ | | 200 | static RF_Raid_t **raidPtrs; /* global raid device descriptors */ |
201 | | | 201 | |
202 | #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) | | 202 | #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) |
203 | RF_DECLARE_STATIC_MUTEX(rf_sparet_wait_mutex) | | 203 | RF_DECLARE_STATIC_MUTEX(rf_sparet_wait_mutex) |
204 | | | 204 | |
205 | static RF_SparetWait_t *rf_sparet_wait_queue; /* requests to install a | | 205 | static RF_SparetWait_t *rf_sparet_wait_queue; /* requests to install a |
206 | * spare table */ | | 206 | * spare table */ |
207 | static RF_SparetWait_t *rf_sparet_resp_queue; /* responses from | | 207 | static RF_SparetWait_t *rf_sparet_resp_queue; /* responses from |
208 | * installation process */ | | 208 | * installation process */ |
209 | #endif | | 209 | #endif |
210 | | | 210 | |
211 | MALLOC_DEFINE(M_RAIDFRAME, "RAIDframe", "RAIDframe structures"); | | 211 | MALLOC_DEFINE(M_RAIDFRAME, "RAIDframe", "RAIDframe structures"); |
212 | | | 212 | |
213 | /* prototypes */ | | 213 | /* prototypes */ |
214 | static void KernelWakeupFunc(struct buf *); | | 214 | static void KernelWakeupFunc(struct buf *); |
215 | static void InitBP(struct buf *, struct vnode *, unsigned, | | 215 | static void InitBP(struct buf *, struct vnode *, unsigned, |
216 | dev_t, RF_SectorNum_t, RF_SectorCount_t, void *, void (*) (struct buf *), | | 216 | dev_t, RF_SectorNum_t, RF_SectorCount_t, void *, void (*) (struct buf *), |
217 | void *, int, struct proc *); | | 217 | void *, int, struct proc *); |
218 | static void raidinit(RF_Raid_t *); | | 218 | static void raidinit(RF_Raid_t *); |
219 | | | 219 | |
220 | void raidattach(int); | | 220 | void raidattach(int); |
221 | static int raid_match(device_t, cfdata_t, void *); | | 221 | static int raid_match(device_t, cfdata_t, void *); |
222 | static void raid_attach(device_t, device_t, void *); | | 222 | static void raid_attach(device_t, device_t, void *); |
223 | static int raid_detach(device_t, int); | | 223 | static int raid_detach(device_t, int); |
224 | | | 224 | |
225 | static int raidread_component_area(dev_t, struct vnode *, void *, size_t, | | 225 | static int raidread_component_area(dev_t, struct vnode *, void *, size_t, |
226 | daddr_t, daddr_t); | | 226 | daddr_t, daddr_t); |
227 | static int raidwrite_component_area(dev_t, struct vnode *, void *, size_t, | | 227 | static int raidwrite_component_area(dev_t, struct vnode *, void *, size_t, |
228 | daddr_t, daddr_t, int); | | 228 | daddr_t, daddr_t, int); |
229 | | | 229 | |
230 | static int raidwrite_component_label(dev_t, struct vnode *, | | 230 | static int raidwrite_component_label(dev_t, struct vnode *, |
231 | RF_ComponentLabel_t *); | | 231 | RF_ComponentLabel_t *); |
232 | static int raidread_component_label(dev_t, struct vnode *, | | 232 | static int raidread_component_label(dev_t, struct vnode *, |
233 | RF_ComponentLabel_t *); | | 233 | RF_ComponentLabel_t *); |
234 | | | 234 | |
235 | | | 235 | |
236 | dev_type_open(raidopen); | | 236 | dev_type_open(raidopen); |
237 | dev_type_close(raidclose); | | 237 | dev_type_close(raidclose); |
238 | dev_type_read(raidread); | | 238 | dev_type_read(raidread); |
239 | dev_type_write(raidwrite); | | 239 | dev_type_write(raidwrite); |
240 | dev_type_ioctl(raidioctl); | | 240 | dev_type_ioctl(raidioctl); |
241 | dev_type_strategy(raidstrategy); | | 241 | dev_type_strategy(raidstrategy); |
242 | dev_type_dump(raiddump); | | 242 | dev_type_dump(raiddump); |
243 | dev_type_size(raidsize); | | 243 | dev_type_size(raidsize); |
244 | | | 244 | |
245 | const struct bdevsw raid_bdevsw = { | | 245 | const struct bdevsw raid_bdevsw = { |
246 | raidopen, raidclose, raidstrategy, raidioctl, | | 246 | raidopen, raidclose, raidstrategy, raidioctl, |
247 | raiddump, raidsize, D_DISK | | 247 | raiddump, raidsize, D_DISK |
248 | }; | | 248 | }; |
249 | | | 249 | |
250 | const struct cdevsw raid_cdevsw = { | | 250 | const struct cdevsw raid_cdevsw = { |
251 | raidopen, raidclose, raidread, raidwrite, raidioctl, | | 251 | raidopen, raidclose, raidread, raidwrite, raidioctl, |
252 | nostop, notty, nopoll, nommap, nokqfilter, D_DISK | | 252 | nostop, notty, nopoll, nommap, nokqfilter, D_DISK |
253 | }; | | 253 | }; |
254 | | | 254 | |
255 | static struct dkdriver rf_dkdriver = { raidstrategy, minphys }; | | 255 | static struct dkdriver rf_dkdriver = { raidstrategy, minphys }; |
256 | | | 256 | |
257 | /* XXX Not sure if the following should be replacing the raidPtrs above, | | 257 | /* XXX Not sure if the following should be replacing the raidPtrs above, |
258 | or if it should be used in conjunction with that... | | 258 | or if it should be used in conjunction with that... |
259 | */ | | 259 | */ |
260 | | | 260 | |
261 | struct raid_softc { | | 261 | struct raid_softc { |
262 | device_t sc_dev; | | 262 | device_t sc_dev; |
263 | int sc_flags; /* flags */ | | 263 | int sc_flags; /* flags */ |
264 | int sc_cflags; /* configuration flags */ | | 264 | int sc_cflags; /* configuration flags */ |
265 | uint64_t sc_size; /* size of the raid device */ | | 265 | uint64_t sc_size; /* size of the raid device */ |
266 | char sc_xname[20]; /* XXX external name */ | | 266 | char sc_xname[20]; /* XXX external name */ |
267 | struct disk sc_dkdev; /* generic disk device info */ | | 267 | struct disk sc_dkdev; /* generic disk device info */ |
268 | struct bufq_state *buf_queue; /* used for the device queue */ | | 268 | struct bufq_state *buf_queue; /* used for the device queue */ |
269 | }; | | 269 | }; |
270 | /* sc_flags */ | | 270 | /* sc_flags */ |
271 | #define RAIDF_INITED 0x01 /* unit has been initialized */ | | 271 | #define RAIDF_INITED 0x01 /* unit has been initialized */ |
272 | #define RAIDF_WLABEL 0x02 /* label area is writable */ | | 272 | #define RAIDF_WLABEL 0x02 /* label area is writable */ |
273 | #define RAIDF_LABELLING 0x04 /* unit is currently being labelled */ | | 273 | #define RAIDF_LABELLING 0x04 /* unit is currently being labelled */ |
274 | #define RAIDF_SHUTDOWN 0x08 /* unit is being shutdown */ | | 274 | #define RAIDF_SHUTDOWN 0x08 /* unit is being shutdown */ |
275 | #define RAIDF_WANTED 0x40 /* someone is waiting to obtain a lock */ | | 275 | #define RAIDF_WANTED 0x40 /* someone is waiting to obtain a lock */ |
276 | #define RAIDF_LOCKED 0x80 /* unit is locked */ | | 276 | #define RAIDF_LOCKED 0x80 /* unit is locked */ |
277 | | | 277 | |
278 | #define raidunit(x) DISKUNIT(x) | | 278 | #define raidunit(x) DISKUNIT(x) |
279 | int numraid = 0; | | 279 | int numraid = 0; |
280 | | | 280 | |
281 | extern struct cfdriver raid_cd; | | 281 | extern struct cfdriver raid_cd; |
282 | CFATTACH_DECL3_NEW(raid, sizeof(struct raid_softc), | | 282 | CFATTACH_DECL3_NEW(raid, sizeof(struct raid_softc), |
283 | raid_match, raid_attach, raid_detach, NULL, NULL, NULL, | | 283 | raid_match, raid_attach, raid_detach, NULL, NULL, NULL, |
284 | DVF_DETACH_SHUTDOWN); | | 284 | DVF_DETACH_SHUTDOWN); |
285 | | | 285 | |
286 | /* | | 286 | /* |
287 | * Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device. | | 287 | * Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device. |
288 | * Be aware that large numbers can allow the driver to consume a lot of | | 288 | * Be aware that large numbers can allow the driver to consume a lot of |
289 | * kernel memory, especially on writes, and in degraded mode reads. | | 289 | * kernel memory, especially on writes, and in degraded mode reads. |
290 | * | | 290 | * |
291 | * For example: with a stripe width of 64 blocks (32k) and 5 disks, | | 291 | * For example: with a stripe width of 64 blocks (32k) and 5 disks, |
292 | * a single 64K write will typically require 64K for the old data, | | 292 | * a single 64K write will typically require 64K for the old data, |
293 | * 64K for the old parity, and 64K for the new parity, for a total | | 293 | * 64K for the old parity, and 64K for the new parity, for a total |
294 | * of 192K (if the parity buffer is not re-used immediately). | | 294 | * of 192K (if the parity buffer is not re-used immediately). |
295 | * Even it if is used immediately, that's still 128K, which when multiplied | | 295 | * Even it if is used immediately, that's still 128K, which when multiplied |
296 | * by say 10 requests, is 1280K, *on top* of the 640K of incoming data. | | 296 | * by say 10 requests, is 1280K, *on top* of the 640K of incoming data. |
297 | * | | 297 | * |
298 | * Now in degraded mode, for example, a 64K read on the above setup may | | 298 | * Now in degraded mode, for example, a 64K read on the above setup may |
299 | * require data reconstruction, which will require *all* of the 4 remaining | | 299 | * require data reconstruction, which will require *all* of the 4 remaining |
300 | * disks to participate -- 4 * 32K/disk == 128K again. | | 300 | * disks to participate -- 4 * 32K/disk == 128K again. |
301 | */ | | 301 | */ |
302 | | | 302 | |
303 | #ifndef RAIDOUTSTANDING | | 303 | #ifndef RAIDOUTSTANDING |
304 | #define RAIDOUTSTANDING 6 | | 304 | #define RAIDOUTSTANDING 6 |
305 | #endif | | 305 | #endif |
306 | | | 306 | |
307 | #define RAIDLABELDEV(dev) \ | | 307 | #define RAIDLABELDEV(dev) \ |
308 | (MAKEDISKDEV(major((dev)), raidunit((dev)), RAW_PART)) | | 308 | (MAKEDISKDEV(major((dev)), raidunit((dev)), RAW_PART)) |
309 | | | 309 | |
310 | /* declared here, and made public, for the benefit of KVM stuff.. */ | | 310 | /* declared here, and made public, for the benefit of KVM stuff.. */ |
311 | struct raid_softc *raid_softc; | | 311 | struct raid_softc *raid_softc; |
312 | | | 312 | |
313 | static void raidgetdefaultlabel(RF_Raid_t *, struct raid_softc *, | | 313 | static void raidgetdefaultlabel(RF_Raid_t *, struct raid_softc *, |
314 | struct disklabel *); | | 314 | struct disklabel *); |
315 | static void raidgetdisklabel(dev_t); | | 315 | static void raidgetdisklabel(dev_t); |
316 | static void raidmakedisklabel(struct raid_softc *); | | 316 | static void raidmakedisklabel(struct raid_softc *); |
317 | | | 317 | |
318 | static int raidlock(struct raid_softc *); | | 318 | static int raidlock(struct raid_softc *); |
319 | static void raidunlock(struct raid_softc *); | | 319 | static void raidunlock(struct raid_softc *); |
320 | | | 320 | |
321 | static int raid_detach_unlocked(struct raid_softc *); | | 321 | static int raid_detach_unlocked(struct raid_softc *); |
322 | | | 322 | |
323 | static void rf_markalldirty(RF_Raid_t *); | | 323 | static void rf_markalldirty(RF_Raid_t *); |
324 | static void rf_set_properties(struct raid_softc *, RF_Raid_t *); | | 324 | static void rf_set_properties(struct raid_softc *, RF_Raid_t *); |
325 | | | 325 | |
326 | void rf_ReconThread(struct rf_recon_req *); | | 326 | void rf_ReconThread(struct rf_recon_req *); |
327 | void rf_RewriteParityThread(RF_Raid_t *raidPtr); | | 327 | void rf_RewriteParityThread(RF_Raid_t *raidPtr); |
328 | void rf_CopybackThread(RF_Raid_t *raidPtr); | | 328 | void rf_CopybackThread(RF_Raid_t *raidPtr); |
329 | void rf_ReconstructInPlaceThread(struct rf_recon_req *); | | 329 | void rf_ReconstructInPlaceThread(struct rf_recon_req *); |
330 | int rf_autoconfig(device_t); | | 330 | int rf_autoconfig(device_t); |
331 | void rf_buildroothack(RF_ConfigSet_t *); | | 331 | void rf_buildroothack(RF_ConfigSet_t *); |
332 | | | 332 | |
333 | RF_AutoConfig_t *rf_find_raid_components(void); | | 333 | RF_AutoConfig_t *rf_find_raid_components(void); |
334 | RF_ConfigSet_t *rf_create_auto_sets(RF_AutoConfig_t *); | | 334 | RF_ConfigSet_t *rf_create_auto_sets(RF_AutoConfig_t *); |
335 | static int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *); | | 335 | static int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *); |
336 | static int rf_reasonable_label(RF_ComponentLabel_t *); | | 336 | static int rf_reasonable_label(RF_ComponentLabel_t *); |
337 | void rf_create_configuration(RF_AutoConfig_t *,RF_Config_t *, RF_Raid_t *); | | 337 | void rf_create_configuration(RF_AutoConfig_t *,RF_Config_t *, RF_Raid_t *); |
338 | int rf_set_autoconfig(RF_Raid_t *, int); | | 338 | int rf_set_autoconfig(RF_Raid_t *, int); |
339 | int rf_set_rootpartition(RF_Raid_t *, int); | | 339 | int rf_set_rootpartition(RF_Raid_t *, int); |
340 | void rf_release_all_vps(RF_ConfigSet_t *); | | 340 | void rf_release_all_vps(RF_ConfigSet_t *); |
341 | void rf_cleanup_config_set(RF_ConfigSet_t *); | | 341 | void rf_cleanup_config_set(RF_ConfigSet_t *); |
342 | int rf_have_enough_components(RF_ConfigSet_t *); | | 342 | int rf_have_enough_components(RF_ConfigSet_t *); |
343 | int rf_auto_config_set(RF_ConfigSet_t *, int *); | | 343 | int rf_auto_config_set(RF_ConfigSet_t *, int *); |
344 | | | 344 | |
345 | static int raidautoconfig = 0; /* Debugging, mostly. Set to 0 to not | | 345 | static int raidautoconfig = 0; /* Debugging, mostly. Set to 0 to not |
346 | allow autoconfig to take place. | | 346 | allow autoconfig to take place. |
347 | Note that this is overridden by having | | 347 | Note that this is overridden by having |
348 | RAID_AUTOCONFIG as an option in the | | 348 | RAID_AUTOCONFIG as an option in the |
349 | kernel config file. */ | | 349 | kernel config file. */ |
350 | | | 350 | |
351 | struct RF_Pools_s rf_pools; | | 351 | struct RF_Pools_s rf_pools; |
352 | | | 352 | |
353 | void | | 353 | void |
354 | raidattach(int num) | | 354 | raidattach(int num) |
355 | { | | 355 | { |
356 | int raidID; | | 356 | int raidID; |
357 | int i, rc; | | 357 | int i, rc; |
358 | | | 358 | |
359 | aprint_debug("raidattach: Asked for %d units\n", num); | | 359 | aprint_debug("raidattach: Asked for %d units\n", num); |
360 | | | 360 | |
361 | if (num <= 0) { | | 361 | if (num <= 0) { |
362 | #ifdef DIAGNOSTIC | | 362 | #ifdef DIAGNOSTIC |
363 | panic("raidattach: count <= 0"); | | 363 | panic("raidattach: count <= 0"); |
364 | #endif | | 364 | #endif |
365 | return; | | 365 | return; |
366 | } | | 366 | } |
367 | /* This is where all the initialization stuff gets done. */ | | 367 | /* This is where all the initialization stuff gets done. */ |
368 | | | 368 | |
369 | numraid = num; | | 369 | numraid = num; |
370 | | | 370 | |
371 | /* Make some space for requested number of units... */ | | 371 | /* Make some space for requested number of units... */ |
372 | | | 372 | |
373 | RF_Malloc(raidPtrs, num * sizeof(RF_Raid_t *), (RF_Raid_t **)); | | 373 | RF_Malloc(raidPtrs, num * sizeof(RF_Raid_t *), (RF_Raid_t **)); |
374 | if (raidPtrs == NULL) { | | 374 | if (raidPtrs == NULL) { |
375 | panic("raidPtrs is NULL!!"); | | 375 | panic("raidPtrs is NULL!!"); |
376 | } | | 376 | } |
377 | | | 377 | |
378 | #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) | | 378 | #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) |
379 | rf_mutex_init(&rf_sparet_wait_mutex); | | 379 | rf_mutex_init(&rf_sparet_wait_mutex); |
380 | | | 380 | |
381 | rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; | | 381 | rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; |
382 | #endif | | 382 | #endif |
383 | | | 383 | |
384 | for (i = 0; i < num; i++) | | 384 | for (i = 0; i < num; i++) |
385 | raidPtrs[i] = NULL; | | 385 | raidPtrs[i] = NULL; |
386 | rc = rf_BootRaidframe(); | | 386 | rc = rf_BootRaidframe(); |
387 | if (rc == 0) | | 387 | if (rc == 0) |
388 | aprint_normal("Kernelized RAIDframe activated\n"); | | 388 | aprint_verbose("Kernelized RAIDframe activated\n"); |
389 | else | | 389 | else |
390 | panic("Serious error booting RAID!!"); | | 390 | panic("Serious error booting RAID!!"); |
391 | | | 391 | |
392 | /* put together some datastructures like the CCD device does.. This | | 392 | /* put together some datastructures like the CCD device does.. This |
393 | * lets us lock the device and what-not when it gets opened. */ | | 393 | * lets us lock the device and what-not when it gets opened. */ |
394 | | | 394 | |
395 | raid_softc = (struct raid_softc *) | | 395 | raid_softc = (struct raid_softc *) |
396 | malloc(num * sizeof(struct raid_softc), | | 396 | malloc(num * sizeof(struct raid_softc), |
397 | M_RAIDFRAME, M_NOWAIT); | | 397 | M_RAIDFRAME, M_NOWAIT); |
398 | if (raid_softc == NULL) { | | 398 | if (raid_softc == NULL) { |
399 | aprint_error("WARNING: no memory for RAIDframe driver\n"); | | 399 | aprint_error("WARNING: no memory for RAIDframe driver\n"); |
400 | return; | | 400 | return; |
401 | } | | 401 | } |
402 | | | 402 | |
403 | memset(raid_softc, 0, num * sizeof(struct raid_softc)); | | 403 | memset(raid_softc, 0, num * sizeof(struct raid_softc)); |
404 | | | 404 | |
405 | for (raidID = 0; raidID < num; raidID++) { | | 405 | for (raidID = 0; raidID < num; raidID++) { |
406 | bufq_alloc(&raid_softc[raidID].buf_queue, "fcfs", 0); | | 406 | bufq_alloc(&raid_softc[raidID].buf_queue, "fcfs", 0); |
407 | | | 407 | |
408 | RF_Malloc(raidPtrs[raidID], sizeof(RF_Raid_t), | | 408 | RF_Malloc(raidPtrs[raidID], sizeof(RF_Raid_t), |
409 | (RF_Raid_t *)); | | 409 | (RF_Raid_t *)); |
410 | if (raidPtrs[raidID] == NULL) { | | 410 | if (raidPtrs[raidID] == NULL) { |
411 | aprint_error("WARNING: raidPtrs[%d] is NULL\n", raidID); | | 411 | aprint_error("WARNING: raidPtrs[%d] is NULL\n", raidID); |
412 | numraid = raidID; | | 412 | numraid = raidID; |
413 | return; | | 413 | return; |
414 | } | | 414 | } |
415 | } | | 415 | } |
416 | | | 416 | |
417 | if (config_cfattach_attach(raid_cd.cd_name, &raid_ca)) { | | 417 | if (config_cfattach_attach(raid_cd.cd_name, &raid_ca)) { |
418 | aprint_error("raidattach: config_cfattach_attach failed?\n"); | | 418 | aprint_error("raidattach: config_cfattach_attach failed?\n"); |
419 | } | | 419 | } |
420 | | | 420 | |
421 | #ifdef RAID_AUTOCONFIG | | 421 | #ifdef RAID_AUTOCONFIG |
422 | raidautoconfig = 1; | | 422 | raidautoconfig = 1; |
423 | #endif | | 423 | #endif |
424 | | | 424 | |
425 | /* | | 425 | /* |
426 | * Register a finalizer which will be used to auto-config RAID | | 426 | * Register a finalizer which will be used to auto-config RAID |
427 | * sets once all real hardware devices have been found. | | 427 | * sets once all real hardware devices have been found. |
428 | */ | | 428 | */ |
429 | if (config_finalize_register(NULL, rf_autoconfig) != 0) | | 429 | if (config_finalize_register(NULL, rf_autoconfig) != 0) |
430 | aprint_error("WARNING: unable to register RAIDframe finalizer\n"); | | 430 | aprint_error("WARNING: unable to register RAIDframe finalizer\n"); |
431 | } | | 431 | } |
432 | | | 432 | |
433 | int | | 433 | int |
434 | rf_autoconfig(device_t self) | | 434 | rf_autoconfig(device_t self) |
435 | { | | 435 | { |
436 | RF_AutoConfig_t *ac_list; | | 436 | RF_AutoConfig_t *ac_list; |
437 | RF_ConfigSet_t *config_sets; | | 437 | RF_ConfigSet_t *config_sets; |
438 | | | 438 | |
439 | if (raidautoconfig == 0) | | 439 | if (raidautoconfig == 0) |
440 | return (0); | | 440 | return (0); |
441 | | | 441 | |
442 | /* XXX This code can only be run once. */ | | 442 | /* XXX This code can only be run once. */ |
443 | raidautoconfig = 0; | | 443 | raidautoconfig = 0; |
444 | | | 444 | |
445 | /* 1. locate all RAID components on the system */ | | 445 | /* 1. locate all RAID components on the system */ |
446 | aprint_debug("Searching for RAID components...\n"); | | 446 | aprint_debug("Searching for RAID components...\n"); |
447 | ac_list = rf_find_raid_components(); | | 447 | ac_list = rf_find_raid_components(); |
448 | | | 448 | |
449 | /* 2. Sort them into their respective sets. */ | | 449 | /* 2. Sort them into their respective sets. */ |
450 | config_sets = rf_create_auto_sets(ac_list); | | 450 | config_sets = rf_create_auto_sets(ac_list); |
451 | | | 451 | |
452 | /* | | 452 | /* |
453 | * 3. Evaluate each set andconfigure the valid ones. | | 453 | * 3. Evaluate each set andconfigure the valid ones. |
454 | * This gets done in rf_buildroothack(). | | 454 | * This gets done in rf_buildroothack(). |
455 | */ | | 455 | */ |
456 | rf_buildroothack(config_sets); | | 456 | rf_buildroothack(config_sets); |
457 | | | 457 | |
458 | return 1; | | 458 | return 1; |
459 | } | | 459 | } |
460 | | | 460 | |
461 | void | | 461 | void |
462 | rf_buildroothack(RF_ConfigSet_t *config_sets) | | 462 | rf_buildroothack(RF_ConfigSet_t *config_sets) |
463 | { | | 463 | { |
464 | RF_ConfigSet_t *cset; | | 464 | RF_ConfigSet_t *cset; |
465 | RF_ConfigSet_t *next_cset; | | 465 | RF_ConfigSet_t *next_cset; |
466 | int retcode; | | 466 | int retcode; |
467 | int raidID; | | 467 | int raidID; |
468 | int rootID; | | 468 | int rootID; |
469 | int col; | | 469 | int col; |
470 | int num_root; | | 470 | int num_root; |
471 | char *devname; | | 471 | char *devname; |
472 | | | 472 | |
473 | rootID = 0; | | 473 | rootID = 0; |
474 | num_root = 0; | | 474 | num_root = 0; |
475 | cset = config_sets; | | 475 | cset = config_sets; |
476 | while (cset != NULL) { | | 476 | while (cset != NULL) { |
477 | next_cset = cset->next; | | 477 | next_cset = cset->next; |
478 | if (rf_have_enough_components(cset) && | | 478 | if (rf_have_enough_components(cset) && |
479 | cset->ac->clabel->autoconfigure==1) { | | 479 | cset->ac->clabel->autoconfigure==1) { |
480 | retcode = rf_auto_config_set(cset,&raidID); | | 480 | retcode = rf_auto_config_set(cset,&raidID); |
481 | if (!retcode) { | | 481 | if (!retcode) { |
482 | aprint_debug("raid%d: configured ok\n", raidID); | | 482 | aprint_debug("raid%d: configured ok\n", raidID); |
483 | if (cset->rootable) { | | 483 | if (cset->rootable) { |
484 | rootID = raidID; | | 484 | rootID = raidID; |
485 | num_root++; | | 485 | num_root++; |
486 | } | | 486 | } |
487 | } else { | | 487 | } else { |
488 | /* The autoconfig didn't work :( */ | | 488 | /* The autoconfig didn't work :( */ |
489 | aprint_debug("Autoconfig failed with code %d for raid%d\n", retcode, raidID); | | 489 | aprint_debug("Autoconfig failed with code %d for raid%d\n", retcode, raidID); |
490 | rf_release_all_vps(cset); | | 490 | rf_release_all_vps(cset); |
491 | } | | 491 | } |
492 | } else { | | 492 | } else { |
493 | /* we're not autoconfiguring this set... | | 493 | /* we're not autoconfiguring this set... |
494 | release the associated resources */ | | 494 | release the associated resources */ |
495 | rf_release_all_vps(cset); | | 495 | rf_release_all_vps(cset); |
496 | } | | 496 | } |
497 | /* cleanup */ | | 497 | /* cleanup */ |
498 | rf_cleanup_config_set(cset); | | 498 | rf_cleanup_config_set(cset); |
499 | cset = next_cset; | | 499 | cset = next_cset; |
500 | } | | 500 | } |
501 | | | 501 | |
502 | /* if the user has specified what the root device should be | | 502 | /* if the user has specified what the root device should be |
503 | then we don't touch booted_device or boothowto... */ | | 503 | then we don't touch booted_device or boothowto... */ |
504 | | | 504 | |
505 | if (rootspec != NULL) | | 505 | if (rootspec != NULL) |
506 | return; | | 506 | return; |
507 | | | 507 | |
508 | /* we found something bootable... */ | | 508 | /* we found something bootable... */ |
509 | | | 509 | |
510 | if (num_root == 1) { | | 510 | if (num_root == 1) { |
511 | booted_device = raid_softc[rootID].sc_dev; | | 511 | booted_device = raid_softc[rootID].sc_dev; |
512 | } else if (num_root > 1) { | | 512 | } else if (num_root > 1) { |
513 | | | 513 | |
514 | /* | | 514 | /* |
515 | * Maybe the MD code can help. If it cannot, then | | 515 | * Maybe the MD code can help. If it cannot, then |
516 | * setroot() will discover that we have no | | 516 | * setroot() will discover that we have no |
517 | * booted_device and will ask the user if nothing was | | 517 | * booted_device and will ask the user if nothing was |
518 | * hardwired in the kernel config file | | 518 | * hardwired in the kernel config file |
519 | */ | | 519 | */ |
520 | | | 520 | |
521 | if (booted_device == NULL) | | 521 | if (booted_device == NULL) |
522 | cpu_rootconf(); | | 522 | cpu_rootconf(); |
523 | if (booted_device == NULL) | | 523 | if (booted_device == NULL) |
524 | return; | | 524 | return; |
525 | | | 525 | |
526 | num_root = 0; | | 526 | num_root = 0; |
527 | for (raidID = 0; raidID < numraid; raidID++) { | | 527 | for (raidID = 0; raidID < numraid; raidID++) { |
528 | if (raidPtrs[raidID]->valid == 0) | | 528 | if (raidPtrs[raidID]->valid == 0) |
529 | continue; | | 529 | continue; |
530 | | | 530 | |
531 | if (raidPtrs[raidID]->root_partition == 0) | | 531 | if (raidPtrs[raidID]->root_partition == 0) |
532 | continue; | | 532 | continue; |
533 | | | 533 | |
534 | for (col = 0; col < raidPtrs[raidID]->numCol; col++) { | | 534 | for (col = 0; col < raidPtrs[raidID]->numCol; col++) { |
535 | devname = raidPtrs[raidID]->Disks[col].devname; | | 535 | devname = raidPtrs[raidID]->Disks[col].devname; |
536 | devname += sizeof("/dev/") - 1; | | 536 | devname += sizeof("/dev/") - 1; |
537 | if (strncmp(devname, device_xname(booted_device), | | 537 | if (strncmp(devname, device_xname(booted_device), |
538 | strlen(device_xname(booted_device))) != 0) | | 538 | strlen(device_xname(booted_device))) != 0) |
539 | continue; | | 539 | continue; |
540 | aprint_debug("raid%d includes boot device %s\n", | | 540 | aprint_debug("raid%d includes boot device %s\n", |
541 | raidID, devname); | | 541 | raidID, devname); |
542 | num_root++; | | 542 | num_root++; |
543 | rootID = raidID; | | 543 | rootID = raidID; |
544 | } | | 544 | } |
545 | } | | 545 | } |
546 | | | 546 | |
547 | if (num_root == 1) { | | 547 | if (num_root == 1) { |
548 | booted_device = raid_softc[rootID].sc_dev; | | 548 | booted_device = raid_softc[rootID].sc_dev; |
549 | } else { | | 549 | } else { |
550 | /* we can't guess.. require the user to answer... */ | | 550 | /* we can't guess.. require the user to answer... */ |
551 | boothowto |= RB_ASKNAME; | | 551 | boothowto |= RB_ASKNAME; |
552 | } | | 552 | } |
553 | } | | 553 | } |
554 | } | | 554 | } |
555 | | | 555 | |
556 | | | 556 | |
557 | int | | 557 | int |
558 | raidsize(dev_t dev) | | 558 | raidsize(dev_t dev) |
559 | { | | 559 | { |
560 | struct raid_softc *rs; | | 560 | struct raid_softc *rs; |
561 | struct disklabel *lp; | | 561 | struct disklabel *lp; |
562 | int part, unit, omask, size; | | 562 | int part, unit, omask, size; |
563 | | | 563 | |
564 | unit = raidunit(dev); | | 564 | unit = raidunit(dev); |
565 | if (unit >= numraid) | | 565 | if (unit >= numraid) |
566 | return (-1); | | 566 | return (-1); |
567 | rs = &raid_softc[unit]; | | 567 | rs = &raid_softc[unit]; |
568 | | | 568 | |
569 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 569 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
570 | return (-1); | | 570 | return (-1); |
571 | | | 571 | |
572 | part = DISKPART(dev); | | 572 | part = DISKPART(dev); |
573 | omask = rs->sc_dkdev.dk_openmask & (1 << part); | | 573 | omask = rs->sc_dkdev.dk_openmask & (1 << part); |
574 | lp = rs->sc_dkdev.dk_label; | | 574 | lp = rs->sc_dkdev.dk_label; |
575 | | | 575 | |
576 | if (omask == 0 && raidopen(dev, 0, S_IFBLK, curlwp)) | | 576 | if (omask == 0 && raidopen(dev, 0, S_IFBLK, curlwp)) |
577 | return (-1); | | 577 | return (-1); |
578 | | | 578 | |
579 | if (lp->d_partitions[part].p_fstype != FS_SWAP) | | 579 | if (lp->d_partitions[part].p_fstype != FS_SWAP) |
580 | size = -1; | | 580 | size = -1; |
581 | else | | 581 | else |
582 | size = lp->d_partitions[part].p_size * | | 582 | size = lp->d_partitions[part].p_size * |
583 | (lp->d_secsize / DEV_BSIZE); | | 583 | (lp->d_secsize / DEV_BSIZE); |
584 | | | 584 | |
585 | if (omask == 0 && raidclose(dev, 0, S_IFBLK, curlwp)) | | 585 | if (omask == 0 && raidclose(dev, 0, S_IFBLK, curlwp)) |
586 | return (-1); | | 586 | return (-1); |
587 | | | 587 | |
588 | return (size); | | 588 | return (size); |
589 | | | 589 | |
590 | } | | 590 | } |
591 | | | 591 | |
592 | int | | 592 | int |
593 | raiddump(dev_t dev, daddr_t blkno, void *va, size_t size) | | 593 | raiddump(dev_t dev, daddr_t blkno, void *va, size_t size) |
594 | { | | 594 | { |
595 | int unit = raidunit(dev); | | 595 | int unit = raidunit(dev); |
596 | struct raid_softc *rs; | | 596 | struct raid_softc *rs; |
597 | const struct bdevsw *bdev; | | 597 | const struct bdevsw *bdev; |
598 | struct disklabel *lp; | | 598 | struct disklabel *lp; |
599 | RF_Raid_t *raidPtr; | | 599 | RF_Raid_t *raidPtr; |
600 | daddr_t offset; | | 600 | daddr_t offset; |
601 | int part, c, sparecol, j, scol, dumpto; | | 601 | int part, c, sparecol, j, scol, dumpto; |
602 | int error = 0; | | 602 | int error = 0; |
603 | | | 603 | |
604 | if (unit >= numraid) | | 604 | if (unit >= numraid) |
605 | return (ENXIO); | | 605 | return (ENXIO); |
606 | | | 606 | |
607 | rs = &raid_softc[unit]; | | 607 | rs = &raid_softc[unit]; |
608 | raidPtr = raidPtrs[unit]; | | 608 | raidPtr = raidPtrs[unit]; |
609 | | | 609 | |
610 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 610 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
611 | return ENXIO; | | 611 | return ENXIO; |
612 | | | 612 | |
613 | /* we only support dumping to RAID 1 sets */ | | 613 | /* we only support dumping to RAID 1 sets */ |
614 | if (raidPtr->Layout.numDataCol != 1 || | | 614 | if (raidPtr->Layout.numDataCol != 1 || |
615 | raidPtr->Layout.numParityCol != 1) | | 615 | raidPtr->Layout.numParityCol != 1) |
616 | return EINVAL; | | 616 | return EINVAL; |
617 | | | 617 | |
618 | | | 618 | |
619 | if ((error = raidlock(rs)) != 0) | | 619 | if ((error = raidlock(rs)) != 0) |
620 | return error; | | 620 | return error; |
621 | | | 621 | |
622 | if (size % DEV_BSIZE != 0) { | | 622 | if (size % DEV_BSIZE != 0) { |
623 | error = EINVAL; | | 623 | error = EINVAL; |
624 | goto out; | | 624 | goto out; |
625 | } | | 625 | } |
626 | | | 626 | |
627 | if (blkno + size / DEV_BSIZE > rs->sc_size) { | | 627 | if (blkno + size / DEV_BSIZE > rs->sc_size) { |
628 | printf("%s: blkno (%" PRIu64 ") + size / DEV_BSIZE (%zu) > " | | 628 | printf("%s: blkno (%" PRIu64 ") + size / DEV_BSIZE (%zu) > " |
629 | "sc->sc_size (%" PRIu64 ")\n", __func__, blkno, | | 629 | "sc->sc_size (%" PRIu64 ")\n", __func__, blkno, |
630 | size / DEV_BSIZE, rs->sc_size); | | 630 | size / DEV_BSIZE, rs->sc_size); |
631 | error = EINVAL; | | 631 | error = EINVAL; |
632 | goto out; | | 632 | goto out; |
633 | } | | 633 | } |
634 | | | 634 | |
635 | part = DISKPART(dev); | | 635 | part = DISKPART(dev); |
636 | lp = rs->sc_dkdev.dk_label; | | 636 | lp = rs->sc_dkdev.dk_label; |
637 | offset = lp->d_partitions[part].p_offset + RF_PROTECTED_SECTORS; | | 637 | offset = lp->d_partitions[part].p_offset + RF_PROTECTED_SECTORS; |
638 | | | 638 | |
639 | /* figure out what device is alive.. */ | | 639 | /* figure out what device is alive.. */ |
640 | | | 640 | |
641 | /* | | 641 | /* |
642 | Look for a component to dump to. The preference for the | | 642 | Look for a component to dump to. The preference for the |
643 | component to dump to is as follows: | | 643 | component to dump to is as follows: |
644 | 1) the master | | 644 | 1) the master |
645 | 2) a used_spare of the master | | 645 | 2) a used_spare of the master |
646 | 3) the slave | | 646 | 3) the slave |
647 | 4) a used_spare of the slave | | 647 | 4) a used_spare of the slave |
648 | */ | | 648 | */ |
649 | | | 649 | |
650 | dumpto = -1; | | 650 | dumpto = -1; |
651 | for (c = 0; c < raidPtr->numCol; c++) { | | 651 | for (c = 0; c < raidPtr->numCol; c++) { |
652 | if (raidPtr->Disks[c].status == rf_ds_optimal) { | | 652 | if (raidPtr->Disks[c].status == rf_ds_optimal) { |
653 | /* this might be the one */ | | 653 | /* this might be the one */ |
654 | dumpto = c; | | 654 | dumpto = c; |
655 | break; | | 655 | break; |
656 | } | | 656 | } |
657 | } | | 657 | } |
658 | | | 658 | |
659 | /* | | 659 | /* |
660 | At this point we have possibly selected a live master or a | | 660 | At this point we have possibly selected a live master or a |
661 | live slave. We now check to see if there is a spared | | 661 | live slave. We now check to see if there is a spared |
662 | master (or a spared slave), if we didn't find a live master | | 662 | master (or a spared slave), if we didn't find a live master |
663 | or a live slave. | | 663 | or a live slave. |
664 | */ | | 664 | */ |
665 | | | 665 | |
666 | for (c = 0; c < raidPtr->numSpare; c++) { | | 666 | for (c = 0; c < raidPtr->numSpare; c++) { |
667 | sparecol = raidPtr->numCol + c; | | 667 | sparecol = raidPtr->numCol + c; |
668 | if (raidPtr->Disks[sparecol].status == rf_ds_used_spare) { | | 668 | if (raidPtr->Disks[sparecol].status == rf_ds_used_spare) { |
669 | /* How about this one? */ | | 669 | /* How about this one? */ |
670 | scol = -1; | | 670 | scol = -1; |
671 | for(j=0;j<raidPtr->numCol;j++) { | | 671 | for(j=0;j<raidPtr->numCol;j++) { |
672 | if (raidPtr->Disks[j].spareCol == sparecol) { | | 672 | if (raidPtr->Disks[j].spareCol == sparecol) { |
673 | scol = j; | | 673 | scol = j; |
674 | break; | | 674 | break; |
675 | } | | 675 | } |
676 | } | | 676 | } |
677 | if (scol == 0) { | | 677 | if (scol == 0) { |
678 | /* | | 678 | /* |
679 | We must have found a spared master! | | 679 | We must have found a spared master! |
680 | We'll take that over anything else | | 680 | We'll take that over anything else |
681 | found so far. (We couldn't have | | 681 | found so far. (We couldn't have |
682 | found a real master before, since | | 682 | found a real master before, since |
683 | this is a used spare, and it's | | 683 | this is a used spare, and it's |
684 | saying that it's replacing the | | 684 | saying that it's replacing the |
685 | master.) On reboot (with | | 685 | master.) On reboot (with |
686 | autoconfiguration turned on) | | 686 | autoconfiguration turned on) |
687 | sparecol will become the 1st | | 687 | sparecol will become the 1st |
688 | component (component0) of this set. | | 688 | component (component0) of this set. |
689 | */ | | 689 | */ |
690 | dumpto = sparecol; | | 690 | dumpto = sparecol; |
691 | break; | | 691 | break; |
692 | } else if (scol != -1) { | | 692 | } else if (scol != -1) { |
693 | /* | | 693 | /* |
694 | Must be a spared slave. We'll dump | | 694 | Must be a spared slave. We'll dump |
695 | to that if we havn't found anything | | 695 | to that if we havn't found anything |
696 | else so far. | | 696 | else so far. |
697 | */ | | 697 | */ |
698 | if (dumpto == -1) | | 698 | if (dumpto == -1) |
699 | dumpto = sparecol; | | 699 | dumpto = sparecol; |
700 | } | | 700 | } |
701 | } | | 701 | } |
702 | } | | 702 | } |
703 | | | 703 | |
704 | if (dumpto == -1) { | | 704 | if (dumpto == -1) { |
705 | /* we couldn't find any live components to dump to!?!? | | 705 | /* we couldn't find any live components to dump to!?!? |
706 | */ | | 706 | */ |
707 | error = EINVAL; | | 707 | error = EINVAL; |
708 | goto out; | | 708 | goto out; |
709 | } | | 709 | } |
710 | | | 710 | |
711 | bdev = bdevsw_lookup(raidPtr->Disks[dumpto].dev); | | 711 | bdev = bdevsw_lookup(raidPtr->Disks[dumpto].dev); |
712 | | | 712 | |
713 | /* | | 713 | /* |
714 | Note that blkno is relative to this particular partition. | | 714 | Note that blkno is relative to this particular partition. |
715 | By adding the offset of this partition in the RAID | | 715 | By adding the offset of this partition in the RAID |
716 | set, and also adding RF_PROTECTED_SECTORS, we get a | | 716 | set, and also adding RF_PROTECTED_SECTORS, we get a |
717 | value that is relative to the partition used for the | | 717 | value that is relative to the partition used for the |
718 | underlying component. | | 718 | underlying component. |
719 | */ | | 719 | */ |
720 | | | 720 | |
721 | error = (*bdev->d_dump)(raidPtr->Disks[dumpto].dev, | | 721 | error = (*bdev->d_dump)(raidPtr->Disks[dumpto].dev, |
722 | blkno + offset, va, size); | | 722 | blkno + offset, va, size); |
723 | | | 723 | |
724 | out: | | 724 | out: |
725 | raidunlock(rs); | | 725 | raidunlock(rs); |
726 | | | 726 | |
727 | return error; | | 727 | return error; |
728 | } | | 728 | } |
729 | /* ARGSUSED */ | | 729 | /* ARGSUSED */ |
730 | int | | 730 | int |
731 | raidopen(dev_t dev, int flags, int fmt, | | 731 | raidopen(dev_t dev, int flags, int fmt, |
732 | struct lwp *l) | | 732 | struct lwp *l) |
733 | { | | 733 | { |
734 | int unit = raidunit(dev); | | 734 | int unit = raidunit(dev); |
735 | struct raid_softc *rs; | | 735 | struct raid_softc *rs; |
736 | struct disklabel *lp; | | 736 | struct disklabel *lp; |
737 | int part, pmask; | | 737 | int part, pmask; |
738 | int error = 0; | | 738 | int error = 0; |
739 | | | 739 | |
740 | if (unit >= numraid) | | 740 | if (unit >= numraid) |
741 | return (ENXIO); | | 741 | return (ENXIO); |
742 | rs = &raid_softc[unit]; | | 742 | rs = &raid_softc[unit]; |
743 | | | 743 | |
744 | if ((error = raidlock(rs)) != 0) | | 744 | if ((error = raidlock(rs)) != 0) |
745 | return (error); | | 745 | return (error); |
746 | | | 746 | |
747 | if ((rs->sc_flags & RAIDF_SHUTDOWN) != 0) { | | 747 | if ((rs->sc_flags & RAIDF_SHUTDOWN) != 0) { |
748 | error = EBUSY; | | 748 | error = EBUSY; |
749 | goto bad; | | 749 | goto bad; |
750 | } | | 750 | } |
751 | | | 751 | |
752 | lp = rs->sc_dkdev.dk_label; | | 752 | lp = rs->sc_dkdev.dk_label; |
753 | | | 753 | |
754 | part = DISKPART(dev); | | 754 | part = DISKPART(dev); |
755 | | | 755 | |
756 | /* | | 756 | /* |
757 | * If there are wedges, and this is not RAW_PART, then we | | 757 | * If there are wedges, and this is not RAW_PART, then we |
758 | * need to fail. | | 758 | * need to fail. |
759 | */ | | 759 | */ |
760 | if (rs->sc_dkdev.dk_nwedges != 0 && part != RAW_PART) { | | 760 | if (rs->sc_dkdev.dk_nwedges != 0 && part != RAW_PART) { |
761 | error = EBUSY; | | 761 | error = EBUSY; |
762 | goto bad; | | 762 | goto bad; |
763 | } | | 763 | } |
764 | pmask = (1 << part); | | 764 | pmask = (1 << part); |
765 | | | 765 | |
766 | if ((rs->sc_flags & RAIDF_INITED) && | | 766 | if ((rs->sc_flags & RAIDF_INITED) && |
767 | (rs->sc_dkdev.dk_openmask == 0)) | | 767 | (rs->sc_dkdev.dk_openmask == 0)) |
768 | raidgetdisklabel(dev); | | 768 | raidgetdisklabel(dev); |
769 | | | 769 | |
770 | /* make sure that this partition exists */ | | 770 | /* make sure that this partition exists */ |
771 | | | 771 | |
772 | if (part != RAW_PART) { | | 772 | if (part != RAW_PART) { |
773 | if (((rs->sc_flags & RAIDF_INITED) == 0) || | | 773 | if (((rs->sc_flags & RAIDF_INITED) == 0) || |
774 | ((part >= lp->d_npartitions) || | | 774 | ((part >= lp->d_npartitions) || |
775 | (lp->d_partitions[part].p_fstype == FS_UNUSED))) { | | 775 | (lp->d_partitions[part].p_fstype == FS_UNUSED))) { |
776 | error = ENXIO; | | 776 | error = ENXIO; |
777 | goto bad; | | 777 | goto bad; |
778 | } | | 778 | } |
779 | } | | 779 | } |
780 | /* Prevent this unit from being unconfigured while open. */ | | 780 | /* Prevent this unit from being unconfigured while open. */ |
781 | switch (fmt) { | | 781 | switch (fmt) { |
782 | case S_IFCHR: | | 782 | case S_IFCHR: |
783 | rs->sc_dkdev.dk_copenmask |= pmask; | | 783 | rs->sc_dkdev.dk_copenmask |= pmask; |
784 | break; | | 784 | break; |
785 | | | 785 | |
786 | case S_IFBLK: | | 786 | case S_IFBLK: |
787 | rs->sc_dkdev.dk_bopenmask |= pmask; | | 787 | rs->sc_dkdev.dk_bopenmask |= pmask; |
788 | break; | | 788 | break; |
789 | } | | 789 | } |
790 | | | 790 | |
791 | if ((rs->sc_dkdev.dk_openmask == 0) && | | 791 | if ((rs->sc_dkdev.dk_openmask == 0) && |
792 | ((rs->sc_flags & RAIDF_INITED) != 0)) { | | 792 | ((rs->sc_flags & RAIDF_INITED) != 0)) { |
793 | /* First one... mark things as dirty... Note that we *MUST* | | 793 | /* First one... mark things as dirty... Note that we *MUST* |
794 | have done a configure before this. I DO NOT WANT TO BE | | 794 | have done a configure before this. I DO NOT WANT TO BE |
795 | SCRIBBLING TO RANDOM COMPONENTS UNTIL IT'S BEEN DETERMINED | | 795 | SCRIBBLING TO RANDOM COMPONENTS UNTIL IT'S BEEN DETERMINED |
796 | THAT THEY BELONG TOGETHER!!!!! */ | | 796 | THAT THEY BELONG TOGETHER!!!!! */ |
797 | /* XXX should check to see if we're only open for reading | | 797 | /* XXX should check to see if we're only open for reading |
798 | here... If so, we needn't do this, but then need some | | 798 | here... If so, we needn't do this, but then need some |
799 | other way of keeping track of what's happened.. */ | | 799 | other way of keeping track of what's happened.. */ |
800 | | | 800 | |
801 | rf_markalldirty(raidPtrs[unit]); | | 801 | rf_markalldirty(raidPtrs[unit]); |
802 | } | | 802 | } |
803 | | | 803 | |
804 | | | 804 | |
805 | rs->sc_dkdev.dk_openmask = | | 805 | rs->sc_dkdev.dk_openmask = |
806 | rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; | | 806 | rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; |
807 | | | 807 | |
808 | bad: | | 808 | bad: |
809 | raidunlock(rs); | | 809 | raidunlock(rs); |
810 | | | 810 | |
811 | return (error); | | 811 | return (error); |
812 | | | 812 | |
813 | | | 813 | |
814 | } | | 814 | } |
815 | /* ARGSUSED */ | | 815 | /* ARGSUSED */ |
816 | int | | 816 | int |
817 | raidclose(dev_t dev, int flags, int fmt, struct lwp *l) | | 817 | raidclose(dev_t dev, int flags, int fmt, struct lwp *l) |
818 | { | | 818 | { |
819 | int unit = raidunit(dev); | | 819 | int unit = raidunit(dev); |
820 | struct raid_softc *rs; | | 820 | struct raid_softc *rs; |
821 | int error = 0; | | 821 | int error = 0; |
822 | int part; | | 822 | int part; |
823 | | | 823 | |
824 | if (unit >= numraid) | | 824 | if (unit >= numraid) |
825 | return (ENXIO); | | 825 | return (ENXIO); |
826 | rs = &raid_softc[unit]; | | 826 | rs = &raid_softc[unit]; |
827 | | | 827 | |
828 | if ((error = raidlock(rs)) != 0) | | 828 | if ((error = raidlock(rs)) != 0) |
829 | return (error); | | 829 | return (error); |
830 | | | 830 | |
831 | part = DISKPART(dev); | | 831 | part = DISKPART(dev); |
832 | | | 832 | |
833 | /* ...that much closer to allowing unconfiguration... */ | | 833 | /* ...that much closer to allowing unconfiguration... */ |
834 | switch (fmt) { | | 834 | switch (fmt) { |
835 | case S_IFCHR: | | 835 | case S_IFCHR: |
836 | rs->sc_dkdev.dk_copenmask &= ~(1 << part); | | 836 | rs->sc_dkdev.dk_copenmask &= ~(1 << part); |
837 | break; | | 837 | break; |
838 | | | 838 | |
839 | case S_IFBLK: | | 839 | case S_IFBLK: |
840 | rs->sc_dkdev.dk_bopenmask &= ~(1 << part); | | 840 | rs->sc_dkdev.dk_bopenmask &= ~(1 << part); |
841 | break; | | 841 | break; |
842 | } | | 842 | } |
843 | rs->sc_dkdev.dk_openmask = | | 843 | rs->sc_dkdev.dk_openmask = |
844 | rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; | | 844 | rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; |
845 | | | 845 | |
846 | if ((rs->sc_dkdev.dk_openmask == 0) && | | 846 | if ((rs->sc_dkdev.dk_openmask == 0) && |
847 | ((rs->sc_flags & RAIDF_INITED) != 0)) { | | 847 | ((rs->sc_flags & RAIDF_INITED) != 0)) { |
848 | /* Last one... device is not unconfigured yet. | | 848 | /* Last one... device is not unconfigured yet. |
849 | Device shutdown has taken care of setting the | | 849 | Device shutdown has taken care of setting the |
850 | clean bits if RAIDF_INITED is not set | | 850 | clean bits if RAIDF_INITED is not set |
851 | mark things as clean... */ | | 851 | mark things as clean... */ |
852 | | | 852 | |
853 | rf_update_component_labels(raidPtrs[unit], | | 853 | rf_update_component_labels(raidPtrs[unit], |
854 | RF_FINAL_COMPONENT_UPDATE); | | 854 | RF_FINAL_COMPONENT_UPDATE); |
855 | | | 855 | |
856 | /* If the kernel is shutting down, it will detach | | 856 | /* If the kernel is shutting down, it will detach |
857 | * this RAID set soon enough. | | 857 | * this RAID set soon enough. |
858 | */ | | 858 | */ |
859 | } | | 859 | } |
860 | | | 860 | |
861 | raidunlock(rs); | | 861 | raidunlock(rs); |
862 | return (0); | | 862 | return (0); |
863 | | | 863 | |
864 | } | | 864 | } |
865 | | | 865 | |
866 | void | | 866 | void |
867 | raidstrategy(struct buf *bp) | | 867 | raidstrategy(struct buf *bp) |
868 | { | | 868 | { |
869 | int s; | | 869 | int s; |
870 | | | 870 | |
871 | unsigned int raidID = raidunit(bp->b_dev); | | 871 | unsigned int raidID = raidunit(bp->b_dev); |
872 | RF_Raid_t *raidPtr; | | 872 | RF_Raid_t *raidPtr; |
873 | struct raid_softc *rs = &raid_softc[raidID]; | | 873 | struct raid_softc *rs = &raid_softc[raidID]; |
874 | int wlabel; | | 874 | int wlabel; |
875 | | | 875 | |
876 | if ((rs->sc_flags & RAIDF_INITED) ==0) { | | 876 | if ((rs->sc_flags & RAIDF_INITED) ==0) { |
877 | bp->b_error = ENXIO; | | 877 | bp->b_error = ENXIO; |
878 | goto done; | | 878 | goto done; |
879 | } | | 879 | } |
880 | if (raidID >= numraid || !raidPtrs[raidID]) { | | 880 | if (raidID >= numraid || !raidPtrs[raidID]) { |
881 | bp->b_error = ENODEV; | | 881 | bp->b_error = ENODEV; |
882 | goto done; | | 882 | goto done; |
883 | } | | 883 | } |
884 | raidPtr = raidPtrs[raidID]; | | 884 | raidPtr = raidPtrs[raidID]; |
885 | if (!raidPtr->valid) { | | 885 | if (!raidPtr->valid) { |
886 | bp->b_error = ENODEV; | | 886 | bp->b_error = ENODEV; |
887 | goto done; | | 887 | goto done; |
888 | } | | 888 | } |
889 | if (bp->b_bcount == 0) { | | 889 | if (bp->b_bcount == 0) { |
890 | db1_printf(("b_bcount is zero..\n")); | | 890 | db1_printf(("b_bcount is zero..\n")); |
891 | goto done; | | 891 | goto done; |
892 | } | | 892 | } |
893 | | | 893 | |
894 | /* | | 894 | /* |
895 | * Do bounds checking and adjust transfer. If there's an | | 895 | * Do bounds checking and adjust transfer. If there's an |
896 | * error, the bounds check will flag that for us. | | 896 | * error, the bounds check will flag that for us. |
897 | */ | | 897 | */ |
898 | | | 898 | |
899 | wlabel = rs->sc_flags & (RAIDF_WLABEL | RAIDF_LABELLING); | | 899 | wlabel = rs->sc_flags & (RAIDF_WLABEL | RAIDF_LABELLING); |
900 | if (DISKPART(bp->b_dev) == RAW_PART) { | | 900 | if (DISKPART(bp->b_dev) == RAW_PART) { |
901 | uint64_t size; /* device size in DEV_BSIZE unit */ | | 901 | uint64_t size; /* device size in DEV_BSIZE unit */ |
902 | | | 902 | |
903 | if (raidPtr->logBytesPerSector > DEV_BSHIFT) { | | 903 | if (raidPtr->logBytesPerSector > DEV_BSHIFT) { |
904 | size = raidPtr->totalSectors << | | 904 | size = raidPtr->totalSectors << |
905 | (raidPtr->logBytesPerSector - DEV_BSHIFT); | | 905 | (raidPtr->logBytesPerSector - DEV_BSHIFT); |
906 | } else { | | 906 | } else { |
907 | size = raidPtr->totalSectors >> | | 907 | size = raidPtr->totalSectors >> |
908 | (DEV_BSHIFT - raidPtr->logBytesPerSector); | | 908 | (DEV_BSHIFT - raidPtr->logBytesPerSector); |
909 | } | | 909 | } |
910 | if (bounds_check_with_mediasize(bp, DEV_BSIZE, size) <= 0) { | | 910 | if (bounds_check_with_mediasize(bp, DEV_BSIZE, size) <= 0) { |
911 | goto done; | | 911 | goto done; |
912 | } | | 912 | } |
913 | } else { | | 913 | } else { |
914 | if (bounds_check_with_label(&rs->sc_dkdev, bp, wlabel) <= 0) { | | 914 | if (bounds_check_with_label(&rs->sc_dkdev, bp, wlabel) <= 0) { |
915 | db1_printf(("Bounds check failed!!:%d %d\n", | | 915 | db1_printf(("Bounds check failed!!:%d %d\n", |
916 | (int) bp->b_blkno, (int) wlabel)); | | 916 | (int) bp->b_blkno, (int) wlabel)); |
917 | goto done; | | 917 | goto done; |
918 | } | | 918 | } |
919 | } | | 919 | } |
920 | s = splbio(); | | 920 | s = splbio(); |
921 | | | 921 | |
922 | bp->b_resid = 0; | | 922 | bp->b_resid = 0; |
923 | | | 923 | |
924 | /* stuff it onto our queue */ | | 924 | /* stuff it onto our queue */ |
925 | bufq_put(rs->buf_queue, bp); | | 925 | bufq_put(rs->buf_queue, bp); |
926 | | | 926 | |
927 | /* scheduled the IO to happen at the next convenient time */ | | 927 | /* scheduled the IO to happen at the next convenient time */ |
928 | wakeup(&(raidPtrs[raidID]->iodone)); | | 928 | wakeup(&(raidPtrs[raidID]->iodone)); |
929 | | | 929 | |
930 | splx(s); | | 930 | splx(s); |
931 | return; | | 931 | return; |
932 | | | 932 | |
933 | done: | | 933 | done: |
934 | bp->b_resid = bp->b_bcount; | | 934 | bp->b_resid = bp->b_bcount; |
935 | biodone(bp); | | 935 | biodone(bp); |
936 | } | | 936 | } |
937 | /* ARGSUSED */ | | 937 | /* ARGSUSED */ |
938 | int | | 938 | int |
939 | raidread(dev_t dev, struct uio *uio, int flags) | | 939 | raidread(dev_t dev, struct uio *uio, int flags) |
940 | { | | 940 | { |
941 | int unit = raidunit(dev); | | 941 | int unit = raidunit(dev); |
942 | struct raid_softc *rs; | | 942 | struct raid_softc *rs; |
943 | | | 943 | |
944 | if (unit >= numraid) | | 944 | if (unit >= numraid) |
945 | return (ENXIO); | | 945 | return (ENXIO); |
946 | rs = &raid_softc[unit]; | | 946 | rs = &raid_softc[unit]; |
947 | | | 947 | |
948 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 948 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
949 | return (ENXIO); | | 949 | return (ENXIO); |
950 | | | 950 | |
951 | return (physio(raidstrategy, NULL, dev, B_READ, minphys, uio)); | | 951 | return (physio(raidstrategy, NULL, dev, B_READ, minphys, uio)); |
952 | | | 952 | |
953 | } | | 953 | } |
954 | /* ARGSUSED */ | | 954 | /* ARGSUSED */ |
955 | int | | 955 | int |
956 | raidwrite(dev_t dev, struct uio *uio, int flags) | | 956 | raidwrite(dev_t dev, struct uio *uio, int flags) |
957 | { | | 957 | { |
958 | int unit = raidunit(dev); | | 958 | int unit = raidunit(dev); |
959 | struct raid_softc *rs; | | 959 | struct raid_softc *rs; |
960 | | | 960 | |
961 | if (unit >= numraid) | | 961 | if (unit >= numraid) |
962 | return (ENXIO); | | 962 | return (ENXIO); |
963 | rs = &raid_softc[unit]; | | 963 | rs = &raid_softc[unit]; |
964 | | | 964 | |
965 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 965 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
966 | return (ENXIO); | | 966 | return (ENXIO); |
967 | | | 967 | |
968 | return (physio(raidstrategy, NULL, dev, B_WRITE, minphys, uio)); | | 968 | return (physio(raidstrategy, NULL, dev, B_WRITE, minphys, uio)); |
969 | | | 969 | |
970 | } | | 970 | } |
971 | | | 971 | |
972 | static int | | 972 | static int |
973 | raid_detach_unlocked(struct raid_softc *rs) | | 973 | raid_detach_unlocked(struct raid_softc *rs) |
974 | { | | 974 | { |
975 | int error; | | 975 | int error; |
976 | RF_Raid_t *raidPtr; | | 976 | RF_Raid_t *raidPtr; |
977 | | | 977 | |
978 | raidPtr = raidPtrs[device_unit(rs->sc_dev)]; | | 978 | raidPtr = raidPtrs[device_unit(rs->sc_dev)]; |
979 | | | 979 | |
980 | /* | | 980 | /* |
981 | * If somebody has a partition mounted, we shouldn't | | 981 | * If somebody has a partition mounted, we shouldn't |
982 | * shutdown. | | 982 | * shutdown. |
983 | */ | | 983 | */ |
984 | if (rs->sc_dkdev.dk_openmask != 0) | | 984 | if (rs->sc_dkdev.dk_openmask != 0) |
985 | return EBUSY; | | 985 | return EBUSY; |
986 | | | 986 | |
987 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 987 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
988 | ; /* not initialized: nothing to do */ | | 988 | ; /* not initialized: nothing to do */ |
989 | else if ((error = rf_Shutdown(raidPtr)) != 0) | | 989 | else if ((error = rf_Shutdown(raidPtr)) != 0) |
990 | return error; | | 990 | return error; |
991 | else | | 991 | else |
992 | rs->sc_flags &= ~(RAIDF_INITED|RAIDF_SHUTDOWN); | | 992 | rs->sc_flags &= ~(RAIDF_INITED|RAIDF_SHUTDOWN); |
993 | | | 993 | |
994 | /* Detach the disk. */ | | 994 | /* Detach the disk. */ |
995 | disk_detach(&rs->sc_dkdev); | | 995 | disk_detach(&rs->sc_dkdev); |
996 | disk_destroy(&rs->sc_dkdev); | | 996 | disk_destroy(&rs->sc_dkdev); |
997 | | | 997 | |
998 | return 0; | | 998 | return 0; |
999 | } | | 999 | } |
1000 | | | 1000 | |
1001 | int | | 1001 | int |
1002 | raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) | | 1002 | raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) |
1003 | { | | 1003 | { |
1004 | int unit = raidunit(dev); | | 1004 | int unit = raidunit(dev); |
1005 | int error = 0; | | 1005 | int error = 0; |
1006 | int part, pmask; | | 1006 | int part, pmask; |
1007 | cfdata_t cf; | | 1007 | cfdata_t cf; |
1008 | struct raid_softc *rs; | | 1008 | struct raid_softc *rs; |
1009 | RF_Config_t *k_cfg, *u_cfg; | | 1009 | RF_Config_t *k_cfg, *u_cfg; |
1010 | RF_Raid_t *raidPtr; | | 1010 | RF_Raid_t *raidPtr; |
1011 | RF_RaidDisk_t *diskPtr; | | 1011 | RF_RaidDisk_t *diskPtr; |
1012 | RF_AccTotals_t *totals; | | 1012 | RF_AccTotals_t *totals; |
1013 | RF_DeviceConfig_t *d_cfg, **ucfgp; | | 1013 | RF_DeviceConfig_t *d_cfg, **ucfgp; |
1014 | u_char *specific_buf; | | 1014 | u_char *specific_buf; |
1015 | int retcode = 0; | | 1015 | int retcode = 0; |
1016 | int column; | | 1016 | int column; |
1017 | /* int raidid; */ | | 1017 | /* int raidid; */ |
1018 | struct rf_recon_req *rrcopy, *rr; | | 1018 | struct rf_recon_req *rrcopy, *rr; |
1019 | RF_ComponentLabel_t *clabel; | | 1019 | RF_ComponentLabel_t *clabel; |
1020 | RF_ComponentLabel_t *ci_label; | | 1020 | RF_ComponentLabel_t *ci_label; |
1021 | RF_ComponentLabel_t **clabel_ptr; | | 1021 | RF_ComponentLabel_t **clabel_ptr; |
1022 | RF_SingleComponent_t *sparePtr,*componentPtr; | | 1022 | RF_SingleComponent_t *sparePtr,*componentPtr; |
1023 | RF_SingleComponent_t component; | | 1023 | RF_SingleComponent_t component; |
1024 | RF_ProgressInfo_t progressInfo, **progressInfoPtr; | | 1024 | RF_ProgressInfo_t progressInfo, **progressInfoPtr; |
1025 | int i, j, d; | | 1025 | int i, j, d; |
1026 | #ifdef __HAVE_OLD_DISKLABEL | | 1026 | #ifdef __HAVE_OLD_DISKLABEL |
1027 | struct disklabel newlabel; | | 1027 | struct disklabel newlabel; |
1028 | #endif | | 1028 | #endif |
1029 | struct dkwedge_info *dkw; | | 1029 | struct dkwedge_info *dkw; |
1030 | | | 1030 | |
1031 | if (unit >= numraid) | | 1031 | if (unit >= numraid) |
1032 | return (ENXIO); | | 1032 | return (ENXIO); |
1033 | rs = &raid_softc[unit]; | | 1033 | rs = &raid_softc[unit]; |
1034 | raidPtr = raidPtrs[unit]; | | 1034 | raidPtr = raidPtrs[unit]; |
1035 | | | 1035 | |
1036 | db1_printf(("raidioctl: %d %d %d %d\n", (int) dev, | | 1036 | db1_printf(("raidioctl: %d %d %d %d\n", (int) dev, |
1037 | (int) DISKPART(dev), (int) unit, (int) cmd)); | | 1037 | (int) DISKPART(dev), (int) unit, (int) cmd)); |
1038 | | | 1038 | |
1039 | /* Must be open for writes for these commands... */ | | 1039 | /* Must be open for writes for these commands... */ |
1040 | switch (cmd) { | | 1040 | switch (cmd) { |
1041 | #ifdef DIOCGSECTORSIZE | | 1041 | #ifdef DIOCGSECTORSIZE |
1042 | case DIOCGSECTORSIZE: | | 1042 | case DIOCGSECTORSIZE: |
1043 | *(u_int *)data = raidPtr->bytesPerSector; | | 1043 | *(u_int *)data = raidPtr->bytesPerSector; |
1044 | return 0; | | 1044 | return 0; |
1045 | case DIOCGMEDIASIZE: | | 1045 | case DIOCGMEDIASIZE: |
1046 | *(off_t *)data = | | 1046 | *(off_t *)data = |
1047 | (off_t)raidPtr->totalSectors * raidPtr->bytesPerSector; | | 1047 | (off_t)raidPtr->totalSectors * raidPtr->bytesPerSector; |
1048 | return 0; | | 1048 | return 0; |
1049 | #endif | | 1049 | #endif |
1050 | case DIOCSDINFO: | | 1050 | case DIOCSDINFO: |
1051 | case DIOCWDINFO: | | 1051 | case DIOCWDINFO: |
1052 | #ifdef __HAVE_OLD_DISKLABEL | | 1052 | #ifdef __HAVE_OLD_DISKLABEL |
1053 | case ODIOCWDINFO: | | 1053 | case ODIOCWDINFO: |
1054 | case ODIOCSDINFO: | | 1054 | case ODIOCSDINFO: |
1055 | #endif | | 1055 | #endif |
1056 | case DIOCWLABEL: | | 1056 | case DIOCWLABEL: |
1057 | case DIOCAWEDGE: | | 1057 | case DIOCAWEDGE: |
1058 | case DIOCDWEDGE: | | 1058 | case DIOCDWEDGE: |
1059 | if ((flag & FWRITE) == 0) | | 1059 | if ((flag & FWRITE) == 0) |
1060 | return (EBADF); | | 1060 | return (EBADF); |
1061 | } | | 1061 | } |
1062 | | | 1062 | |
1063 | /* Must be initialized for these... */ | | 1063 | /* Must be initialized for these... */ |
1064 | switch (cmd) { | | 1064 | switch (cmd) { |
1065 | case DIOCGDINFO: | | 1065 | case DIOCGDINFO: |
1066 | case DIOCSDINFO: | | 1066 | case DIOCSDINFO: |
1067 | case DIOCWDINFO: | | 1067 | case DIOCWDINFO: |
1068 | #ifdef __HAVE_OLD_DISKLABEL | | 1068 | #ifdef __HAVE_OLD_DISKLABEL |
1069 | case ODIOCGDINFO: | | 1069 | case ODIOCGDINFO: |
1070 | case ODIOCWDINFO: | | 1070 | case ODIOCWDINFO: |
1071 | case ODIOCSDINFO: | | 1071 | case ODIOCSDINFO: |
1072 | case ODIOCGDEFLABEL: | | 1072 | case ODIOCGDEFLABEL: |
1073 | #endif | | 1073 | #endif |
1074 | case DIOCGPART: | | 1074 | case DIOCGPART: |
1075 | case DIOCWLABEL: | | 1075 | case DIOCWLABEL: |
1076 | case DIOCGDEFLABEL: | | 1076 | case DIOCGDEFLABEL: |
1077 | case DIOCAWEDGE: | | 1077 | case DIOCAWEDGE: |
1078 | case DIOCDWEDGE: | | 1078 | case DIOCDWEDGE: |
1079 | case DIOCLWEDGES: | | 1079 | case DIOCLWEDGES: |
1080 | case DIOCCACHESYNC: | | 1080 | case DIOCCACHESYNC: |
1081 | case RAIDFRAME_SHUTDOWN: | | 1081 | case RAIDFRAME_SHUTDOWN: |
1082 | case RAIDFRAME_REWRITEPARITY: | | 1082 | case RAIDFRAME_REWRITEPARITY: |
1083 | case RAIDFRAME_GET_INFO: | | 1083 | case RAIDFRAME_GET_INFO: |
1084 | case RAIDFRAME_RESET_ACCTOTALS: | | 1084 | case RAIDFRAME_RESET_ACCTOTALS: |
1085 | case RAIDFRAME_GET_ACCTOTALS: | | 1085 | case RAIDFRAME_GET_ACCTOTALS: |
1086 | case RAIDFRAME_KEEP_ACCTOTALS: | | 1086 | case RAIDFRAME_KEEP_ACCTOTALS: |
1087 | case RAIDFRAME_GET_SIZE: | | 1087 | case RAIDFRAME_GET_SIZE: |
1088 | case RAIDFRAME_FAIL_DISK: | | 1088 | case RAIDFRAME_FAIL_DISK: |
1089 | case RAIDFRAME_COPYBACK: | | 1089 | case RAIDFRAME_COPYBACK: |
1090 | case RAIDFRAME_CHECK_RECON_STATUS: | | 1090 | case RAIDFRAME_CHECK_RECON_STATUS: |
1091 | case RAIDFRAME_CHECK_RECON_STATUS_EXT: | | 1091 | case RAIDFRAME_CHECK_RECON_STATUS_EXT: |
1092 | case RAIDFRAME_GET_COMPONENT_LABEL: | | 1092 | case RAIDFRAME_GET_COMPONENT_LABEL: |
1093 | case RAIDFRAME_SET_COMPONENT_LABEL: | | 1093 | case RAIDFRAME_SET_COMPONENT_LABEL: |
1094 | case RAIDFRAME_ADD_HOT_SPARE: | | 1094 | case RAIDFRAME_ADD_HOT_SPARE: |
1095 | case RAIDFRAME_REMOVE_HOT_SPARE: | | 1095 | case RAIDFRAME_REMOVE_HOT_SPARE: |
1096 | case RAIDFRAME_INIT_LABELS: | | 1096 | case RAIDFRAME_INIT_LABELS: |
1097 | case RAIDFRAME_REBUILD_IN_PLACE: | | 1097 | case RAIDFRAME_REBUILD_IN_PLACE: |
1098 | case RAIDFRAME_CHECK_PARITY: | | 1098 | case RAIDFRAME_CHECK_PARITY: |
1099 | case RAIDFRAME_CHECK_PARITYREWRITE_STATUS: | | 1099 | case RAIDFRAME_CHECK_PARITYREWRITE_STATUS: |
1100 | case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT: | | 1100 | case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT: |
1101 | case RAIDFRAME_CHECK_COPYBACK_STATUS: | | 1101 | case RAIDFRAME_CHECK_COPYBACK_STATUS: |
1102 | case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT: | | 1102 | case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT: |
1103 | case RAIDFRAME_SET_AUTOCONFIG: | | 1103 | case RAIDFRAME_SET_AUTOCONFIG: |
1104 | case RAIDFRAME_SET_ROOT: | | 1104 | case RAIDFRAME_SET_ROOT: |
1105 | case RAIDFRAME_DELETE_COMPONENT: | | 1105 | case RAIDFRAME_DELETE_COMPONENT: |
1106 | case RAIDFRAME_INCORPORATE_HOT_SPARE: | | 1106 | case RAIDFRAME_INCORPORATE_HOT_SPARE: |
1107 | case RAIDFRAME_PARITYMAP_STATUS: | | 1107 | case RAIDFRAME_PARITYMAP_STATUS: |
1108 | case RAIDFRAME_PARITYMAP_GET_DISABLE: | | 1108 | case RAIDFRAME_PARITYMAP_GET_DISABLE: |
1109 | case RAIDFRAME_PARITYMAP_SET_DISABLE: | | 1109 | case RAIDFRAME_PARITYMAP_SET_DISABLE: |
1110 | case RAIDFRAME_PARITYMAP_SET_PARAMS: | | 1110 | case RAIDFRAME_PARITYMAP_SET_PARAMS: |
1111 | if ((rs->sc_flags & RAIDF_INITED) == 0) | | 1111 | if ((rs->sc_flags & RAIDF_INITED) == 0) |
1112 | return (ENXIO); | | 1112 | return (ENXIO); |
1113 | } | | 1113 | } |
1114 | | | 1114 | |
1115 | switch (cmd) { | | 1115 | switch (cmd) { |
1116 | #ifdef COMPAT_50 | | 1116 | #ifdef COMPAT_50 |
1117 | case RAIDFRAME_GET_INFO50: | | 1117 | case RAIDFRAME_GET_INFO50: |
1118 | return rf_get_info50(raidPtr, data); | | 1118 | return rf_get_info50(raidPtr, data); |
1119 | | | 1119 | |
1120 | case RAIDFRAME_CONFIGURE50: | | 1120 | case RAIDFRAME_CONFIGURE50: |
1121 | if ((retcode = rf_config50(raidPtr, unit, data, &k_cfg)) != 0) | | 1121 | if ((retcode = rf_config50(raidPtr, unit, data, &k_cfg)) != 0) |
1122 | return retcode; | | 1122 | return retcode; |
1123 | goto config; | | 1123 | goto config; |
1124 | #endif | | 1124 | #endif |
1125 | /* configure the system */ | | 1125 | /* configure the system */ |
1126 | case RAIDFRAME_CONFIGURE: | | 1126 | case RAIDFRAME_CONFIGURE: |
1127 | | | 1127 | |
1128 | if (raidPtr->valid) { | | 1128 | if (raidPtr->valid) { |
1129 | /* There is a valid RAID set running on this unit! */ | | 1129 | /* There is a valid RAID set running on this unit! */ |
1130 | printf("raid%d: Device already configured!\n",unit); | | 1130 | printf("raid%d: Device already configured!\n",unit); |
1131 | return(EINVAL); | | 1131 | return(EINVAL); |
1132 | } | | 1132 | } |
1133 | | | 1133 | |
1134 | /* copy-in the configuration information */ | | 1134 | /* copy-in the configuration information */ |
1135 | /* data points to a pointer to the configuration structure */ | | 1135 | /* data points to a pointer to the configuration structure */ |
1136 | | | 1136 | |
1137 | u_cfg = *((RF_Config_t **) data); | | 1137 | u_cfg = *((RF_Config_t **) data); |
1138 | RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *)); | | 1138 | RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *)); |
1139 | if (k_cfg == NULL) { | | 1139 | if (k_cfg == NULL) { |
1140 | return (ENOMEM); | | 1140 | return (ENOMEM); |
1141 | } | | 1141 | } |
1142 | retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t)); | | 1142 | retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t)); |
1143 | if (retcode) { | | 1143 | if (retcode) { |
1144 | RF_Free(k_cfg, sizeof(RF_Config_t)); | | 1144 | RF_Free(k_cfg, sizeof(RF_Config_t)); |
1145 | db1_printf(("rf_ioctl: retcode=%d copyin.1\n", | | 1145 | db1_printf(("rf_ioctl: retcode=%d copyin.1\n", |
1146 | retcode)); | | 1146 | retcode)); |
1147 | return (retcode); | | 1147 | return (retcode); |
1148 | } | | 1148 | } |
1149 | goto config; | | 1149 | goto config; |
1150 | config: | | 1150 | config: |
1151 | /* allocate a buffer for the layout-specific data, and copy it | | 1151 | /* allocate a buffer for the layout-specific data, and copy it |
1152 | * in */ | | 1152 | * in */ |
1153 | if (k_cfg->layoutSpecificSize) { | | 1153 | if (k_cfg->layoutSpecificSize) { |
1154 | if (k_cfg->layoutSpecificSize > 10000) { | | 1154 | if (k_cfg->layoutSpecificSize > 10000) { |
1155 | /* sanity check */ | | 1155 | /* sanity check */ |
1156 | RF_Free(k_cfg, sizeof(RF_Config_t)); | | 1156 | RF_Free(k_cfg, sizeof(RF_Config_t)); |
1157 | return (EINVAL); | | 1157 | return (EINVAL); |
1158 | } | | 1158 | } |
1159 | RF_Malloc(specific_buf, k_cfg->layoutSpecificSize, | | 1159 | RF_Malloc(specific_buf, k_cfg->layoutSpecificSize, |
1160 | (u_char *)); | | 1160 | (u_char *)); |
1161 | if (specific_buf == NULL) { | | 1161 | if (specific_buf == NULL) { |
1162 | RF_Free(k_cfg, sizeof(RF_Config_t)); | | 1162 | RF_Free(k_cfg, sizeof(RF_Config_t)); |
1163 | return (ENOMEM); | | 1163 | return (ENOMEM); |
1164 | } | | 1164 | } |
1165 | retcode = copyin(k_cfg->layoutSpecific, specific_buf, | | 1165 | retcode = copyin(k_cfg->layoutSpecific, specific_buf, |
1166 | k_cfg->layoutSpecificSize); | | 1166 | k_cfg->layoutSpecificSize); |
1167 | if (retcode) { | | 1167 | if (retcode) { |
1168 | RF_Free(k_cfg, sizeof(RF_Config_t)); | | 1168 | RF_Free(k_cfg, sizeof(RF_Config_t)); |
1169 | RF_Free(specific_buf, | | 1169 | RF_Free(specific_buf, |
1170 | k_cfg->layoutSpecificSize); | | 1170 | k_cfg->layoutSpecificSize); |
1171 | db1_printf(("rf_ioctl: retcode=%d copyin.2\n", | | 1171 | db1_printf(("rf_ioctl: retcode=%d copyin.2\n", |
1172 | retcode)); | | 1172 | retcode)); |
1173 | return (retcode); | | 1173 | return (retcode); |
1174 | } | | 1174 | } |
1175 | } else | | 1175 | } else |
1176 | specific_buf = NULL; | | 1176 | specific_buf = NULL; |
1177 | k_cfg->layoutSpecific = specific_buf; | | 1177 | k_cfg->layoutSpecific = specific_buf; |
1178 | | | 1178 | |
1179 | /* should do some kind of sanity check on the configuration. | | 1179 | /* should do some kind of sanity check on the configuration. |
1180 | * Store the sum of all the bytes in the last byte? */ | | 1180 | * Store the sum of all the bytes in the last byte? */ |
1181 | | | 1181 | |
1182 | /* configure the system */ | | 1182 | /* configure the system */ |
1183 | | | 1183 | |
1184 | /* | | 1184 | /* |
1185 | * Clear the entire RAID descriptor, just to make sure | | 1185 | * Clear the entire RAID descriptor, just to make sure |
1186 | * there is no stale data left in the case of a | | 1186 | * there is no stale data left in the case of a |
1187 | * reconfiguration | | 1187 | * reconfiguration |
1188 | */ | | 1188 | */ |
1189 | memset((char *) raidPtr, 0, sizeof(RF_Raid_t)); | | 1189 | memset((char *) raidPtr, 0, sizeof(RF_Raid_t)); |
1190 | raidPtr->raidid = unit; | | 1190 | raidPtr->raidid = unit; |
1191 | | | 1191 | |
1192 | retcode = rf_Configure(raidPtr, k_cfg, NULL); | | 1192 | retcode = rf_Configure(raidPtr, k_cfg, NULL); |
1193 | | | 1193 | |
1194 | if (retcode == 0) { | | 1194 | if (retcode == 0) { |
1195 | | | 1195 | |
1196 | /* allow this many simultaneous IO's to | | 1196 | /* allow this many simultaneous IO's to |
1197 | this RAID device */ | | 1197 | this RAID device */ |
1198 | raidPtr->openings = RAIDOUTSTANDING; | | 1198 | raidPtr->openings = RAIDOUTSTANDING; |
1199 | | | 1199 | |
1200 | raidinit(raidPtr); | | 1200 | raidinit(raidPtr); |
1201 | rf_markalldirty(raidPtr); | | 1201 | rf_markalldirty(raidPtr); |
1202 | } | | 1202 | } |
1203 | /* free the buffers. No return code here. */ | | 1203 | /* free the buffers. No return code here. */ |
1204 | if (k_cfg->layoutSpecificSize) { | | 1204 | if (k_cfg->layoutSpecificSize) { |
1205 | RF_Free(specific_buf, k_cfg->layoutSpecificSize); | | 1205 | RF_Free(specific_buf, k_cfg->layoutSpecificSize); |
1206 | } | | 1206 | } |
1207 | RF_Free(k_cfg, sizeof(RF_Config_t)); | | 1207 | RF_Free(k_cfg, sizeof(RF_Config_t)); |
1208 | | | 1208 | |
1209 | return (retcode); | | 1209 | return (retcode); |
1210 | | | 1210 | |
1211 | /* shutdown the system */ | | 1211 | /* shutdown the system */ |
1212 | case RAIDFRAME_SHUTDOWN: | | 1212 | case RAIDFRAME_SHUTDOWN: |
1213 | | | 1213 | |
1214 | part = DISKPART(dev); | | 1214 | part = DISKPART(dev); |
1215 | pmask = (1 << part); | | 1215 | pmask = (1 << part); |
1216 | | | 1216 | |
1217 | if ((error = raidlock(rs)) != 0) | | 1217 | if ((error = raidlock(rs)) != 0) |
1218 | return (error); | | 1218 | return (error); |
1219 | | | 1219 | |
1220 | if ((rs->sc_dkdev.dk_openmask & ~pmask) || | | 1220 | if ((rs->sc_dkdev.dk_openmask & ~pmask) || |
1221 | ((rs->sc_dkdev.dk_bopenmask & pmask) && | | 1221 | ((rs->sc_dkdev.dk_bopenmask & pmask) && |
1222 | (rs->sc_dkdev.dk_copenmask & pmask))) | | 1222 | (rs->sc_dkdev.dk_copenmask & pmask))) |
1223 | retcode = EBUSY; | | 1223 | retcode = EBUSY; |
1224 | else { | | 1224 | else { |
1225 | rs->sc_flags |= RAIDF_SHUTDOWN; | | 1225 | rs->sc_flags |= RAIDF_SHUTDOWN; |
1226 | rs->sc_dkdev.dk_copenmask &= ~pmask; | | 1226 | rs->sc_dkdev.dk_copenmask &= ~pmask; |
1227 | rs->sc_dkdev.dk_bopenmask &= ~pmask; | | 1227 | rs->sc_dkdev.dk_bopenmask &= ~pmask; |
1228 | rs->sc_dkdev.dk_openmask &= ~pmask; | | 1228 | rs->sc_dkdev.dk_openmask &= ~pmask; |
1229 | retcode = 0; | | 1229 | retcode = 0; |
1230 | } | | 1230 | } |
1231 | | | 1231 | |
1232 | raidunlock(rs); | | 1232 | raidunlock(rs); |
1233 | | | 1233 | |
1234 | if (retcode != 0) | | 1234 | if (retcode != 0) |
1235 | return retcode; | | 1235 | return retcode; |
1236 | | | 1236 | |
1237 | /* free the pseudo device attach bits */ | | 1237 | /* free the pseudo device attach bits */ |
1238 | | | 1238 | |
1239 | cf = device_cfdata(rs->sc_dev); | | 1239 | cf = device_cfdata(rs->sc_dev); |
1240 | if ((retcode = config_detach(rs->sc_dev, DETACH_QUIET)) == 0) | | 1240 | if ((retcode = config_detach(rs->sc_dev, DETACH_QUIET)) == 0) |
1241 | free(cf, M_RAIDFRAME); | | 1241 | free(cf, M_RAIDFRAME); |
1242 | | | 1242 | |
1243 | return (retcode); | | 1243 | return (retcode); |
1244 | case RAIDFRAME_GET_COMPONENT_LABEL: | | 1244 | case RAIDFRAME_GET_COMPONENT_LABEL: |
1245 | clabel_ptr = (RF_ComponentLabel_t **) data; | | 1245 | clabel_ptr = (RF_ComponentLabel_t **) data; |
1246 | /* need to read the component label for the disk indicated | | 1246 | /* need to read the component label for the disk indicated |
1247 | by row,column in clabel */ | | 1247 | by row,column in clabel */ |
1248 | | | 1248 | |
1249 | /* | | 1249 | /* |
1250 | * Perhaps there should be an option to skip the in-core | | 1250 | * Perhaps there should be an option to skip the in-core |
1251 | * copy and hit the disk, as with disklabel(8). | | 1251 | * copy and hit the disk, as with disklabel(8). |
1252 | */ | | 1252 | */ |
1253 | RF_Malloc(clabel, sizeof(*clabel), (RF_ComponentLabel_t *)); | | 1253 | RF_Malloc(clabel, sizeof(*clabel), (RF_ComponentLabel_t *)); |
1254 | | | 1254 | |
1255 | retcode = copyin( *clabel_ptr, clabel, | | 1255 | retcode = copyin( *clabel_ptr, clabel, |
1256 | sizeof(RF_ComponentLabel_t)); | | 1256 | sizeof(RF_ComponentLabel_t)); |
1257 | | | 1257 | |
1258 | if (retcode) { | | 1258 | if (retcode) { |
1259 | return(retcode); | | 1259 | return(retcode); |
1260 | } | | 1260 | } |
1261 | | | 1261 | |
1262 | clabel->row = 0; /* Don't allow looking at anything else.*/ | | 1262 | clabel->row = 0; /* Don't allow looking at anything else.*/ |
1263 | | | 1263 | |
1264 | column = clabel->column; | | 1264 | column = clabel->column; |
1265 | | | 1265 | |
1266 | if ((column < 0) || (column >= raidPtr->numCol + | | 1266 | if ((column < 0) || (column >= raidPtr->numCol + |
1267 | raidPtr->numSpare)) { | | 1267 | raidPtr->numSpare)) { |
1268 | return(EINVAL); | | 1268 | return(EINVAL); |
1269 | } | | 1269 | } |
1270 | | | 1270 | |
1271 | RF_Free(clabel, sizeof(*clabel)); | | 1271 | RF_Free(clabel, sizeof(*clabel)); |
1272 | | | 1272 | |
1273 | clabel = raidget_component_label(raidPtr, column); | | 1273 | clabel = raidget_component_label(raidPtr, column); |
1274 | | | 1274 | |
1275 | if (retcode == 0) { | | 1275 | if (retcode == 0) { |
1276 | retcode = copyout(clabel, *clabel_ptr, | | 1276 | retcode = copyout(clabel, *clabel_ptr, |
1277 | sizeof(RF_ComponentLabel_t)); | | 1277 | sizeof(RF_ComponentLabel_t)); |
1278 | } | | 1278 | } |
1279 | return (retcode); | | 1279 | return (retcode); |
1280 | | | 1280 | |
1281 | #if 0 | | 1281 | #if 0 |
1282 | case RAIDFRAME_SET_COMPONENT_LABEL: | | 1282 | case RAIDFRAME_SET_COMPONENT_LABEL: |
1283 | clabel = (RF_ComponentLabel_t *) data; | | 1283 | clabel = (RF_ComponentLabel_t *) data; |
1284 | | | 1284 | |
1285 | /* XXX check the label for valid stuff... */ | | 1285 | /* XXX check the label for valid stuff... */ |
1286 | /* Note that some things *should not* get modified -- | | 1286 | /* Note that some things *should not* get modified -- |
1287 | the user should be re-initing the labels instead of | | 1287 | the user should be re-initing the labels instead of |
1288 | trying to patch things. | | 1288 | trying to patch things. |
1289 | */ | | 1289 | */ |
1290 | | | 1290 | |
1291 | raidid = raidPtr->raidid; | | 1291 | raidid = raidPtr->raidid; |
1292 | #ifdef DEBUG | | 1292 | #ifdef DEBUG |
1293 | printf("raid%d: Got component label:\n", raidid); | | 1293 | printf("raid%d: Got component label:\n", raidid); |
1294 | printf("raid%d: Version: %d\n", raidid, clabel->version); | | 1294 | printf("raid%d: Version: %d\n", raidid, clabel->version); |
1295 | printf("raid%d: Serial Number: %d\n", raidid, clabel->serial_number); | | 1295 | printf("raid%d: Serial Number: %d\n", raidid, clabel->serial_number); |
1296 | printf("raid%d: Mod counter: %d\n", raidid, clabel->mod_counter); | | 1296 | printf("raid%d: Mod counter: %d\n", raidid, clabel->mod_counter); |
1297 | printf("raid%d: Column: %d\n", raidid, clabel->column); | | 1297 | printf("raid%d: Column: %d\n", raidid, clabel->column); |
1298 | printf("raid%d: Num Columns: %d\n", raidid, clabel->num_columns); | | 1298 | printf("raid%d: Num Columns: %d\n", raidid, clabel->num_columns); |
1299 | printf("raid%d: Clean: %d\n", raidid, clabel->clean); | | 1299 | printf("raid%d: Clean: %d\n", raidid, clabel->clean); |
1300 | printf("raid%d: Status: %d\n", raidid, clabel->status); | | 1300 | printf("raid%d: Status: %d\n", raidid, clabel->status); |
1301 | #endif | | 1301 | #endif |
1302 | clabel->row = 0; | | 1302 | clabel->row = 0; |
1303 | column = clabel->column; | | 1303 | column = clabel->column; |
1304 | | | 1304 | |
1305 | if ((column < 0) || (column >= raidPtr->numCol)) { | | 1305 | if ((column < 0) || (column >= raidPtr->numCol)) { |
1306 | return(EINVAL); | | 1306 | return(EINVAL); |
1307 | } | | 1307 | } |
1308 | | | 1308 | |
1309 | /* XXX this isn't allowed to do anything for now :-) */ | | 1309 | /* XXX this isn't allowed to do anything for now :-) */ |
1310 | | | 1310 | |
1311 | /* XXX and before it is, we need to fill in the rest | | 1311 | /* XXX and before it is, we need to fill in the rest |
1312 | of the fields!?!?!?! */ | | 1312 | of the fields!?!?!?! */ |
1313 | memcpy(raidget_component_label(raidPtr, column), | | 1313 | memcpy(raidget_component_label(raidPtr, column), |
1314 | clabel, sizeof(*clabel)); | | 1314 | clabel, sizeof(*clabel)); |
1315 | raidflush_component_label(raidPtr, column); | | 1315 | raidflush_component_label(raidPtr, column); |
1316 | return (0); | | 1316 | return (0); |
1317 | #endif | | 1317 | #endif |
1318 | | | 1318 | |
1319 | case RAIDFRAME_INIT_LABELS: | | 1319 | case RAIDFRAME_INIT_LABELS: |
1320 | clabel = (RF_ComponentLabel_t *) data; | | 1320 | clabel = (RF_ComponentLabel_t *) data; |
1321 | /* | | 1321 | /* |
1322 | we only want the serial number from | | 1322 | we only want the serial number from |
1323 | the above. We get all the rest of the information | | 1323 | the above. We get all the rest of the information |
1324 | from the config that was used to create this RAID | | 1324 | from the config that was used to create this RAID |
1325 | set. | | 1325 | set. |
1326 | */ | | 1326 | */ |
1327 | | | 1327 | |
1328 | raidPtr->serial_number = clabel->serial_number; | | 1328 | raidPtr->serial_number = clabel->serial_number; |
1329 | | | 1329 | |
1330 | for(column=0;column<raidPtr->numCol;column++) { | | 1330 | for(column=0;column<raidPtr->numCol;column++) { |
1331 | diskPtr = &raidPtr->Disks[column]; | | 1331 | diskPtr = &raidPtr->Disks[column]; |
1332 | if (!RF_DEAD_DISK(diskPtr->status)) { | | 1332 | if (!RF_DEAD_DISK(diskPtr->status)) { |
1333 | ci_label = raidget_component_label(raidPtr, | | 1333 | ci_label = raidget_component_label(raidPtr, |
1334 | column); | | 1334 | column); |
1335 | /* Zeroing this is important. */ | | 1335 | /* Zeroing this is important. */ |
1336 | memset(ci_label, 0, sizeof(*ci_label)); | | 1336 | memset(ci_label, 0, sizeof(*ci_label)); |
1337 | raid_init_component_label(raidPtr, ci_label); | | 1337 | raid_init_component_label(raidPtr, ci_label); |
1338 | ci_label->serial_number = | | 1338 | ci_label->serial_number = |
1339 | raidPtr->serial_number; | | 1339 | raidPtr->serial_number; |
1340 | ci_label->row = 0; /* we dont' pretend to support more */ | | 1340 | ci_label->row = 0; /* we dont' pretend to support more */ |
1341 | ci_label->partitionSize = | | 1341 | ci_label->partitionSize = |
1342 | diskPtr->partitionSize; | | 1342 | diskPtr->partitionSize; |
1343 | ci_label->column = column; | | 1343 | ci_label->column = column; |
1344 | raidflush_component_label(raidPtr, column); | | 1344 | raidflush_component_label(raidPtr, column); |
1345 | } | | 1345 | } |
1346 | /* XXXjld what about the spares? */ | | 1346 | /* XXXjld what about the spares? */ |
1347 | } | | 1347 | } |
1348 | | | 1348 | |
1349 | return (retcode); | | 1349 | return (retcode); |
1350 | case RAIDFRAME_SET_AUTOCONFIG: | | 1350 | case RAIDFRAME_SET_AUTOCONFIG: |
1351 | d = rf_set_autoconfig(raidPtr, *(int *) data); | | 1351 | d = rf_set_autoconfig(raidPtr, *(int *) data); |
1352 | printf("raid%d: New autoconfig value is: %d\n", | | 1352 | printf("raid%d: New autoconfig value is: %d\n", |
1353 | raidPtr->raidid, d); | | 1353 | raidPtr->raidid, d); |
1354 | *(int *) data = d; | | 1354 | *(int *) data = d; |
1355 | return (retcode); | | 1355 | return (retcode); |
1356 | | | 1356 | |
1357 | case RAIDFRAME_SET_ROOT: | | 1357 | case RAIDFRAME_SET_ROOT: |
1358 | d = rf_set_rootpartition(raidPtr, *(int *) data); | | 1358 | d = rf_set_rootpartition(raidPtr, *(int *) data); |
1359 | printf("raid%d: New rootpartition value is: %d\n", | | 1359 | printf("raid%d: New rootpartition value is: %d\n", |
1360 | raidPtr->raidid, d); | | 1360 | raidPtr->raidid, d); |
1361 | *(int *) data = d; | | 1361 | *(int *) data = d; |
1362 | return (retcode); | | 1362 | return (retcode); |
1363 | | | 1363 | |
1364 | /* initialize all parity */ | | 1364 | /* initialize all parity */ |
1365 | case RAIDFRAME_REWRITEPARITY: | | 1365 | case RAIDFRAME_REWRITEPARITY: |
1366 | | | 1366 | |
1367 | if (raidPtr->Layout.map->faultsTolerated == 0) { | | 1367 | if (raidPtr->Layout.map->faultsTolerated == 0) { |
1368 | /* Parity for RAID 0 is trivially correct */ | | 1368 | /* Parity for RAID 0 is trivially correct */ |
1369 | raidPtr->parity_good = RF_RAID_CLEAN; | | 1369 | raidPtr->parity_good = RF_RAID_CLEAN; |
1370 | return(0); | | 1370 | return(0); |
1371 | } | | 1371 | } |
1372 | | | 1372 | |
1373 | if (raidPtr->parity_rewrite_in_progress == 1) { | | 1373 | if (raidPtr->parity_rewrite_in_progress == 1) { |
1374 | /* Re-write is already in progress! */ | | 1374 | /* Re-write is already in progress! */ |
1375 | return(EINVAL); | | 1375 | return(EINVAL); |
1376 | } | | 1376 | } |
1377 | | | 1377 | |
1378 | retcode = RF_CREATE_THREAD(raidPtr->parity_rewrite_thread, | | 1378 | retcode = RF_CREATE_THREAD(raidPtr->parity_rewrite_thread, |
1379 | rf_RewriteParityThread, | | 1379 | rf_RewriteParityThread, |
1380 | raidPtr,"raid_parity"); | | 1380 | raidPtr,"raid_parity"); |
1381 | return (retcode); | | 1381 | return (retcode); |
1382 | | | 1382 | |
1383 | | | 1383 | |
1384 | case RAIDFRAME_ADD_HOT_SPARE: | | 1384 | case RAIDFRAME_ADD_HOT_SPARE: |
1385 | sparePtr = (RF_SingleComponent_t *) data; | | 1385 | sparePtr = (RF_SingleComponent_t *) data; |
1386 | memcpy( &component, sparePtr, sizeof(RF_SingleComponent_t)); | | 1386 | memcpy( &component, sparePtr, sizeof(RF_SingleComponent_t)); |
1387 | retcode = rf_add_hot_spare(raidPtr, &component); | | 1387 | retcode = rf_add_hot_spare(raidPtr, &component); |