author | George Wilson <George.Wilson@Sun.COM> |
Tue, 26 May 2009 10:05:28 -0700 | |
changeset 9722 | e3866bad4e96 |
parent 9470 | 6d827468d7b5 |
child 9725 | 0bf7402e8022 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/zfs_context.h> |
|
1544 | 27 |
#include <sys/fm/fs/zfs.h> |
789 | 28 |
#include <sys/spa.h> |
29 |
#include <sys/txg.h> |
|
30 |
#include <sys/spa_impl.h> |
|
31 |
#include <sys/vdev_impl.h> |
|
32 |
#include <sys/zio_impl.h> |
|
33 |
#include <sys/zio_compress.h> |
|
34 |
#include <sys/zio_checksum.h> |
|
35 |
||
36 |
/* |
|
37 |
* ========================================================================== |
|
38 |
* I/O priority table |
|
39 |
* ========================================================================== |
|
40 |
*/ |
|
41 |
uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE] = { |
|
42 |
0, /* ZIO_PRIORITY_NOW */ |
|
43 |
0, /* ZIO_PRIORITY_SYNC_READ */ |
|
44 |
0, /* ZIO_PRIORITY_SYNC_WRITE */ |
|
45 |
6, /* ZIO_PRIORITY_ASYNC_READ */ |
|
46 |
4, /* ZIO_PRIORITY_ASYNC_WRITE */ |
|
47 |
4, /* ZIO_PRIORITY_FREE */ |
|
48 |
0, /* ZIO_PRIORITY_CACHE_FILL */ |
|
49 |
0, /* ZIO_PRIORITY_LOG_WRITE */ |
|
50 |
10, /* ZIO_PRIORITY_RESILVER */ |
|
51 |
20, /* ZIO_PRIORITY_SCRUB */ |
|
52 |
}; |
|
53 |
||
54 |
/* |
|
55 |
* ========================================================================== |
|
56 |
* I/O type descriptions |
|
57 |
* ========================================================================== |
|
58 |
*/ |
|
59 |
char *zio_type_name[ZIO_TYPES] = { |
|
60 |
"null", "read", "write", "free", "claim", "ioctl" }; |
|
61 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
62 |
#define SYNC_PASS_DEFERRED_FREE 1 /* defer frees after this pass */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
63 |
#define SYNC_PASS_DONT_COMPRESS 4 /* don't compress after this pass */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
64 |
#define SYNC_PASS_REWRITE 1 /* rewrite new bps after this pass */ |
5329 | 65 |
|
789 | 66 |
/* |
67 |
* ========================================================================== |
|
68 |
* I/O kmem caches |
|
69 |
* ========================================================================== |
|
70 |
*/ |
|
4055 | 71 |
kmem_cache_t *zio_cache; |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
72 |
kmem_cache_t *zio_link_cache; |
789 | 73 |
kmem_cache_t *zio_buf_cache[SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT]; |
3290 | 74 |
kmem_cache_t *zio_data_buf_cache[SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT]; |
75 |
||
76 |
#ifdef _KERNEL |
|
77 |
extern vmem_t *zio_alloc_arena; |
|
78 |
#endif |
|
789 | 79 |
|
5329 | 80 |
/* |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
81 |
* An allocating zio is one that either currently has the DVA allocate |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
82 |
* stage set or will have it later in its lifetime. |
5329 | 83 |
*/ |
84 |
#define IO_IS_ALLOCATING(zio) \ |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5530
diff
changeset
|
85 |
((zio)->io_orig_pipeline & (1U << ZIO_STAGE_DVA_ALLOCATE)) |
5329 | 86 |
|
789 | 87 |
void |
88 |
zio_init(void) |
|
89 |
{ |
|
90 |
size_t c; |
|
3290 | 91 |
vmem_t *data_alloc_arena = NULL; |
92 |
||
93 |
#ifdef _KERNEL |
|
94 |
data_alloc_arena = zio_alloc_arena; |
|
95 |
#endif |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
96 |
zio_cache = kmem_cache_create("zio_cache", |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
97 |
sizeof (zio_t), 0, NULL, NULL, NULL, NULL, NULL, 0); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
98 |
zio_link_cache = kmem_cache_create("zio_link_cache", |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
99 |
sizeof (zio_link_t), 0, NULL, NULL, NULL, NULL, NULL, 0); |
4055 | 100 |
|
789 | 101 |
/* |
102 |
* For small buffers, we want a cache for each multiple of |
|
103 |
* SPA_MINBLOCKSIZE. For medium-size buffers, we want a cache |
|
104 |
* for each quarter-power of 2. For large buffers, we want |
|
105 |
* a cache for each multiple of PAGESIZE. |
|
106 |
*/ |
|
107 |
for (c = 0; c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; c++) { |
|
108 |
size_t size = (c + 1) << SPA_MINBLOCKSHIFT; |
|
109 |
size_t p2 = size; |
|
110 |
size_t align = 0; |
|
111 |
||
112 |
while (p2 & (p2 - 1)) |
|
113 |
p2 &= p2 - 1; |
|
114 |
||
115 |
if (size <= 4 * SPA_MINBLOCKSIZE) { |
|
116 |
align = SPA_MINBLOCKSIZE; |
|
117 |
} else if (P2PHASE(size, PAGESIZE) == 0) { |
|
118 |
align = PAGESIZE; |
|
119 |
} else if (P2PHASE(size, p2 >> 2) == 0) { |
|
120 |
align = p2 >> 2; |
|
121 |
} |
|
122 |
||
123 |
if (align != 0) { |
|
3290 | 124 |
char name[36]; |
2856 | 125 |
(void) sprintf(name, "zio_buf_%lu", (ulong_t)size); |
789 | 126 |
zio_buf_cache[c] = kmem_cache_create(name, size, |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
127 |
align, NULL, NULL, NULL, NULL, NULL, KMC_NODEBUG); |
3290 | 128 |
|
129 |
(void) sprintf(name, "zio_data_buf_%lu", (ulong_t)size); |
|
130 |
zio_data_buf_cache[c] = kmem_cache_create(name, size, |
|
131 |
align, NULL, NULL, NULL, NULL, data_alloc_arena, |
|
132 |
KMC_NODEBUG); |
|
789 | 133 |
} |
134 |
} |
|
135 |
||
136 |
while (--c != 0) { |
|
137 |
ASSERT(zio_buf_cache[c] != NULL); |
|
138 |
if (zio_buf_cache[c - 1] == NULL) |
|
139 |
zio_buf_cache[c - 1] = zio_buf_cache[c]; |
|
3290 | 140 |
|
141 |
ASSERT(zio_data_buf_cache[c] != NULL); |
|
142 |
if (zio_data_buf_cache[c - 1] == NULL) |
|
143 |
zio_data_buf_cache[c - 1] = zio_data_buf_cache[c]; |
|
789 | 144 |
} |
1544 | 145 |
|
146 |
zio_inject_init(); |
|
789 | 147 |
} |
148 |
||
149 |
void |
|
150 |
zio_fini(void) |
|
151 |
{ |
|
152 |
size_t c; |
|
153 |
kmem_cache_t *last_cache = NULL; |
|
3290 | 154 |
kmem_cache_t *last_data_cache = NULL; |
789 | 155 |
|
156 |
for (c = 0; c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; c++) { |
|
157 |
if (zio_buf_cache[c] != last_cache) { |
|
158 |
last_cache = zio_buf_cache[c]; |
|
159 |
kmem_cache_destroy(zio_buf_cache[c]); |
|
160 |
} |
|
161 |
zio_buf_cache[c] = NULL; |
|
3290 | 162 |
|
163 |
if (zio_data_buf_cache[c] != last_data_cache) { |
|
164 |
last_data_cache = zio_data_buf_cache[c]; |
|
165 |
kmem_cache_destroy(zio_data_buf_cache[c]); |
|
166 |
} |
|
167 |
zio_data_buf_cache[c] = NULL; |
|
789 | 168 |
} |
1544 | 169 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
170 |
kmem_cache_destroy(zio_link_cache); |
4055 | 171 |
kmem_cache_destroy(zio_cache); |
172 |
||
1544 | 173 |
zio_inject_fini(); |
789 | 174 |
} |
175 |
||
176 |
/* |
|
177 |
* ========================================================================== |
|
178 |
* Allocate and free I/O buffers |
|
179 |
* ========================================================================== |
|
180 |
*/ |
|
3290 | 181 |
|
182 |
/* |
|
183 |
* Use zio_buf_alloc to allocate ZFS metadata. This data will appear in a |
|
184 |
* crashdump if the kernel panics, so use it judiciously. Obviously, it's |
|
185 |
* useful to inspect ZFS metadata, but if possible, we should avoid keeping |
|
186 |
* excess / transient data in-core during a crashdump. |
|
187 |
*/ |
|
789 | 188 |
void * |
189 |
zio_buf_alloc(size_t size) |
|
190 |
{ |
|
191 |
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; |
|
192 |
||
193 |
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); |
|
194 |
||
6245
1a2a7cfb9f26
6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents:
5688
diff
changeset
|
195 |
return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE)); |
789 | 196 |
} |
197 |
||
3290 | 198 |
/* |
199 |
* Use zio_data_buf_alloc to allocate data. The data will not appear in a |
|
200 |
* crashdump if the kernel panics. This exists so that we will limit the amount |
|
201 |
* of ZFS data that shows up in a kernel crashdump. (Thus reducing the amount |
|
202 |
* of kernel heap dumped to disk when the kernel panics) |
|
203 |
*/ |
|
204 |
void * |
|
205 |
zio_data_buf_alloc(size_t size) |
|
206 |
{ |
|
207 |
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; |
|
208 |
||
209 |
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); |
|
210 |
||
6245
1a2a7cfb9f26
6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents:
5688
diff
changeset
|
211 |
return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE)); |
3290 | 212 |
} |
213 |
||
789 | 214 |
void |
215 |
zio_buf_free(void *buf, size_t size) |
|
216 |
{ |
|
217 |
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; |
|
218 |
||
219 |
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); |
|
220 |
||
221 |
kmem_cache_free(zio_buf_cache[c], buf); |
|
222 |
} |
|
223 |
||
3290 | 224 |
void |
225 |
zio_data_buf_free(void *buf, size_t size) |
|
226 |
{ |
|
227 |
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; |
|
228 |
||
229 |
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); |
|
230 |
||
231 |
kmem_cache_free(zio_data_buf_cache[c], buf); |
|
232 |
} |
|
3463 | 233 |
|
789 | 234 |
/* |
235 |
* ========================================================================== |
|
236 |
* Push and pop I/O transform buffers |
|
237 |
* ========================================================================== |
|
238 |
*/ |
|
239 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
240 |
zio_push_transform(zio_t *zio, void *data, uint64_t size, uint64_t bufsize, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
241 |
zio_transform_func_t *transform) |
789 | 242 |
{ |
243 |
zio_transform_t *zt = kmem_alloc(sizeof (zio_transform_t), KM_SLEEP); |
|
244 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
245 |
zt->zt_orig_data = zio->io_data; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
246 |
zt->zt_orig_size = zio->io_size; |
789 | 247 |
zt->zt_bufsize = bufsize; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
248 |
zt->zt_transform = transform; |
789 | 249 |
|
250 |
zt->zt_next = zio->io_transform_stack; |
|
251 |
zio->io_transform_stack = zt; |
|
252 |
||
253 |
zio->io_data = data; |
|
254 |
zio->io_size = size; |
|
255 |
} |
|
256 |
||
257 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
258 |
zio_pop_transforms(zio_t *zio) |
789 | 259 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
260 |
zio_transform_t *zt; |
789 | 261 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
262 |
while ((zt = zio->io_transform_stack) != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
263 |
if (zt->zt_transform != NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
264 |
zt->zt_transform(zio, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
265 |
zt->zt_orig_data, zt->zt_orig_size); |
789 | 266 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
267 |
zio_buf_free(zio->io_data, zt->zt_bufsize); |
789 | 268 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
269 |
zio->io_data = zt->zt_orig_data; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
270 |
zio->io_size = zt->zt_orig_size; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
271 |
zio->io_transform_stack = zt->zt_next; |
789 | 272 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
273 |
kmem_free(zt, sizeof (zio_transform_t)); |
789 | 274 |
} |
275 |
} |
|
276 |
||
277 |
/* |
|
278 |
* ========================================================================== |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
279 |
* I/O transform callbacks for subblocks and decompression |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
280 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
281 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
282 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
283 |
zio_subblock(zio_t *zio, void *data, uint64_t size) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
284 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
285 |
ASSERT(zio->io_size > size); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
286 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
287 |
if (zio->io_type == ZIO_TYPE_READ) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
288 |
bcopy(zio->io_data, data, size); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
289 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
290 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
291 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
292 |
zio_decompress(zio_t *zio, void *data, uint64_t size) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
293 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
294 |
if (zio->io_error == 0 && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
295 |
zio_decompress_data(BP_GET_COMPRESS(zio->io_bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
296 |
zio->io_data, zio->io_size, data, size) != 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
297 |
zio->io_error = EIO; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
298 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
299 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
300 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
301 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
302 |
* I/O parent/child relationships and pipeline interlocks |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
303 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
304 |
*/ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
305 |
/* |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
306 |
* NOTE - Callers to zio_walk_parents() and zio_walk_children must |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
307 |
* continue calling these functions until they return NULL. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
308 |
* Otherwise, the next caller will pick up the list walk in |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
309 |
* some indeterminate state. (Otherwise every caller would |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
310 |
* have to pass in a cookie to keep the state represented by |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
311 |
* io_walk_link, which gets annoying.) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
312 |
*/ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
313 |
zio_t * |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
314 |
zio_walk_parents(zio_t *cio) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
315 |
{ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
316 |
zio_link_t *zl = cio->io_walk_link; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
317 |
list_t *pl = &cio->io_parent_list; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
318 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
319 |
zl = (zl == NULL) ? list_head(pl) : list_next(pl, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
320 |
cio->io_walk_link = zl; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
321 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
322 |
if (zl == NULL) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
323 |
return (NULL); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
324 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
325 |
ASSERT(zl->zl_child == cio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
326 |
return (zl->zl_parent); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
327 |
} |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
328 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
329 |
zio_t * |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
330 |
zio_walk_children(zio_t *pio) |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
331 |
{ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
332 |
zio_link_t *zl = pio->io_walk_link; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
333 |
list_t *cl = &pio->io_child_list; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
334 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
335 |
zl = (zl == NULL) ? list_head(cl) : list_next(cl, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
336 |
pio->io_walk_link = zl; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
337 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
338 |
if (zl == NULL) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
339 |
return (NULL); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
340 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
341 |
ASSERT(zl->zl_parent == pio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
342 |
return (zl->zl_child); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
343 |
} |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
344 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
345 |
zio_t * |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
346 |
zio_unique_parent(zio_t *cio) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
347 |
{ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
348 |
zio_t *pio = zio_walk_parents(cio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
349 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
350 |
VERIFY(zio_walk_parents(cio) == NULL); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
351 |
return (pio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
352 |
} |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
353 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
354 |
void |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
355 |
zio_add_child(zio_t *pio, zio_t *cio) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
356 |
{ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
357 |
zio_link_t *zl = kmem_cache_alloc(zio_link_cache, KM_SLEEP); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
358 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
359 |
/* |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
360 |
* Logical I/Os can have logical, gang, or vdev children. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
361 |
* Gang I/Os can have gang or vdev children. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
362 |
* Vdev I/Os can only have vdev children. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
363 |
* The following ASSERT captures all of these constraints. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
364 |
*/ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
365 |
ASSERT(cio->io_child_type <= pio->io_child_type); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
366 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
367 |
zl->zl_parent = pio; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
368 |
zl->zl_child = cio; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
369 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
370 |
mutex_enter(&cio->io_lock); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
371 |
mutex_enter(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
372 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
373 |
ASSERT(pio->io_state[ZIO_WAIT_DONE] == 0); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
374 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
375 |
for (int w = 0; w < ZIO_WAIT_TYPES; w++) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
376 |
pio->io_children[cio->io_child_type][w] += !cio->io_state[w]; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
377 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
378 |
list_insert_head(&pio->io_child_list, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
379 |
list_insert_head(&cio->io_parent_list, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
380 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
381 |
mutex_exit(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
382 |
mutex_exit(&cio->io_lock); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
383 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
384 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
385 |
static void |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
386 |
zio_remove_child(zio_t *pio, zio_t *cio, zio_link_t *zl) |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
387 |
{ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
388 |
ASSERT(zl->zl_parent == pio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
389 |
ASSERT(zl->zl_child == cio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
390 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
391 |
mutex_enter(&cio->io_lock); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
392 |
mutex_enter(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
393 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
394 |
list_remove(&pio->io_child_list, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
395 |
list_remove(&cio->io_parent_list, zl); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
396 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
397 |
mutex_exit(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
398 |
mutex_exit(&cio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
399 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
400 |
kmem_cache_free(zio_link_cache, zl); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
401 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
402 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
403 |
static boolean_t |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
404 |
zio_wait_for_children(zio_t *zio, enum zio_child child, enum zio_wait_type wait) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
405 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
406 |
uint64_t *countp = &zio->io_children[child][wait]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
407 |
boolean_t waiting = B_FALSE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
408 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
409 |
mutex_enter(&zio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
410 |
ASSERT(zio->io_stall == NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
411 |
if (*countp != 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
412 |
zio->io_stage--; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
413 |
zio->io_stall = countp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
414 |
waiting = B_TRUE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
415 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
416 |
mutex_exit(&zio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
417 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
418 |
return (waiting); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
419 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
420 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
421 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
422 |
zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
423 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
424 |
uint64_t *countp = &pio->io_children[zio->io_child_type][wait]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
425 |
int *errorp = &pio->io_child_error[zio->io_child_type]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
426 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
427 |
mutex_enter(&pio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
428 |
if (zio->io_error && !(zio->io_flags & ZIO_FLAG_DONT_PROPAGATE)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
429 |
*errorp = zio_worst_error(*errorp, zio->io_error); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
430 |
pio->io_reexecute |= zio->io_reexecute; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
431 |
ASSERT3U(*countp, >, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
432 |
if (--*countp == 0 && pio->io_stall == countp) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
433 |
pio->io_stall = NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
434 |
mutex_exit(&pio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
435 |
zio_execute(pio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
436 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
437 |
mutex_exit(&pio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
438 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
439 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
440 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
441 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
442 |
zio_inherit_child_errors(zio_t *zio, enum zio_child c) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
443 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
444 |
if (zio->io_child_error[c] != 0 && zio->io_error == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
445 |
zio->io_error = zio->io_child_error[c]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
446 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
447 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
448 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
449 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
450 |
* Create the various types of I/O (read, write, free, etc) |
789 | 451 |
* ========================================================================== |
452 |
*/ |
|
453 |
static zio_t * |
|
454 |
zio_create(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, |
|
455 |
void *data, uint64_t size, zio_done_func_t *done, void *private, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
456 |
zio_type_t type, int priority, int flags, vdev_t *vd, uint64_t offset, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
457 |
const zbookmark_t *zb, uint8_t stage, uint32_t pipeline) |
789 | 458 |
{ |
459 |
zio_t *zio; |
|
460 |
||
461 |
ASSERT3U(size, <=, SPA_MAXBLOCKSIZE); |
|
462 |
ASSERT(P2PHASE(size, SPA_MINBLOCKSIZE) == 0); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
463 |
ASSERT(P2PHASE(offset, SPA_MINBLOCKSIZE) == 0); |
789 | 464 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
465 |
ASSERT(!vd || spa_config_held(spa, SCL_STATE_ALL, RW_READER)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
466 |
ASSERT(!bp || !(flags & ZIO_FLAG_CONFIG_WRITER)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
467 |
ASSERT(vd || stage == ZIO_STAGE_OPEN); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
7030
diff
changeset
|
468 |
|
4055 | 469 |
zio = kmem_cache_alloc(zio_cache, KM_SLEEP); |
470 |
bzero(zio, sizeof (zio_t)); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
471 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
472 |
mutex_init(&zio->io_lock, NULL, MUTEX_DEFAULT, NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
473 |
cv_init(&zio->io_cv, NULL, CV_DEFAULT, NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
474 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
475 |
list_create(&zio->io_parent_list, sizeof (zio_link_t), |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
476 |
offsetof(zio_link_t, zl_parent_node)); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
477 |
list_create(&zio->io_child_list, sizeof (zio_link_t), |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
478 |
offsetof(zio_link_t, zl_child_node)); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
479 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
480 |
if (vd != NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
481 |
zio->io_child_type = ZIO_CHILD_VDEV; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
482 |
else if (flags & ZIO_FLAG_GANG_CHILD) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
483 |
zio->io_child_type = ZIO_CHILD_GANG; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
484 |
else |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
485 |
zio->io_child_type = ZIO_CHILD_LOGICAL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
486 |
|
789 | 487 |
if (bp != NULL) { |
488 |
zio->io_bp = bp; |
|
489 |
zio->io_bp_copy = *bp; |
|
490 |
zio->io_bp_orig = *bp; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
491 |
if (type != ZIO_TYPE_WRITE) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
492 |
zio->io_bp = &zio->io_bp_copy; /* so caller can free */ |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
493 |
if (zio->io_child_type == ZIO_CHILD_LOGICAL) |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
494 |
zio->io_logical = zio; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
495 |
if (zio->io_child_type > ZIO_CHILD_GANG && BP_IS_GANG(bp)) |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
496 |
pipeline |= ZIO_GANG_STAGES; |
789 | 497 |
} |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
498 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
499 |
zio->io_spa = spa; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
500 |
zio->io_txg = txg; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
501 |
zio->io_data = data; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
502 |
zio->io_size = size; |
789 | 503 |
zio->io_done = done; |
504 |
zio->io_private = private; |
|
505 |
zio->io_type = type; |
|
506 |
zio->io_priority = priority; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
507 |
zio->io_vd = vd; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
508 |
zio->io_offset = offset; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
509 |
zio->io_orig_flags = zio->io_flags = flags; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
510 |
zio->io_orig_stage = zio->io_stage = stage; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
511 |
zio->io_orig_pipeline = zio->io_pipeline = pipeline; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
512 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
513 |
zio->io_state[ZIO_WAIT_READY] = (stage >= ZIO_STAGE_READY); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
514 |
zio->io_state[ZIO_WAIT_DONE] = (stage >= ZIO_STAGE_DONE); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
515 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
516 |
if (zb != NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
517 |
zio->io_bookmark = *zb; |
789 | 518 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
519 |
if (pio != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
520 |
if (zio->io_logical == NULL) |
1544 | 521 |
zio->io_logical = pio->io_logical; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
522 |
if (zio->io_child_type == ZIO_CHILD_GANG) |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
523 |
zio->io_gang_leader = pio->io_gang_leader; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
524 |
zio_add_child(pio, zio); |
789 | 525 |
} |
526 |
||
527 |
return (zio); |
|
528 |
} |
|
529 |
||
5329 | 530 |
static void |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
531 |
zio_destroy(zio_t *zio) |
5329 | 532 |
{ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
533 |
list_destroy(&zio->io_parent_list); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
534 |
list_destroy(&zio->io_child_list); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
535 |
mutex_destroy(&zio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
536 |
cv_destroy(&zio->io_cv); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
537 |
kmem_cache_free(zio_cache, zio); |
5329 | 538 |
} |
539 |
||
789 | 540 |
zio_t * |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
541 |
zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, zio_done_func_t *done, |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
542 |
void *private, int flags) |
789 | 543 |
{ |
544 |
zio_t *zio; |
|
545 |
||
546 |
zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, private, |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
547 |
ZIO_TYPE_NULL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
548 |
ZIO_STAGE_OPEN, ZIO_INTERLOCK_PIPELINE); |
789 | 549 |
|
550 |
return (zio); |
|
551 |
} |
|
552 |
||
553 |
zio_t * |
|
554 |
zio_root(spa_t *spa, zio_done_func_t *done, void *private, int flags) |
|
555 |
{ |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
556 |
return (zio_null(NULL, spa, NULL, done, private, flags)); |
789 | 557 |
} |
558 |
||
559 |
zio_t * |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
560 |
zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
561 |
void *data, uint64_t size, zio_done_func_t *done, void *private, |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
7030
diff
changeset
|
562 |
int priority, int flags, const zbookmark_t *zb) |
789 | 563 |
{ |
564 |
zio_t *zio; |
|
565 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
7030
diff
changeset
|
566 |
zio = zio_create(pio, spa, bp->blk_birth, (blkptr_t *)bp, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
7030
diff
changeset
|
567 |
data, size, done, private, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
568 |
ZIO_TYPE_READ, priority, flags, NULL, 0, zb, |
2981 | 569 |
ZIO_STAGE_OPEN, ZIO_READ_PIPELINE); |
789 | 570 |
|
571 |
return (zio); |
|
572 |
} |
|
573 |
||
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
574 |
void |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
575 |
zio_skip_write(zio_t *zio) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
576 |
{ |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
577 |
ASSERT(zio->io_type == ZIO_TYPE_WRITE); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
578 |
ASSERT(zio->io_stage == ZIO_STAGE_READY); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
579 |
ASSERT(!BP_IS_GANG(zio->io_bp)); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
580 |
|
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
581 |
zio->io_pipeline &= ~ZIO_VDEV_IO_STAGES; |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
582 |
} |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
583 |
|
789 | 584 |
zio_t * |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
585 |
zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
586 |
void *data, uint64_t size, zio_prop_t *zp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
587 |
zio_done_func_t *ready, zio_done_func_t *done, void *private, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
588 |
int priority, int flags, const zbookmark_t *zb) |
789 | 589 |
{ |
590 |
zio_t *zio; |
|
591 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
592 |
ASSERT(zp->zp_checksum >= ZIO_CHECKSUM_OFF && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
593 |
zp->zp_checksum < ZIO_CHECKSUM_FUNCTIONS && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
594 |
zp->zp_compress >= ZIO_COMPRESS_OFF && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
595 |
zp->zp_compress < ZIO_COMPRESS_FUNCTIONS && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
596 |
zp->zp_type < DMU_OT_NUMTYPES && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
597 |
zp->zp_level < 32 && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
598 |
zp->zp_ndvas > 0 && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
599 |
zp->zp_ndvas <= spa_max_replication(spa)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
600 |
ASSERT(ready != NULL); |
5329 | 601 |
|
789 | 602 |
zio = zio_create(pio, spa, txg, bp, data, size, done, private, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
603 |
ZIO_TYPE_WRITE, priority, flags, NULL, 0, zb, |
789 | 604 |
ZIO_STAGE_OPEN, ZIO_WRITE_PIPELINE); |
605 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3463
diff
changeset
|
606 |
zio->io_ready = ready; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
607 |
zio->io_prop = *zp; |
789 | 608 |
|
609 |
return (zio); |
|
610 |
} |
|
611 |
||
612 |
zio_t * |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
613 |
zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, void *data, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
614 |
uint64_t size, zio_done_func_t *done, void *private, int priority, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
615 |
int flags, zbookmark_t *zb) |
789 | 616 |
{ |
617 |
zio_t *zio; |
|
618 |
||
7181
8d299641aa23
6719934 assertion failed: ((&zh->zh_log)->blk_birth == 0), file: ../../common/fs/zfs/zil.c, line: 1336
perrin
parents:
7046
diff
changeset
|
619 |
zio = zio_create(pio, spa, txg, bp, data, size, done, private, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
620 |
ZIO_TYPE_WRITE, priority, flags, NULL, 0, zb, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
621 |
ZIO_STAGE_OPEN, ZIO_REWRITE_PIPELINE); |
789 | 622 |
|
623 |
return (zio); |
|
624 |
} |
|
625 |
||
626 |
zio_t * |
|
627 |
zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
628 |
zio_done_func_t *done, void *private, int flags) |
789 | 629 |
{ |
630 |
zio_t *zio; |
|
631 |
||
632 |
ASSERT(!BP_IS_HOLE(bp)); |
|
633 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
634 |
if (bp->blk_fill == BLK_FILL_ALREADY_FREED) |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
635 |
return (zio_null(pio, spa, NULL, NULL, NULL, flags)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
636 |
|
789 | 637 |
if (txg == spa->spa_syncing_txg && |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
638 |
spa_sync_pass(spa) > SYNC_PASS_DEFERRED_FREE) { |
789 | 639 |
bplist_enqueue_deferred(&spa->spa_sync_bplist, bp); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
640 |
return (zio_null(pio, spa, NULL, NULL, NULL, flags)); |
789 | 641 |
} |
642 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
643 |
zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
644 |
done, private, ZIO_TYPE_FREE, ZIO_PRIORITY_FREE, flags, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
645 |
NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_FREE_PIPELINE); |
789 | 646 |
|
647 |
return (zio); |
|
648 |
} |
|
649 |
||
650 |
zio_t * |
|
651 |
zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
652 |
zio_done_func_t *done, void *private, int flags) |
789 | 653 |
{ |
654 |
zio_t *zio; |
|
655 |
||
656 |
/* |
|
657 |
* A claim is an allocation of a specific block. Claims are needed |
|
658 |
* to support immediate writes in the intent log. The issue is that |
|
659 |
* immediate writes contain committed data, but in a txg that was |
|
660 |
* *not* committed. Upon opening the pool after an unclean shutdown, |
|
661 |
* the intent log claims all blocks that contain immediate write data |
|
662 |
* so that the SPA knows they're in use. |
|
663 |
* |
|
664 |
* All claims *must* be resolved in the first txg -- before the SPA |
|
665 |
* starts allocating blocks -- so that nothing is allocated twice. |
|
666 |
*/ |
|
667 |
ASSERT3U(spa->spa_uberblock.ub_rootbp.blk_birth, <, spa_first_txg(spa)); |
|
668 |
ASSERT3U(spa_first_txg(spa), <=, txg); |
|
669 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
670 |
zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
671 |
done, private, ZIO_TYPE_CLAIM, ZIO_PRIORITY_NOW, flags, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
672 |
NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_CLAIM_PIPELINE); |
789 | 673 |
|
674 |
return (zio); |
|
675 |
} |
|
676 |
||
677 |
zio_t * |
|
678 |
zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, |
|
679 |
zio_done_func_t *done, void *private, int priority, int flags) |
|
680 |
{ |
|
681 |
zio_t *zio; |
|
682 |
int c; |
|
683 |
||
684 |
if (vd->vdev_children == 0) { |
|
685 |
zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, private, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
686 |
ZIO_TYPE_IOCTL, priority, flags, vd, 0, NULL, |
789 | 687 |
ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE); |
688 |
||
689 |
zio->io_cmd = cmd; |
|
690 |
} else { |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
691 |
zio = zio_null(pio, spa, NULL, NULL, NULL, flags); |
789 | 692 |
|
693 |
for (c = 0; c < vd->vdev_children; c++) |
|
694 |
zio_nowait(zio_ioctl(zio, spa, vd->vdev_child[c], cmd, |
|
695 |
done, private, priority, flags)); |
|
696 |
} |
|
697 |
||
698 |
return (zio); |
|
699 |
} |
|
700 |
||
701 |
zio_t * |
|
702 |
zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size, |
|
703 |
void *data, int checksum, zio_done_func_t *done, void *private, |
|
5450 | 704 |
int priority, int flags, boolean_t labels) |
789 | 705 |
{ |
706 |
zio_t *zio; |
|
5329 | 707 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
708 |
ASSERT(vd->vdev_children == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
709 |
ASSERT(!labels || offset + size <= VDEV_LABEL_START_SIZE || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
710 |
offset >= vd->vdev_psize - VDEV_LABEL_END_SIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
711 |
ASSERT3U(offset + size, <=, vd->vdev_psize); |
789 | 712 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
713 |
zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done, private, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
714 |
ZIO_TYPE_READ, priority, flags, vd, offset, NULL, |
789 | 715 |
ZIO_STAGE_OPEN, ZIO_READ_PHYS_PIPELINE); |
716 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
717 |
zio->io_prop.zp_checksum = checksum; |
789 | 718 |
|
719 |
return (zio); |
|
720 |
} |
|
721 |
||
722 |
zio_t * |
|
723 |
zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size, |
|
724 |
void *data, int checksum, zio_done_func_t *done, void *private, |
|
5450 | 725 |
int priority, int flags, boolean_t labels) |
789 | 726 |
{ |
727 |
zio_t *zio; |
|
728 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
729 |
ASSERT(vd->vdev_children == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
730 |
ASSERT(!labels || offset + size <= VDEV_LABEL_START_SIZE || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
731 |
offset >= vd->vdev_psize - VDEV_LABEL_END_SIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
732 |
ASSERT3U(offset + size, <=, vd->vdev_psize); |
5329 | 733 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
734 |
zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done, private, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
735 |
ZIO_TYPE_WRITE, priority, flags, vd, offset, NULL, |
789 | 736 |
ZIO_STAGE_OPEN, ZIO_WRITE_PHYS_PIPELINE); |
737 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
738 |
zio->io_prop.zp_checksum = checksum; |
789 | 739 |
|
740 |
if (zio_checksum_table[checksum].ci_zbt) { |
|
741 |
/* |
|
742 |
* zbt checksums are necessarily destructive -- they modify |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
743 |
* the end of the write buffer to hold the verifier/checksum. |
789 | 744 |
* Therefore, we must make a local copy in case the data is |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
745 |
* being written to multiple places in parallel. |
789 | 746 |
*/ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
747 |
void *wbuf = zio_buf_alloc(size); |
789 | 748 |
bcopy(data, wbuf, size); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
749 |
zio_push_transform(zio, wbuf, size, size, NULL); |
789 | 750 |
} |
751 |
||
752 |
return (zio); |
|
753 |
} |
|
754 |
||
755 |
/* |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
756 |
* Create a child I/O to do some work for us. |
789 | 757 |
*/ |
758 |
zio_t * |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
759 |
zio_vdev_child_io(zio_t *pio, blkptr_t *bp, vdev_t *vd, uint64_t offset, |
789 | 760 |
void *data, uint64_t size, int type, int priority, int flags, |
761 |
zio_done_func_t *done, void *private) |
|
762 |
{ |
|
763 |
uint32_t pipeline = ZIO_VDEV_CHILD_PIPELINE; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
764 |
zio_t *zio; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
765 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
766 |
ASSERT(vd->vdev_parent == |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
767 |
(pio->io_vd ? pio->io_vd : pio->io_spa->spa_root_vdev)); |
789 | 768 |
|
769 |
if (type == ZIO_TYPE_READ && bp != NULL) { |
|
770 |
/* |
|
771 |
* If we have the bp, then the child should perform the |
|
772 |
* checksum and the parent need not. This pushes error |
|
773 |
* detection as close to the leaves as possible and |
|
774 |
* eliminates redundant checksums in the interior nodes. |
|
775 |
*/ |
|
776 |
pipeline |= 1U << ZIO_STAGE_CHECKSUM_VERIFY; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
777 |
pio->io_pipeline &= ~(1U << ZIO_STAGE_CHECKSUM_VERIFY); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
778 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
779 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
780 |
if (vd->vdev_children == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
781 |
offset += VDEV_LABEL_START_SIZE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
782 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
783 |
zio = zio_create(pio, pio->io_spa, pio->io_txg, bp, data, size, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
784 |
done, private, type, priority, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
785 |
(pio->io_flags & ZIO_FLAG_VDEV_INHERIT) | |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
786 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE | flags, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
787 |
vd, offset, &pio->io_bookmark, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
788 |
ZIO_STAGE_VDEV_IO_START - 1, pipeline); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
789 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
790 |
return (zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
791 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
792 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
793 |
zio_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
794 |
zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, void *data, uint64_t size, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
795 |
int type, int priority, int flags, zio_done_func_t *done, void *private) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
796 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
797 |
zio_t *zio; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
798 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
799 |
ASSERT(vd->vdev_ops->vdev_op_leaf); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
800 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
801 |
zio = zio_create(NULL, vd->vdev_spa, 0, NULL, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
802 |
data, size, done, private, type, priority, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
803 |
flags | ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_RETRY, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
804 |
vd, offset, NULL, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
805 |
ZIO_STAGE_VDEV_IO_START - 1, ZIO_VDEV_CHILD_PIPELINE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
806 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
807 |
return (zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
808 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
809 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
810 |
void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
811 |
zio_flush(zio_t *zio, vdev_t *vd) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
812 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
813 |
zio_nowait(zio_ioctl(zio, zio->io_spa, vd, DKIOCFLUSHWRITECACHE, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
814 |
NULL, NULL, ZIO_PRIORITY_NOW, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
815 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
816 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
817 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
818 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
819 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
820 |
* Prepare to read and write logical blocks |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
821 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
822 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
823 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
824 |
static int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
825 |
zio_read_bp_init(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
826 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
827 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
828 |
|
8274
846b39508aff
6713916 scrub/resilver needlessly decompress data
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
8241
diff
changeset
|
829 |
if (BP_GET_COMPRESS(bp) != ZIO_COMPRESS_OFF && |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
830 |
zio->io_child_type == ZIO_CHILD_LOGICAL && |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
831 |
!(zio->io_flags & ZIO_FLAG_RAW)) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
832 |
uint64_t csize = BP_GET_PSIZE(bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
833 |
void *cbuf = zio_buf_alloc(csize); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
834 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
835 |
zio_push_transform(zio, cbuf, csize, csize, zio_decompress); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
836 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
837 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
838 |
if (!dmu_ot[BP_GET_TYPE(bp)].ot_metadata && BP_GET_LEVEL(bp) == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
839 |
zio->io_flags |= ZIO_FLAG_DONT_CACHE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
840 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
841 |
return (ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
842 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
843 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
844 |
static int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
845 |
zio_write_bp_init(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
846 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
847 |
zio_prop_t *zp = &zio->io_prop; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
848 |
int compress = zp->zp_compress; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
849 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
850 |
void *cbuf; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
851 |
uint64_t lsize = zio->io_size; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
852 |
uint64_t csize = lsize; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
853 |
uint64_t cbufsize = 0; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
854 |
int pass = 1; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
855 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
856 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
857 |
* If our children haven't all reached the ready stage, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
858 |
* wait for them and then repeat this pipeline stage. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
859 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
860 |
if (zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_READY) || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
861 |
zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_READY)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
862 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
863 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
864 |
if (!IO_IS_ALLOCATING(zio)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
865 |
return (ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
866 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
867 |
ASSERT(compress != ZIO_COMPRESS_INHERIT); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
868 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
869 |
if (bp->blk_birth == zio->io_txg) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
870 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
871 |
* We're rewriting an existing block, which means we're |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
872 |
* working on behalf of spa_sync(). For spa_sync() to |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
873 |
* converge, it must eventually be the case that we don't |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
874 |
* have to allocate new blocks. But compression changes |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
875 |
* the blocksize, which forces a reallocate, and makes |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
876 |
* convergence take longer. Therefore, after the first |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
877 |
* few passes, stop compressing to ensure convergence. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
878 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
879 |
pass = spa_sync_pass(zio->io_spa); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
880 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
881 |
if (pass > SYNC_PASS_DONT_COMPRESS) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
882 |
compress = ZIO_COMPRESS_OFF; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
883 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
884 |
/* Make sure someone doesn't change their mind on overwrites */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
885 |
ASSERT(MIN(zp->zp_ndvas + BP_IS_GANG(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
886 |
spa_max_replication(zio->io_spa)) == BP_GET_NDVAS(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
887 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
888 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
889 |
if (compress != ZIO_COMPRESS_OFF) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
890 |
if (!zio_compress_data(compress, zio->io_data, zio->io_size, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
891 |
&cbuf, &csize, &cbufsize)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
892 |
compress = ZIO_COMPRESS_OFF; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
893 |
} else if (csize != 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
894 |
zio_push_transform(zio, cbuf, csize, cbufsize, NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
895 |
} |
789 | 896 |
} |
897 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
898 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
899 |
* The final pass of spa_sync() must be all rewrites, but the first |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
900 |
* few passes offer a trade-off: allocating blocks defers convergence, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
901 |
* but newly allocated blocks are sequential, so they can be written |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
902 |
* to disk faster. Therefore, we allow the first few passes of |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
903 |
* spa_sync() to allocate new blocks, but force rewrites after that. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
904 |
* There should only be a handful of blocks after pass 1 in any case. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
905 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
906 |
if (bp->blk_birth == zio->io_txg && BP_GET_PSIZE(bp) == csize && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
907 |
pass > SYNC_PASS_REWRITE) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
908 |
ASSERT(csize != 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
909 |
uint32_t gang_stages = zio->io_pipeline & ZIO_GANG_STAGES; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
910 |
zio->io_pipeline = ZIO_REWRITE_PIPELINE | gang_stages; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
911 |
zio->io_flags |= ZIO_FLAG_IO_REWRITE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
912 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
913 |
BP_ZERO(bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
914 |
zio->io_pipeline = ZIO_WRITE_PIPELINE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
915 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
916 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
917 |
if (csize == 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
918 |
zio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
919 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
920 |
ASSERT(zp->zp_checksum != ZIO_CHECKSUM_GANG_HEADER); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
921 |
BP_SET_LSIZE(bp, lsize); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
922 |
BP_SET_PSIZE(bp, csize); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
923 |
BP_SET_COMPRESS(bp, compress); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
924 |
BP_SET_CHECKSUM(bp, zp->zp_checksum); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
925 |
BP_SET_TYPE(bp, zp->zp_type); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
926 |
BP_SET_LEVEL(bp, zp->zp_level); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
927 |
BP_SET_BYTEORDER(bp, ZFS_HOST_BYTEORDER); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
928 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
929 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
930 |
return (ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
931 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
932 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
933 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
934 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
935 |
* Execute the I/O pipeline |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
936 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
937 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
938 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
939 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
940 |
zio_taskq_dispatch(zio_t *zio, enum zio_taskq_type q) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
941 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
942 |
zio_type_t t = zio->io_type; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
943 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
944 |
/* |
9722
e3866bad4e96
6844069 vdev_probe() starvation brings txg train to a screeching halt
George Wilson <George.Wilson@Sun.COM>
parents:
9470
diff
changeset
|
945 |
* If we're a config writer or a probe, the normal issue and |
e3866bad4e96
6844069 vdev_probe() starvation brings txg train to a screeching halt
George Wilson <George.Wilson@Sun.COM>
parents:
9470
diff
changeset
|
946 |
* interrupt threads may all be blocked waiting for the config lock. |
e3866bad4e96
6844069 vdev_probe() starvation brings txg train to a screeching halt
George Wilson <George.Wilson@Sun.COM>
parents:
9470
diff
changeset
|
947 |
* In this case, select the otherwise-unused taskq for ZIO_TYPE_NULL. |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
948 |
*/ |
9722
e3866bad4e96
6844069 vdev_probe() starvation brings txg train to a screeching halt
George Wilson <George.Wilson@Sun.COM>
parents:
9470
diff
changeset
|
949 |
if (zio->io_flags & (ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_PROBE)) |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
950 |
t = ZIO_TYPE_NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
951 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
952 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
953 |
* A similar issue exists for the L2ARC write thread until L2ARC 2.0. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
954 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
955 |
if (t == ZIO_TYPE_WRITE && zio->io_vd && zio->io_vd->vdev_aux) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
956 |
t = ZIO_TYPE_NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
957 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
958 |
(void) taskq_dispatch(zio->io_spa->spa_zio_taskq[t][q], |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
959 |
(task_func_t *)zio_execute, zio, TQ_SLEEP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
960 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
961 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
962 |
static boolean_t |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
963 |
zio_taskq_member(zio_t *zio, enum zio_taskq_type q) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
964 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
965 |
kthread_t *executor = zio->io_executor; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
966 |
spa_t *spa = zio->io_spa; |
789 | 967 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
968 |
for (zio_type_t t = 0; t < ZIO_TYPES; t++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
969 |
if (taskq_member(spa->spa_zio_taskq[t][q], executor)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
970 |
return (B_TRUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
971 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
972 |
return (B_FALSE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
973 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
974 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
975 |
static int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
976 |
zio_issue_async(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
977 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
978 |
zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
979 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
980 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
981 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
982 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
983 |
void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
984 |
zio_interrupt(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
985 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
986 |
zio_taskq_dispatch(zio, ZIO_TASKQ_INTERRUPT); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
987 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
988 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
989 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
990 |
* Execute the I/O pipeline until one of the following occurs: |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
991 |
* (1) the I/O completes; (2) the pipeline stalls waiting for |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
992 |
* dependent child I/Os; (3) the I/O issues, so we're waiting |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
993 |
* for an I/O completion interrupt; (4) the I/O is delegated by |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
994 |
* vdev-level caching or aggregation; (5) the I/O is deferred |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
995 |
* due to vdev-level queueing; (6) the I/O is handed off to |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
996 |
* another thread. In all cases, the pipeline stops whenever |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
997 |
* there's no CPU work; it never burns a thread in cv_wait(). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
998 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
999 |
* There's no locking on io_stage because there's no legitimate way |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1000 |
* for multiple threads to be attempting to process the same I/O. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1001 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1002 |
static zio_pipe_stage_t *zio_pipeline[ZIO_STAGES]; |
789 | 1003 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1004 |
void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1005 |
zio_execute(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1006 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1007 |
zio->io_executor = curthread; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1008 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1009 |
while (zio->io_stage < ZIO_STAGE_DONE) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1010 |
uint32_t pipeline = zio->io_pipeline; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1011 |
zio_stage_t stage = zio->io_stage; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1012 |
int rv; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1013 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1014 |
ASSERT(!MUTEX_HELD(&zio->io_lock)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1015 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1016 |
while (((1U << ++stage) & pipeline) == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1017 |
continue; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1018 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1019 |
ASSERT(stage <= ZIO_STAGE_DONE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1020 |
ASSERT(zio->io_stall == NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1021 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1022 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1023 |
* If we are in interrupt context and this pipeline stage |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1024 |
* will grab a config lock that is held across I/O, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1025 |
* issue async to avoid deadlock. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1026 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1027 |
if (((1U << stage) & ZIO_CONFIG_LOCK_BLOCKING_STAGES) && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1028 |
zio->io_vd == NULL && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1029 |
zio_taskq_member(zio, ZIO_TASKQ_INTERRUPT)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1030 |
zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1031 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1032 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1033 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1034 |
zio->io_stage = stage; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1035 |
rv = zio_pipeline[stage](zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1036 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1037 |
if (rv == ZIO_PIPELINE_STOP) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1038 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1039 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1040 |
ASSERT(rv == ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1041 |
} |
789 | 1042 |
} |
1043 |
||
1044 |
/* |
|
1045 |
* ========================================================================== |
|
1046 |
* Initiate I/O, either sync or async |
|
1047 |
* ========================================================================== |
|
1048 |
*/ |
|
1049 |
int |
|
1050 |
zio_wait(zio_t *zio) |
|
1051 |
{ |
|
1052 |
int error; |
|
1053 |
||
1054 |
ASSERT(zio->io_stage == ZIO_STAGE_OPEN); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1055 |
ASSERT(zio->io_executor == NULL); |
789 | 1056 |
|
1057 |
zio->io_waiter = curthread; |
|
1058 |
||
5530 | 1059 |
zio_execute(zio); |
789 | 1060 |
|
1061 |
mutex_enter(&zio->io_lock); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1062 |
while (zio->io_executor != NULL) |
789 | 1063 |
cv_wait(&zio->io_cv, &zio->io_lock); |
1064 |
mutex_exit(&zio->io_lock); |
|
1065 |
||
1066 |
error = zio->io_error; |
|
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1067 |
zio_destroy(zio); |
789 | 1068 |
|
1069 |
return (error); |
|
1070 |
} |
|
1071 |
||
1072 |
void |
|
1073 |
zio_nowait(zio_t *zio) |
|
1074 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1075 |
ASSERT(zio->io_executor == NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1076 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1077 |
if (zio->io_child_type == ZIO_CHILD_LOGICAL && |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1078 |
zio_unique_parent(zio) == NULL) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1079 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1080 |
* This is a logical async I/O with no parent to wait for it. |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1081 |
* We add it to the spa_async_root_zio "Godfather" I/O which |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1082 |
* will ensure they complete prior to unloading the pool. |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1083 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1084 |
spa_t *spa = zio->io_spa; |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1085 |
|
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1086 |
zio_add_child(spa->spa_async_zio_root, zio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1087 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1088 |
|
5530 | 1089 |
zio_execute(zio); |
1090 |
} |
|
1091 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1092 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1093 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1094 |
* Reexecute or suspend/resume failed I/O |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1095 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1096 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1097 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1098 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1099 |
zio_reexecute(zio_t *pio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1100 |
{ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1101 |
zio_t *cio, *cio_next; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1102 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1103 |
ASSERT(pio->io_child_type == ZIO_CHILD_LOGICAL); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1104 |
ASSERT(pio->io_orig_stage == ZIO_STAGE_OPEN); |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1105 |
ASSERT(pio->io_gang_leader == NULL); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1106 |
ASSERT(pio->io_gang_tree == NULL); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1107 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1108 |
pio->io_flags = pio->io_orig_flags; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1109 |
pio->io_stage = pio->io_orig_stage; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1110 |
pio->io_pipeline = pio->io_orig_pipeline; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1111 |
pio->io_reexecute = 0; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1112 |
pio->io_error = 0; |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1113 |
for (int w = 0; w < ZIO_WAIT_TYPES; w++) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1114 |
pio->io_state[w] = 0; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1115 |
for (int c = 0; c < ZIO_CHILD_TYPES; c++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1116 |
pio->io_child_error[c] = 0; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1117 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1118 |
if (IO_IS_ALLOCATING(pio)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1119 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1120 |
* Remember the failed bp so that the io_ready() callback |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1121 |
* can update its accounting upon reexecution. The block |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1122 |
* was already freed in zio_done(); we indicate this with |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1123 |
* a fill count of -1 so that zio_free() knows to skip it. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1124 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1125 |
blkptr_t *bp = pio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1126 |
ASSERT(bp->blk_birth == 0 || bp->blk_birth == pio->io_txg); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1127 |
bp->blk_fill = BLK_FILL_ALREADY_FREED; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1128 |
pio->io_bp_orig = *bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1129 |
BP_ZERO(bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1130 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1131 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1132 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1133 |
* As we reexecute pio's children, new children could be created. |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1134 |
* New children go to the head of pio's io_child_list, however, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1135 |
* so we will (correctly) not reexecute them. The key is that |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1136 |
* the remainder of pio's io_child_list, from 'cio_next' onward, |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1137 |
* cannot be affected by any side effects of reexecuting 'cio'. |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1138 |
*/ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1139 |
for (cio = zio_walk_children(pio); cio != NULL; cio = cio_next) { |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1140 |
cio_next = zio_walk_children(pio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1141 |
mutex_enter(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1142 |
for (int w = 0; w < ZIO_WAIT_TYPES; w++) |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1143 |
pio->io_children[cio->io_child_type][w]++; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1144 |
mutex_exit(&pio->io_lock); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1145 |
zio_reexecute(cio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1146 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1147 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1148 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1149 |
* Now that all children have been reexecuted, execute the parent. |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1150 |
* We don't reexecute "The Godfather" I/O here as it's the |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1151 |
* responsibility of the caller to wait on him. |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1152 |
*/ |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1153 |
if (!(pio->io_flags & ZIO_FLAG_GODFATHER)) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1154 |
zio_execute(pio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1155 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1156 |
|
5530 | 1157 |
void |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1158 |
zio_suspend(spa_t *spa, zio_t *zio) |
5530 | 1159 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1160 |
if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_PANIC) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1161 |
fm_panic("Pool '%s' has encountered an uncorrectable I/O " |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1162 |
"failure and the failure mode property for this pool " |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1163 |
"is set to panic.", spa_name(spa)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1164 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1165 |
zfs_ereport_post(FM_EREPORT_ZFS_IO_FAILURE, spa, NULL, NULL, 0, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1166 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1167 |
mutex_enter(&spa->spa_suspend_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1168 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1169 |
if (spa->spa_suspend_zio_root == NULL) |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1170 |
spa->spa_suspend_zio_root = zio_root(spa, NULL, NULL, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1171 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1172 |
ZIO_FLAG_GODFATHER); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1173 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1174 |
spa->spa_suspended = B_TRUE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1175 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1176 |
if (zio != NULL) { |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1177 |
ASSERT(!(zio->io_flags & ZIO_FLAG_GODFATHER)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1178 |
ASSERT(zio != spa->spa_suspend_zio_root); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1179 |
ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1180 |
ASSERT(zio_unique_parent(zio) == NULL); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1181 |
ASSERT(zio->io_stage == ZIO_STAGE_DONE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1182 |
zio_add_child(spa->spa_suspend_zio_root, zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1183 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1184 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1185 |
mutex_exit(&spa->spa_suspend_lock); |
5530 | 1186 |
} |
1187 |
||
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1188 |
int |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1189 |
zio_resume(spa_t *spa) |
5530 | 1190 |
{ |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1191 |
zio_t *pio; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1192 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1193 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1194 |
* Reexecute all previously suspended i/o. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1195 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1196 |
mutex_enter(&spa->spa_suspend_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1197 |
spa->spa_suspended = B_FALSE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1198 |
cv_broadcast(&spa->spa_suspend_cv); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1199 |
pio = spa->spa_suspend_zio_root; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1200 |
spa->spa_suspend_zio_root = NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1201 |
mutex_exit(&spa->spa_suspend_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1202 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1203 |
if (pio == NULL) |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1204 |
return (0); |
5530 | 1205 |
|
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1206 |
zio_reexecute(pio); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
1207 |
return (zio_wait(pio)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1208 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1209 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1210 |
void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1211 |
zio_resume_wait(spa_t *spa) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1212 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1213 |
mutex_enter(&spa->spa_suspend_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1214 |
while (spa_suspended(spa)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1215 |
cv_wait(&spa->spa_suspend_cv, &spa->spa_suspend_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1216 |
mutex_exit(&spa->spa_suspend_lock); |
789 | 1217 |
} |
1218 |
||
1219 |
/* |
|
1220 |
* ========================================================================== |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1221 |
* Gang blocks. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1222 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1223 |
* A gang block is a collection of small blocks that looks to the DMU |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1224 |
* like one large block. When zio_dva_allocate() cannot find a block |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1225 |
* of the requested size, due to either severe fragmentation or the pool |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1226 |
* being nearly full, it calls zio_write_gang_block() to construct the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1227 |
* block from smaller fragments. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1228 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1229 |
* A gang block consists of a gang header (zio_gbh_phys_t) and up to |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1230 |
* three (SPA_GBH_NBLKPTRS) gang members. The gang header is just like |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1231 |
* an indirect block: it's an array of block pointers. It consumes |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1232 |
* only one sector and hence is allocatable regardless of fragmentation. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1233 |
* The gang header's bps point to its gang members, which hold the data. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1234 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1235 |
* Gang blocks are self-checksumming, using the bp's <vdev, offset, txg> |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1236 |
* as the verifier to ensure uniqueness of the SHA256 checksum. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1237 |
* Critically, the gang block bp's blk_cksum is the checksum of the data, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1238 |
* not the gang header. This ensures that data block signatures (needed for |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1239 |
* deduplication) are independent of how the block is physically stored. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1240 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1241 |
* Gang blocks can be nested: a gang member may itself be a gang block. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1242 |
* Thus every gang block is a tree in which root and all interior nodes are |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1243 |
* gang headers, and the leaves are normal blocks that contain user data. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1244 |
* The root of the gang tree is called the gang leader. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1245 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1246 |
* To perform any operation (read, rewrite, free, claim) on a gang block, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1247 |
* zio_gang_assemble() first assembles the gang tree (minus data leaves) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1248 |
* in the io_gang_tree field of the original logical i/o by recursively |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1249 |
* reading the gang leader and all gang headers below it. This yields |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1250 |
* an in-core tree containing the contents of every gang header and the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1251 |
* bps for every constituent of the gang block. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1252 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1253 |
* With the gang tree now assembled, zio_gang_issue() just walks the gang tree |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1254 |
* and invokes a callback on each bp. To free a gang block, zio_gang_issue() |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1255 |
* calls zio_free_gang() -- a trivial wrapper around zio_free() -- for each bp. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1256 |
* zio_claim_gang() provides a similarly trivial wrapper for zio_claim(). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1257 |
* zio_read_gang() is a wrapper around zio_read() that omits reading gang |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1258 |
* headers, since we already have those in io_gang_tree. zio_rewrite_gang() |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1259 |
* performs a zio_rewrite() of the data or, for gang headers, a zio_rewrite() |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1260 |
* of the gang header plus zio_checksum_compute() of the data to update the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1261 |
* gang header's blk_cksum as described above. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1262 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1263 |
* The two-phase assemble/issue model solves the problem of partial failure -- |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1264 |
* what if you'd freed part of a gang block but then couldn't read the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1265 |
* gang header for another part? Assembling the entire gang tree first |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1266 |
* ensures that all the necessary gang header I/O has succeeded before |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1267 |
* starting the actual work of free, claim, or write. Once the gang tree |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1268 |
* is assembled, free and claim are in-memory operations that cannot fail. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1269 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1270 |
* In the event that a gang write fails, zio_dva_unallocate() walks the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1271 |
* gang tree to immediately free (i.e. insert back into the space map) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1272 |
* everything we've allocated. This ensures that we don't get ENOSPC |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1273 |
* errors during repeated suspend/resume cycles due to a flaky device. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1274 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1275 |
* Gang rewrites only happen during sync-to-convergence. If we can't assemble |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1276 |
* the gang tree, we won't modify the block, so we can safely defer the free |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1277 |
* (knowing that the block is still intact). If we *can* assemble the gang |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1278 |
* tree, then even if some of the rewrites fail, zio_dva_unallocate() will free |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1279 |
* each constituent bp and we can allocate a new block on the next sync pass. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1280 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1281 |
* In all cases, the gang tree allows complete recovery from partial failure. |
789 | 1282 |
* ========================================================================== |
1283 |
*/ |
|
5530 | 1284 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1285 |
static zio_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1286 |
zio_read_gang(zio_t *pio, blkptr_t *bp, zio_gang_node_t *gn, void *data) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1287 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1288 |
if (gn != NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1289 |
return (pio); |
5530 | 1290 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1291 |
return (zio_read(pio, pio->io_spa, bp, data, BP_GET_PSIZE(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1292 |
NULL, NULL, pio->io_priority, ZIO_GANG_CHILD_FLAGS(pio), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1293 |
&pio->io_bookmark)); |
789 | 1294 |
} |
1295 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1296 |
zio_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1297 |
zio_rewrite_gang(zio_t *pio, blkptr_t *bp, zio_gang_node_t *gn, void *data) |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1298 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1299 |
zio_t *zio; |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1300 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1301 |
if (gn != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1302 |
zio = zio_rewrite(pio, pio->io_spa, pio->io_txg, bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1303 |
gn->gn_gbh, SPA_GANGBLOCKSIZE, NULL, NULL, pio->io_priority, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1304 |
ZIO_GANG_CHILD_FLAGS(pio), &pio->io_bookmark); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1305 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1306 |
* As we rewrite each gang header, the pipeline will compute |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1307 |
* a new gang block header checksum for it; but no one will |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1308 |
* compute a new data checksum, so we do that here. The one |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1309 |
* exception is the gang leader: the pipeline already computed |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1310 |
* its data checksum because that stage precedes gang assembly. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1311 |
* (Presently, nothing actually uses interior data checksums; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1312 |
* this is just good hygiene.) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1313 |
*/ |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1314 |
if (gn != pio->io_gang_leader->io_gang_tree) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1315 |
zio_checksum_compute(zio, BP_GET_CHECKSUM(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1316 |
data, BP_GET_PSIZE(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1317 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1318 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1319 |
zio = zio_rewrite(pio, pio->io_spa, pio->io_txg, bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1320 |
data, BP_GET_PSIZE(bp), NULL, NULL, pio->io_priority, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1321 |
ZIO_GANG_CHILD_FLAGS(pio), &pio->io_bookmark); |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1322 |
} |
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1323 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1324 |
return (zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1325 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1326 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1327 |
/* ARGSUSED */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1328 |
zio_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1329 |
zio_free_gang(zio_t *pio, blkptr_t *bp, zio_gang_node_t *gn, void *data) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1330 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1331 |
return (zio_free(pio, pio->io_spa, pio->io_txg, bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1332 |
NULL, NULL, ZIO_GANG_CHILD_FLAGS(pio))); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1333 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1334 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1335 |
/* ARGSUSED */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1336 |
zio_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1337 |
zio_claim_gang(zio_t *pio, blkptr_t *bp, zio_gang_node_t *gn, void *data) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1338 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1339 |
return (zio_claim(pio, pio->io_spa, pio->io_txg, bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1340 |
NULL, NULL, ZIO_GANG_CHILD_FLAGS(pio))); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1341 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1342 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1343 |
static zio_gang_issue_func_t *zio_gang_issue_func[ZIO_TYPES] = { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1344 |
NULL, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1345 |
zio_read_gang, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1346 |
zio_rewrite_gang, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1347 |
zio_free_gang, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1348 |
zio_claim_gang, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1349 |
NULL |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1350 |
}; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1351 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1352 |
static void zio_gang_tree_assemble_done(zio_t *zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1353 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1354 |
static zio_gang_node_t * |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1355 |
zio_gang_node_alloc(zio_gang_node_t **gnpp) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1356 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1357 |
zio_gang_node_t *gn; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1358 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1359 |
ASSERT(*gnpp == NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1360 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1361 |
gn = kmem_zalloc(sizeof (*gn), KM_SLEEP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1362 |
gn->gn_gbh = zio_buf_alloc(SPA_GANGBLOCKSIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1363 |
*gnpp = gn; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1364 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1365 |
return (gn); |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1366 |
} |
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1367 |
|
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1368 |
static void |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1369 |
zio_gang_node_free(zio_gang_node_t **gnpp) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1370 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1371 |
zio_gang_node_t *gn = *gnpp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1372 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1373 |
for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1374 |
ASSERT(gn->gn_child[g] == NULL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1375 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1376 |
zio_buf_free(gn->gn_gbh, SPA_GANGBLOCKSIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1377 |
kmem_free(gn, sizeof (*gn)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1378 |
*gnpp = NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1379 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1380 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1381 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1382 |
zio_gang_tree_free(zio_gang_node_t **gnpp) |
789 | 1383 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1384 |
zio_gang_node_t *gn = *gnpp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1385 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1386 |
if (gn == NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1387 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1388 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1389 |
for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1390 |
zio_gang_tree_free(&gn->gn_child[g]); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1391 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1392 |
zio_gang_node_free(gnpp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1393 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1394 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1395 |
static void |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1396 |
zio_gang_tree_assemble(zio_t *gio, blkptr_t *bp, zio_gang_node_t **gnpp) |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1397 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1398 |
zio_gang_node_t *gn = zio_gang_node_alloc(gnpp); |
789 | 1399 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1400 |
ASSERT(gio->io_gang_leader == gio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1401 |
ASSERT(BP_IS_GANG(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1402 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1403 |
zio_nowait(zio_read(gio, gio->io_spa, bp, gn->gn_gbh, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1404 |
SPA_GANGBLOCKSIZE, zio_gang_tree_assemble_done, gn, |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1405 |
gio->io_priority, ZIO_GANG_CHILD_FLAGS(gio), &gio->io_bookmark)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1406 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1407 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1408 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1409 |
zio_gang_tree_assemble_done(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1410 |
{ |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1411 |
zio_t *gio = zio->io_gang_leader; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1412 |
zio_gang_node_t *gn = zio->io_private; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1413 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1414 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1415 |
ASSERT(gio == zio_unique_parent(zio)); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1416 |
ASSERT(zio_walk_children(zio) == NULL); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1417 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1418 |
if (zio->io_error) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1419 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1420 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1421 |
if (BP_SHOULD_BYTESWAP(bp)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1422 |
byteswap_uint64_array(zio->io_data, zio->io_size); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1423 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1424 |
ASSERT(zio->io_data == gn->gn_gbh); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1425 |
ASSERT(zio->io_size == SPA_GANGBLOCKSIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1426 |
ASSERT(gn->gn_gbh->zg_tail.zbt_magic == ZBT_MAGIC); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1427 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1428 |
for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1429 |
blkptr_t *gbp = &gn->gn_gbh->zg_blkptr[g]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1430 |
if (!BP_IS_GANG(gbp)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1431 |
continue; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1432 |
zio_gang_tree_assemble(gio, gbp, &gn->gn_child[g]); |
789 | 1433 |
} |
1434 |
} |
|
1435 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1436 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1437 |
zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, void *data) |
789 | 1438 |
{ |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1439 |
zio_t *gio = pio->io_gang_leader; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1440 |
zio_t *zio; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1441 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1442 |
ASSERT(BP_IS_GANG(bp) == !!gn); |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1443 |
ASSERT(BP_GET_CHECKSUM(bp) == BP_GET_CHECKSUM(gio->io_bp)); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1444 |
ASSERT(BP_GET_LSIZE(bp) == BP_GET_PSIZE(bp) || gn == gio->io_gang_tree); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1445 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1446 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1447 |
* If you're a gang header, your data is in gn->gn_gbh. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1448 |
* If you're a gang member, your data is in 'data' and gn == NULL. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1449 |
*/ |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1450 |
zio = zio_gang_issue_func[gio->io_type](pio, bp, gn, data); |
789 | 1451 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1452 |
if (gn != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1453 |
ASSERT(gn->gn_gbh->zg_tail.zbt_magic == ZBT_MAGIC); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1454 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1455 |
for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1456 |
blkptr_t *gbp = &gn->gn_gbh->zg_blkptr[g]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1457 |
if (BP_IS_HOLE(gbp)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1458 |
continue; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1459 |
zio_gang_tree_issue(zio, gn->gn_child[g], gbp, data); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1460 |
data = (char *)data + BP_GET_PSIZE(gbp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1461 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1462 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1463 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1464 |
if (gn == gio->io_gang_tree) |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1465 |
ASSERT3P((char *)gio->io_data + gio->io_size, ==, data); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1466 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1467 |
if (zio != pio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1468 |
zio_nowait(zio); |
789 | 1469 |
} |
1470 |
||
5530 | 1471 |
static int |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1472 |
zio_gang_assemble(zio_t *zio) |
5329 | 1473 |
{ |
5530 | 1474 |
blkptr_t *bp = zio->io_bp; |
1475 |
||
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1476 |
ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == NULL); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1477 |
ASSERT(zio->io_child_type > ZIO_CHILD_GANG); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1478 |
|
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1479 |
zio->io_gang_leader = zio; |
5530 | 1480 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1481 |
zio_gang_tree_assemble(zio, bp, &zio->io_gang_tree); |
789 | 1482 |
|
5530 | 1483 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1484 |
} |
1485 |
||
5530 | 1486 |
static int |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1487 |
zio_gang_issue(zio_t *zio) |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1488 |
{ |
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
6245
diff
changeset
|
1489 |
blkptr_t *bp = zio->io_bp; |
789 | 1490 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1491 |
if (zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_DONE)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1492 |
return (ZIO_PIPELINE_STOP); |
5329 | 1493 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1494 |
ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == zio); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1495 |
ASSERT(zio->io_child_type > ZIO_CHILD_GANG); |
789 | 1496 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1497 |
if (zio->io_child_error[ZIO_CHILD_GANG] == 0) |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1498 |
zio_gang_tree_issue(zio, zio->io_gang_tree, bp, zio->io_data); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1499 |
else |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1500 |
zio_gang_tree_free(&zio->io_gang_tree); |
789 | 1501 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1502 |
zio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
5530 | 1503 |
|
1504 |
return (ZIO_PIPELINE_CONTINUE); |
|
789 | 1505 |
} |
1506 |
||
1507 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1508 |
zio_write_gang_member_ready(zio_t *zio) |
789 | 1509 |
{ |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1510 |
zio_t *pio = zio_unique_parent(zio); |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1511 |
zio_t *gio = zio->io_gang_leader; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1512 |
dva_t *cdva = zio->io_bp->blk_dva; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1513 |
dva_t *pdva = pio->io_bp->blk_dva; |
789 | 1514 |
uint64_t asize; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1515 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1516 |
if (BP_IS_HOLE(zio->io_bp)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1517 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1518 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1519 |
ASSERT(BP_IS_HOLE(&zio->io_bp_orig)); |
789 | 1520 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1521 |
ASSERT(zio->io_child_type == ZIO_CHILD_GANG); |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1522 |
ASSERT3U(zio->io_prop.zp_ndvas, ==, gio->io_prop.zp_ndvas); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1523 |
ASSERT3U(zio->io_prop.zp_ndvas, <=, BP_GET_NDVAS(zio->io_bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1524 |
ASSERT3U(pio->io_prop.zp_ndvas, <=, BP_GET_NDVAS(pio->io_bp)); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1525 |
ASSERT3U(BP_GET_NDVAS(zio->io_bp), <=, BP_GET_NDVAS(pio->io_bp)); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1526 |
|
789 | 1527 |
mutex_enter(&pio->io_lock); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1528 |
for (int d = 0; d < BP_GET_NDVAS(zio->io_bp); d++) { |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1529 |
ASSERT(DVA_GET_GANG(&pdva[d])); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1530 |
asize = DVA_GET_ASIZE(&pdva[d]); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1531 |
asize += DVA_GET_ASIZE(&cdva[d]); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1532 |
DVA_SET_ASIZE(&pdva[d], asize); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1533 |
} |
789 | 1534 |
mutex_exit(&pio->io_lock); |
1535 |
} |
|
1536 |
||
5329 | 1537 |
static int |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1538 |
zio_write_gang_block(zio_t *pio) |
789 | 1539 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1540 |
spa_t *spa = pio->io_spa; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1541 |
blkptr_t *bp = pio->io_bp; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1542 |
zio_t *gio = pio->io_gang_leader; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1543 |
zio_t *zio; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1544 |
zio_gang_node_t *gn, **gnpp; |
789 | 1545 |
zio_gbh_phys_t *gbh; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1546 |
uint64_t txg = pio->io_txg; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1547 |
uint64_t resid = pio->io_size; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1548 |
uint64_t lsize; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1549 |
int ndvas = gio->io_prop.zp_ndvas; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1550 |
int gbh_ndvas = MIN(ndvas + 1, spa_max_replication(spa)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1551 |
zio_prop_t zp; |
789 | 1552 |
int error; |
1553 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1554 |
error = metaslab_alloc(spa, spa->spa_normal_class, SPA_GANGBLOCKSIZE, |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1555 |
bp, gbh_ndvas, txg, pio == gio ? NULL : gio->io_bp, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1556 |
METASLAB_HINTBP_FAVOR | METASLAB_GANG_HEADER); |
5530 | 1557 |
if (error) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1558 |
pio->io_error = error; |
5530 | 1559 |
return (ZIO_PIPELINE_CONTINUE); |
1560 |
} |
|
789 | 1561 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1562 |
if (pio == gio) { |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1563 |
gnpp = &gio->io_gang_tree; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1564 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1565 |
gnpp = pio->io_private; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1566 |
ASSERT(pio->io_ready == zio_write_gang_member_ready); |
789 | 1567 |
} |
1568 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1569 |
gn = zio_gang_node_alloc(gnpp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1570 |
gbh = gn->gn_gbh; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1571 |
bzero(gbh, SPA_GANGBLOCKSIZE); |
789 | 1572 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1573 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1574 |
* Create the gang header. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1575 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1576 |
zio = zio_rewrite(pio, spa, txg, bp, gbh, SPA_GANGBLOCKSIZE, NULL, NULL, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1577 |
pio->io_priority, ZIO_GANG_CHILD_FLAGS(pio), &pio->io_bookmark); |
5530 | 1578 |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1579 |
/* |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1580 |
* Create and nowait the gang children. |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1581 |
*/ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1582 |
for (int g = 0; resid != 0; resid -= lsize, g++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1583 |
lsize = P2ROUNDUP(resid / (SPA_GBH_NBLKPTRS - g), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1584 |
SPA_MINBLOCKSIZE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1585 |
ASSERT(lsize >= SPA_MINBLOCKSIZE && lsize <= resid); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1586 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1587 |
zp.zp_checksum = gio->io_prop.zp_checksum; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1588 |
zp.zp_compress = ZIO_COMPRESS_OFF; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1589 |
zp.zp_type = DMU_OT_NONE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1590 |
zp.zp_level = 0; |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1591 |
zp.zp_ndvas = gio->io_prop.zp_ndvas; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1592 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1593 |
zio_nowait(zio_write(zio, spa, txg, &gbh->zg_blkptr[g], |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1594 |
(char *)pio->io_data + (pio->io_size - resid), lsize, &zp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1595 |
zio_write_gang_member_ready, NULL, &gn->gn_child[g], |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1596 |
pio->io_priority, ZIO_GANG_CHILD_FLAGS(pio), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1597 |
&pio->io_bookmark)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1598 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1599 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1600 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1601 |
* Set pio's pipeline to just wait for zio to finish. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1602 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1603 |
pio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1604 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1605 |
zio_nowait(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1606 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1607 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1608 |
} |
1609 |
||
1610 |
/* |
|
1611 |
* ========================================================================== |
|
1612 |
* Allocate and free blocks |
|
1613 |
* ========================================================================== |
|
1614 |
*/ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1615 |
|
5530 | 1616 |
static int |
789 | 1617 |
zio_dva_allocate(zio_t *zio) |
1618 |
{ |
|
4527 | 1619 |
spa_t *spa = zio->io_spa; |
1620 |
metaslab_class_t *mc = spa->spa_normal_class; |
|
789 | 1621 |
blkptr_t *bp = zio->io_bp; |
1622 |
int error; |
|
1623 |
||
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1624 |
if (zio->io_gang_leader == NULL) { |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1625 |
ASSERT(zio->io_child_type > ZIO_CHILD_GANG); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1626 |
zio->io_gang_leader = zio; |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1627 |
} |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
1628 |
|
789 | 1629 |
ASSERT(BP_IS_HOLE(bp)); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1630 |
ASSERT3U(BP_GET_NDVAS(bp), ==, 0); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1631 |
ASSERT3U(zio->io_prop.zp_ndvas, >, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1632 |
ASSERT3U(zio->io_prop.zp_ndvas, <=, spa_max_replication(spa)); |
789 | 1633 |
ASSERT3U(zio->io_size, ==, BP_GET_PSIZE(bp)); |
1634 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1635 |
error = metaslab_alloc(spa, mc, zio->io_size, bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1636 |
zio->io_prop.zp_ndvas, zio->io_txg, NULL, 0); |
789 | 1637 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1638 |
if (error) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1639 |
if (error == ENOSPC && zio->io_size > SPA_MINBLOCKSIZE) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1640 |
return (zio_write_gang_block(zio)); |
789 | 1641 |
zio->io_error = error; |
1642 |
} |
|
5530 | 1643 |
|
1644 |
return (ZIO_PIPELINE_CONTINUE); |
|
789 | 1645 |
} |
1646 |
||
5530 | 1647 |
static int |
789 | 1648 |
zio_dva_free(zio_t *zio) |
1649 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1650 |
metaslab_free(zio->io_spa, zio->io_bp, zio->io_txg, B_FALSE); |
789 | 1651 |
|
5530 | 1652 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1653 |
} |
1654 |
||
5530 | 1655 |
static int |
789 | 1656 |
zio_dva_claim(zio_t *zio) |
1657 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1658 |
int error; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1659 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1660 |
error = metaslab_claim(zio->io_spa, zio->io_bp, zio->io_txg); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1661 |
if (error) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1662 |
zio->io_error = error; |
789 | 1663 |
|
5530 | 1664 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1665 |
} |
1666 |
||
1667 |
/* |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1668 |
* Undo an allocation. This is used by zio_done() when an I/O fails |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1669 |
* and we want to give back the block we just allocated. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1670 |
* This handles both normal blocks and gang blocks. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1671 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1672 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1673 |
zio_dva_unallocate(zio_t *zio, zio_gang_node_t *gn, blkptr_t *bp) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1674 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1675 |
spa_t *spa = zio->io_spa; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1676 |
boolean_t now = !(zio->io_flags & ZIO_FLAG_IO_REWRITE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1677 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1678 |
ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1679 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1680 |
if (zio->io_bp == bp && !now) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1681 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1682 |
* This is a rewrite for sync-to-convergence. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1683 |
* We can't do a metaslab_free(NOW) because bp wasn't allocated |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1684 |
* during this sync pass, which means that metaslab_sync() |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1685 |
* already committed the allocation. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1686 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1687 |
ASSERT(DVA_EQUAL(BP_IDENTITY(bp), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1688 |
BP_IDENTITY(&zio->io_bp_orig))); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1689 |
ASSERT(spa_sync_pass(spa) > 1); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1690 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1691 |
if (BP_IS_GANG(bp) && gn == NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1692 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1693 |
* This is a gang leader whose gang header(s) we |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1694 |
* couldn't read now, so defer the free until later. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1695 |
* The block should still be intact because without |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1696 |
* the headers, we'd never even start the rewrite. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1697 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1698 |
bplist_enqueue_deferred(&spa->spa_sync_bplist, bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1699 |
return; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1700 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1701 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1702 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1703 |
if (!BP_IS_HOLE(bp)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1704 |
metaslab_free(spa, bp, bp->blk_birth, now); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1705 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1706 |
if (gn != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1707 |
for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1708 |
zio_dva_unallocate(zio, gn->gn_child[g], |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1709 |
&gn->gn_gbh->zg_blkptr[g]); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1710 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1711 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1712 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1713 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1714 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1715 |
* Try to allocate an intent log block. Return 0 on success, errno on failure. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1716 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1717 |
int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1718 |
zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp, blkptr_t *old_bp, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1719 |
uint64_t txg) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1720 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1721 |
int error; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1722 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1723 |
error = metaslab_alloc(spa, spa->spa_log_class, size, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1724 |
new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1725 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1726 |
if (error) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1727 |
error = metaslab_alloc(spa, spa->spa_normal_class, size, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1728 |
new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1729 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1730 |
if (error == 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1731 |
BP_SET_LSIZE(new_bp, size); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1732 |
BP_SET_PSIZE(new_bp, size); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1733 |
BP_SET_COMPRESS(new_bp, ZIO_COMPRESS_OFF); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1734 |
BP_SET_CHECKSUM(new_bp, ZIO_CHECKSUM_ZILOG); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1735 |
BP_SET_TYPE(new_bp, DMU_OT_INTENT_LOG); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1736 |
BP_SET_LEVEL(new_bp, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1737 |
BP_SET_BYTEORDER(new_bp, ZFS_HOST_BYTEORDER); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1738 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1739 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1740 |
return (error); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1741 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1742 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1743 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1744 |
* Free an intent log block. We know it can't be a gang block, so there's |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1745 |
* nothing to do except metaslab_free() it. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1746 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1747 |
void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1748 |
zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1749 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1750 |
ASSERT(!BP_IS_GANG(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1751 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1752 |
metaslab_free(spa, bp, txg, B_FALSE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1753 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1754 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1755 |
/* |
789 | 1756 |
* ========================================================================== |
1757 |
* Read and write to physical devices |
|
1758 |
* ========================================================================== |
|
1759 |
*/ |
|
5530 | 1760 |
static int |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1761 |
zio_vdev_io_start(zio_t *zio) |
789 | 1762 |
{ |
1763 |
vdev_t *vd = zio->io_vd; |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1764 |
uint64_t align; |
5329 | 1765 |
spa_t *spa = zio->io_spa; |
1766 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1767 |
ASSERT(zio->io_error == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1768 |
ASSERT(zio->io_child_error[ZIO_CHILD_VDEV] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1769 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1770 |
if (vd == NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1771 |
if (!(zio->io_flags & ZIO_FLAG_CONFIG_WRITER)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1772 |
spa_config_enter(spa, SCL_ZIO, zio, RW_READER); |
789 | 1773 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1774 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1775 |
* The mirror_ops handle multiple DVAs in a single BP. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1776 |
*/ |
5530 | 1777 |
return (vdev_mirror_ops.vdev_op_io_start(zio)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1778 |
} |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1779 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1780 |
align = 1ULL << vd->vdev_top->vdev_ashift; |
789 | 1781 |
|
1732 | 1782 |
if (P2PHASE(zio->io_size, align) != 0) { |
1783 |
uint64_t asize = P2ROUNDUP(zio->io_size, align); |
|
1784 |
char *abuf = zio_buf_alloc(asize); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1785 |
ASSERT(vd == vd->vdev_top); |
1732 | 1786 |
if (zio->io_type == ZIO_TYPE_WRITE) { |
1787 |
bcopy(zio->io_data, abuf, zio->io_size); |
|
1788 |
bzero(abuf + zio->io_size, asize - zio->io_size); |
|
1789 |
} |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1790 |
zio_push_transform(zio, abuf, asize, asize, zio_subblock); |
1732 | 1791 |
} |
1792 |
||
1793 |
ASSERT(P2PHASE(zio->io_offset, align) == 0); |
|
1794 |
ASSERT(P2PHASE(zio->io_size, align) == 0); |
|
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1795 |
ASSERT(zio->io_type != ZIO_TYPE_WRITE || spa_writeable(spa)); |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1796 |
|
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1797 |
/* |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1798 |
* If this is a repair I/O, and there's no self-healing involved -- |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1799 |
* that is, we're just resilvering what we expect to resilver -- |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1800 |
* then don't do the I/O unless zio's txg is actually in vd's DTL. |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1801 |
* This prevents spurious resilvering with nested replication. |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1802 |
* For example, given a mirror of mirrors, (A+B)+(C+D), if only |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1803 |
* A is out of date, we'll read from C+D, then use the data to |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1804 |
* resilver A+B -- but we don't actually want to resilver B, just A. |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1805 |
* The top-level mirror has no way to know this, so instead we just |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1806 |
* discard unnecessary repairs as we work our way down the vdev tree. |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1807 |
* The same logic applies to any form of nested replication: |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1808 |
* ditto + mirror, RAID-Z + replacing, etc. This covers them all. |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1809 |
*/ |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1810 |
if ((zio->io_flags & ZIO_FLAG_IO_REPAIR) && |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1811 |
!(zio->io_flags & ZIO_FLAG_SELF_HEAL) && |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1812 |
zio->io_txg != 0 && /* not a delegated i/o */ |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1813 |
!vdev_dtl_contains(vd, DTL_PARTIAL, zio->io_txg, 1)) { |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1814 |
ASSERT(zio->io_type == ZIO_TYPE_WRITE); |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1815 |
zio_vdev_io_bypass(zio); |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1816 |
return (ZIO_PIPELINE_CONTINUE); |
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
1817 |
} |
789 | 1818 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1819 |
if (vd->vdev_ops->vdev_op_leaf && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1820 |
(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1821 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1822 |
if (zio->io_type == ZIO_TYPE_READ && vdev_cache_read(zio) == 0) |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1823 |
return (ZIO_PIPELINE_CONTINUE); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1824 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1825 |
if ((zio = vdev_queue_io(zio)) == NULL) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1826 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1827 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1828 |
if (!vdev_accessible(vd, zio)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1829 |
zio->io_error = ENXIO; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1830 |
zio_interrupt(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1831 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1832 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1833 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1834 |
|
5530 | 1835 |
return (vd->vdev_ops->vdev_op_io_start(zio)); |
789 | 1836 |
} |
1837 |
||
5530 | 1838 |
static int |
789 | 1839 |
zio_vdev_io_done(zio_t *zio) |
1840 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1841 |
vdev_t *vd = zio->io_vd; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1842 |
vdev_ops_t *ops = vd ? vd->vdev_ops : &vdev_mirror_ops; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1843 |
boolean_t unexpected_error = B_FALSE; |
5530 | 1844 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1845 |
if (zio_wait_for_children(zio, ZIO_CHILD_VDEV, ZIO_WAIT_DONE)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1846 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1847 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1848 |
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE); |
789 | 1849 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1850 |
if (vd != NULL && vd->vdev_ops->vdev_op_leaf) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1851 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1852 |
vdev_queue_io_done(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1853 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1854 |
if (zio->io_type == ZIO_TYPE_WRITE) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1855 |
vdev_cache_write(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1856 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1857 |
if (zio_injection_enabled && zio->io_error == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1858 |
zio->io_error = zio_handle_device_injection(vd, EIO); |
789 | 1859 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1860 |
if (zio_injection_enabled && zio->io_error == 0) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1861 |
zio->io_error = zio_handle_label_injection(zio, EIO); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1862 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1863 |
if (zio->io_error) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1864 |
if (!vdev_accessible(vd, zio)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1865 |
zio->io_error = ENXIO; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1866 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1867 |
unexpected_error = B_TRUE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1868 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1869 |
} |
6976
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
6523
diff
changeset
|
1870 |
} |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1871 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1872 |
ops->vdev_op_io_done(zio); |
789 | 1873 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1874 |
if (unexpected_error) |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
1875 |
VERIFY(vdev_probe(vd, zio) == NULL); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1876 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1877 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1878 |
} |
1879 |
||
5530 | 1880 |
static int |
789 | 1881 |
zio_vdev_io_assess(zio_t *zio) |
1882 |
{ |
|
1883 |
vdev_t *vd = zio->io_vd; |
|
1884 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1885 |
if (zio_wait_for_children(zio, ZIO_CHILD_VDEV, ZIO_WAIT_DONE)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1886 |
return (ZIO_PIPELINE_STOP); |
789 | 1887 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1888 |
if (vd == NULL && !(zio->io_flags & ZIO_FLAG_CONFIG_WRITER)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1889 |
spa_config_exit(zio->io_spa, SCL_ZIO, zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1890 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1891 |
if (zio->io_vsd != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1892 |
zio->io_vsd_free(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1893 |
zio->io_vsd = NULL; |
1732 | 1894 |
} |
1895 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1896 |
if (zio_injection_enabled && zio->io_error == 0) |
1544 | 1897 |
zio->io_error = zio_handle_fault_injection(zio, EIO); |
789 | 1898 |
|
1899 |
/* |
|
1900 |
* If the I/O failed, determine whether we should attempt to retry it. |
|
1901 |
*/ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1902 |
if (zio->io_error && vd == NULL && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1903 |
!(zio->io_flags & (ZIO_FLAG_DONT_RETRY | ZIO_FLAG_IO_RETRY))) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1904 |
ASSERT(!(zio->io_flags & ZIO_FLAG_DONT_QUEUE)); /* not a leaf */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1905 |
ASSERT(!(zio->io_flags & ZIO_FLAG_IO_BYPASS)); /* not a leaf */ |
789 | 1906 |
zio->io_error = 0; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1907 |
zio->io_flags |= ZIO_FLAG_IO_RETRY | |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1908 |
ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_AGGREGATE; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1909 |
zio->io_stage = ZIO_STAGE_VDEV_IO_START - 1; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1910 |
zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1911 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1912 |
} |
789 | 1913 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1914 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1915 |
* If we got an error on a leaf device, convert it to ENXIO |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1916 |
* if the device is not accessible at all. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1917 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1918 |
if (zio->io_error && vd != NULL && vd->vdev_ops->vdev_op_leaf && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1919 |
!vdev_accessible(vd, zio)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1920 |
zio->io_error = ENXIO; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1921 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1922 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1923 |
* If we can't write to an interior vdev (mirror or RAID-Z), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1924 |
* set vdev_cant_write so that we stop trying to allocate from it. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1925 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1926 |
if (zio->io_error == ENXIO && zio->io_type == ZIO_TYPE_WRITE && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1927 |
vd != NULL && !vd->vdev_ops->vdev_op_leaf) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1928 |
vd->vdev_cant_write = B_TRUE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1929 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1930 |
if (zio->io_error) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1931 |
zio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
789 | 1932 |
|
5530 | 1933 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1934 |
} |
1935 |
||
1936 |
void |
|
1937 |
zio_vdev_io_reissue(zio_t *zio) |
|
1938 |
{ |
|
1939 |
ASSERT(zio->io_stage == ZIO_STAGE_VDEV_IO_START); |
|
1940 |
ASSERT(zio->io_error == 0); |
|
1941 |
||
1942 |
zio->io_stage--; |
|
1943 |
} |
|
1944 |
||
1945 |
void |
|
1946 |
zio_vdev_io_redone(zio_t *zio) |
|
1947 |
{ |
|
1948 |
ASSERT(zio->io_stage == ZIO_STAGE_VDEV_IO_DONE); |
|
1949 |
||
1950 |
zio->io_stage--; |
|
1951 |
} |
|
1952 |
||
1953 |
void |
|
1954 |
zio_vdev_io_bypass(zio_t *zio) |
|
1955 |
{ |
|
1956 |
ASSERT(zio->io_stage == ZIO_STAGE_VDEV_IO_START); |
|
1957 |
ASSERT(zio->io_error == 0); |
|
1958 |
||
1959 |
zio->io_flags |= ZIO_FLAG_IO_BYPASS; |
|
1960 |
zio->io_stage = ZIO_STAGE_VDEV_IO_ASSESS - 1; |
|
1961 |
} |
|
1962 |
||
1963 |
/* |
|
1964 |
* ========================================================================== |
|
1965 |
* Generate and verify checksums |
|
1966 |
* ========================================================================== |
|
1967 |
*/ |
|
5530 | 1968 |
static int |
789 | 1969 |
zio_checksum_generate(zio_t *zio) |
1970 |
{ |
|
1971 |
blkptr_t *bp = zio->io_bp; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1972 |
enum zio_checksum checksum; |
789 | 1973 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1974 |
if (bp == NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1975 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1976 |
* This is zio_write_phys(). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1977 |
* We're either generating a label checksum, or none at all. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1978 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1979 |
checksum = zio->io_prop.zp_checksum; |
789 | 1980 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1981 |
if (checksum == ZIO_CHECKSUM_OFF) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1982 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1983 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1984 |
ASSERT(checksum == ZIO_CHECKSUM_LABEL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1985 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1986 |
if (BP_IS_GANG(bp) && zio->io_child_type == ZIO_CHILD_GANG) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1987 |
ASSERT(!IO_IS_ALLOCATING(zio)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1988 |
checksum = ZIO_CHECKSUM_GANG_HEADER; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1989 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1990 |
checksum = BP_GET_CHECKSUM(bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1991 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1992 |
} |
789 | 1993 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
1994 |
zio_checksum_compute(zio, checksum, zio->io_data, zio->io_size); |
789 | 1995 |
|
5530 | 1996 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 1997 |
} |
1998 |
||
5530 | 1999 |
static int |
789 | 2000 |
zio_checksum_verify(zio_t *zio) |
2001 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2002 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2003 |
int error; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2004 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2005 |
if (bp == NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2006 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2007 |
* This is zio_read_phys(). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2008 |
* We're either verifying a label checksum, or nothing at all. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2009 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2010 |
if (zio->io_prop.zp_checksum == ZIO_CHECKSUM_OFF) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2011 |
return (ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2012 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2013 |
ASSERT(zio->io_prop.zp_checksum == ZIO_CHECKSUM_LABEL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2014 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2015 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2016 |
if ((error = zio_checksum_error(zio)) != 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2017 |
zio->io_error = error; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2018 |
if (!(zio->io_flags & ZIO_FLAG_SPECULATIVE)) { |
1544 | 2019 |
zfs_ereport_post(FM_EREPORT_ZFS_CHECKSUM, |
2020 |
zio->io_spa, zio->io_vd, zio, 0, 0); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2021 |
} |
789 | 2022 |
} |
2023 |
||
5530 | 2024 |
return (ZIO_PIPELINE_CONTINUE); |
789 | 2025 |
} |
2026 |
||
2027 |
/* |
|
2028 |
* Called by RAID-Z to ensure we don't compute the checksum twice. |
|
2029 |
*/ |
|
2030 |
void |
|
2031 |
zio_checksum_verified(zio_t *zio) |
|
2032 |
{ |
|
2033 |
zio->io_pipeline &= ~(1U << ZIO_STAGE_CHECKSUM_VERIFY); |
|
2034 |
} |
|
2035 |
||
2036 |
/* |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2037 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2038 |
* Error rank. Error are ranked in the order 0, ENXIO, ECKSUM, EIO, other. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2039 |
* An error of 0 indictes success. ENXIO indicates whole-device failure, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2040 |
* which may be transient (e.g. unplugged) or permament. ECKSUM and EIO |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2041 |
* indicate errors that are specific to one I/O, and most likely permanent. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2042 |
* Any other error is presumed to be worse because we weren't expecting it. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2043 |
* ========================================================================== |
789 | 2044 |
*/ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2045 |
int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2046 |
zio_worst_error(int e1, int e2) |
789 | 2047 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2048 |
static int zio_error_rank[] = { 0, ENXIO, ECKSUM, EIO }; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2049 |
int r1, r2; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2050 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2051 |
for (r1 = 0; r1 < sizeof (zio_error_rank) / sizeof (int); r1++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2052 |
if (e1 == zio_error_rank[r1]) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2053 |
break; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2054 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2055 |
for (r2 = 0; r2 < sizeof (zio_error_rank) / sizeof (int); r2++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2056 |
if (e2 == zio_error_rank[r2]) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2057 |
break; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2058 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2059 |
return (r1 > r2 ? e1 : e2); |
789 | 2060 |
} |
2061 |
||
2062 |
/* |
|
2063 |
* ========================================================================== |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2064 |
* I/O completion |
789 | 2065 |
* ========================================================================== |
2066 |
*/ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2067 |
static int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2068 |
zio_ready(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2069 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2070 |
blkptr_t *bp = zio->io_bp; |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2071 |
zio_t *pio, *pio_next; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2072 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2073 |
if (zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_READY)) |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2074 |
return (ZIO_PIPELINE_STOP); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2075 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2076 |
if (zio->io_ready) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2077 |
ASSERT(IO_IS_ALLOCATING(zio)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2078 |
ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2079 |
ASSERT(zio->io_children[ZIO_CHILD_GANG][ZIO_WAIT_READY] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2080 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2081 |
zio->io_ready(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2082 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2083 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2084 |
if (bp != NULL && bp != &zio->io_bp_copy) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2085 |
zio->io_bp_copy = *bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2086 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2087 |
if (zio->io_error) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2088 |
zio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2089 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2090 |
mutex_enter(&zio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2091 |
zio->io_state[ZIO_WAIT_READY] = 1; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2092 |
pio = zio_walk_parents(zio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2093 |
mutex_exit(&zio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2094 |
|
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2095 |
/* |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2096 |
* As we notify zio's parents, new parents could be added. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2097 |
* New parents go to the head of zio's io_parent_list, however, |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2098 |
* so we will (correctly) not notify them. The remainder of zio's |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2099 |
* io_parent_list, from 'pio_next' onward, cannot change because |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2100 |
* all parents must wait for us to be done before they can be done. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2101 |
*/ |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2102 |
for (; pio != NULL; pio = pio_next) { |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2103 |
pio_next = zio_walk_parents(zio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2104 |
zio_notify_parent(pio, zio, ZIO_WAIT_READY); |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2105 |
} |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2106 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2107 |
return (ZIO_PIPELINE_CONTINUE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2108 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2109 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2110 |
static int |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2111 |
zio_done(zio_t *zio) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2112 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2113 |
spa_t *spa = zio->io_spa; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2114 |
zio_t *lio = zio->io_logical; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2115 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2116 |
vdev_t *vd = zio->io_vd; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2117 |
uint64_t psize = zio->io_size; |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2118 |
zio_t *pio, *pio_next; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2119 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2120 |
/* |
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2121 |
* If our children haven't all completed, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2122 |
* wait for them and then repeat this pipeline stage. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2123 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2124 |
if (zio_wait_for_children(zio, ZIO_CHILD_VDEV, ZIO_WAIT_DONE) || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2125 |
zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_DONE) || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2126 |
zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_DONE)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2127 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2128 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2129 |
for (int c = 0; c < ZIO_CHILD_TYPES; c++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2130 |
for (int w = 0; w < ZIO_WAIT_TYPES; w++) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2131 |
ASSERT(zio->io_children[c][w] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2132 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2133 |
if (bp != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2134 |
ASSERT(bp->blk_pad[0] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2135 |
ASSERT(bp->blk_pad[1] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2136 |
ASSERT(bp->blk_pad[2] == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2137 |
ASSERT(bcmp(bp, &zio->io_bp_copy, sizeof (blkptr_t)) == 0 || |
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2138 |
(bp == zio_unique_parent(zio)->io_bp)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2139 |
if (zio->io_type == ZIO_TYPE_WRITE && !BP_IS_HOLE(bp) && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2140 |
!(zio->io_flags & ZIO_FLAG_IO_REPAIR)) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2141 |
ASSERT(!BP_SHOULD_BYTESWAP(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2142 |
ASSERT3U(zio->io_prop.zp_ndvas, <=, BP_GET_NDVAS(bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2143 |
ASSERT(BP_COUNT_GANG(bp) == 0 || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2144 |
(BP_COUNT_GANG(bp) == BP_GET_NDVAS(bp))); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2145 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2146 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2147 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2148 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2149 |
* If there were child vdev or gang errors, they apply to us now. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2150 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2151 |
zio_inherit_child_errors(zio, ZIO_CHILD_VDEV); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2152 |
zio_inherit_child_errors(zio, ZIO_CHILD_GANG); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2153 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2154 |
zio_pop_transforms(zio); /* note: may set zio->io_error */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2155 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2156 |
vdev_stat_update(zio, psize); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2157 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2158 |
if (zio->io_error) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2159 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2160 |
* If this I/O is attached to a particular vdev, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2161 |
* generate an error message describing the I/O failure |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2162 |
* at the block level. We ignore these errors if the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2163 |
* device is currently unavailable. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2164 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2165 |
if (zio->io_error != ECKSUM && vd != NULL && !vdev_is_dead(vd)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2166 |
zfs_ereport_post(FM_EREPORT_ZFS_IO, spa, vd, zio, 0, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2167 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2168 |
if ((zio->io_error == EIO || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2169 |
!(zio->io_flags & ZIO_FLAG_SPECULATIVE)) && zio == lio) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2170 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2171 |
* For logical I/O requests, tell the SPA to log the |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2172 |
* error and generate a logical data ereport. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2173 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2174 |
spa_log_error(spa, zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2175 |
zfs_ereport_post(FM_EREPORT_ZFS_DATA, spa, NULL, zio, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2176 |
0, 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2177 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2178 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2179 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2180 |
if (zio->io_error && zio == lio) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2181 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2182 |
* Determine whether zio should be reexecuted. This will |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2183 |
* propagate all the way to the root via zio_notify_parent(). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2184 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2185 |
ASSERT(vd == NULL && bp != NULL); |
789 | 2186 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2187 |
if (IO_IS_ALLOCATING(zio)) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2188 |
if (zio->io_error != ENOSPC) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2189 |
zio->io_reexecute |= ZIO_REEXECUTE_NOW; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2190 |
else |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2191 |
zio->io_reexecute |= ZIO_REEXECUTE_SUSPEND; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2192 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2193 |
if ((zio->io_type == ZIO_TYPE_READ || |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2194 |
zio->io_type == ZIO_TYPE_FREE) && |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2195 |
zio->io_error == ENXIO && |
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7872
diff
changeset
|
2196 |
spa->spa_load_state == SPA_LOAD_NONE && |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2197 |
spa_get_failmode(spa) != ZIO_FAILURE_MODE_CONTINUE) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2198 |
zio->io_reexecute |= ZIO_REEXECUTE_SUSPEND; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2199 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2200 |
if (!(zio->io_flags & ZIO_FLAG_CANFAIL) && !zio->io_reexecute) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2201 |
zio->io_reexecute |= ZIO_REEXECUTE_SUSPEND; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2202 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2203 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2204 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2205 |
* If there were logical child errors, they apply to us now. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2206 |
* We defer this until now to avoid conflating logical child |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2207 |
* errors with errors that happened to the zio itself when |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2208 |
* updating vdev stats and reporting FMA events above. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2209 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2210 |
zio_inherit_child_errors(zio, ZIO_CHILD_LOGICAL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2211 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2212 |
if ((zio->io_error || zio->io_reexecute) && IO_IS_ALLOCATING(zio) && |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2213 |
zio->io_child_type == ZIO_CHILD_LOGICAL) { |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2214 |
ASSERT(zio->io_child_type != ZIO_CHILD_GANG); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2215 |
zio_dva_unallocate(zio, zio->io_gang_tree, bp); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2216 |
} |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2217 |
|
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2218 |
zio_gang_tree_free(&zio->io_gang_tree); |
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2219 |
|
9470
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2220 |
/* |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2221 |
* Godfather I/Os should never suspend. |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2222 |
*/ |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2223 |
if ((zio->io_flags & ZIO_FLAG_GODFATHER) && |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2224 |
(zio->io_reexecute & ZIO_REEXECUTE_SUSPEND)) |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2225 |
zio->io_reexecute = 0; |
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2226 |
|
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2227 |
if (zio->io_reexecute) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2228 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2229 |
* This is a logical I/O that wants to reexecute. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2230 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2231 |
* Reexecute is top-down. When an i/o fails, if it's not |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2232 |
* the root, it simply notifies its parent and sticks around. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2233 |
* The parent, seeing that it still has children in zio_done(), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2234 |
* does the same. This percolates all the way up to the root. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2235 |
* The root i/o will reexecute or suspend the entire tree. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2236 |
* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2237 |
* This approach ensures that zio_reexecute() honors |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2238 |
* all the original i/o dependency relationships, e.g. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2239 |
* parents not executing until children are ready. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2240 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2241 |
ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2242 |
|
9443
2a96d8478e95
6833711 gang leaders shouldn't have to be logical
Bill Moore <Bill.Moore@Sun.COM>
parents:
9396
diff
changeset
|
2243 |
zio->io_gang_leader = NULL; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2244 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2245 |
mutex_enter(&zio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2246 |
zio->io_state[ZIO_WAIT_DONE] = 1; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2247 |
mutex_exit(&zio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2248 |
|
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2249 |
/* |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2250 |
* "The Godfather" I/O monitors its children but is |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2251 |
* not a true parent to them. It will track them through |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2252 |
* the pipeline but severs its ties whenever they get into |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2253 |
* trouble (e.g. suspended). This allows "The Godfather" |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2254 |
* I/O to return status without blocking. |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2255 |
*/ |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2256 |
for (pio = zio_walk_parents(zio); pio != NULL; pio = pio_next) { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2257 |
zio_link_t *zl = zio->io_walk_link; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2258 |
pio_next = zio_walk_parents(zio); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2259 |
|
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2260 |
if ((pio->io_flags & ZIO_FLAG_GODFATHER) && |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2261 |
(zio->io_reexecute & ZIO_REEXECUTE_SUSPEND)) { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2262 |
zio_remove_child(pio, zio, zl); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2263 |
zio_notify_parent(pio, zio, ZIO_WAIT_DONE); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2264 |
} |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2265 |
} |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
8632
diff
changeset
|
2266 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2267 |
if ((pio = zio_unique_parent(zio)) != NULL) { |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2268 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2269 |
* We're not a root i/o, so there's nothing to do |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2270 |
* but notify our parent. Don't propagate errors |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2271 |
* upward since we haven't permanently failed yet. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2272 |
*/ |
9470
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2273 |
ASSERT(!(zio->io_flags & ZIO_FLAG_GODFATHER)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2274 |
zio->io_flags |= ZIO_FLAG_DONT_PROPAGATE; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2275 |
zio_notify_parent(pio, zio, ZIO_WAIT_DONE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2276 |
} else if (zio->io_reexecute & ZIO_REEXECUTE_SUSPEND) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2277 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2278 |
* We'd fail again if we reexecuted now, so suspend |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2279 |
* until conditions improve (e.g. device comes online). |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2280 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2281 |
zio_suspend(spa, zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2282 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2283 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2284 |
* Reexecution is potentially a huge amount of work. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2285 |
* Hand it off to the otherwise-unused claim taskq. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2286 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2287 |
(void) taskq_dispatch( |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2288 |
spa->spa_zio_taskq[ZIO_TYPE_CLAIM][ZIO_TASKQ_ISSUE], |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2289 |
(task_func_t *)zio_reexecute, zio, TQ_SLEEP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2290 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2291 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2292 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2293 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2294 |
ASSERT(zio_walk_children(zio) == NULL); |
9470
6d827468d7b5
6834217 godfather I/O should reexecute
George Wilson <George.Wilson@Sun.COM>
parents:
9443
diff
changeset
|
2295 |
ASSERT(zio->io_reexecute == 0); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2296 |
ASSERT(zio->io_error == 0 || (zio->io_flags & ZIO_FLAG_CANFAIL)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2297 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2298 |
/* |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2299 |
* It is the responsibility of the done callback to ensure that this |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2300 |
* particular zio is no longer discoverable for adoption, and as |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2301 |
* such, cannot acquire any new parents. |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2302 |
*/ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2303 |
if (zio->io_done) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2304 |
zio->io_done(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2305 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2306 |
mutex_enter(&zio->io_lock); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2307 |
zio->io_state[ZIO_WAIT_DONE] = 1; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2308 |
mutex_exit(&zio->io_lock); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2309 |
|
8632
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2310 |
for (pio = zio_walk_parents(zio); pio != NULL; pio = pio_next) { |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2311 |
zio_link_t *zl = zio->io_walk_link; |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2312 |
pio_next = zio_walk_parents(zio); |
36ef517870a3
6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents:
8274
diff
changeset
|
2313 |
zio_remove_child(pio, zio, zl); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2314 |
zio_notify_parent(pio, zio, ZIO_WAIT_DONE); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2315 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2316 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2317 |
if (zio->io_waiter != NULL) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2318 |
mutex_enter(&zio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2319 |
zio->io_executor = NULL; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2320 |
cv_broadcast(&zio->io_cv); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2321 |
mutex_exit(&zio->io_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2322 |
} else { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2323 |
zio_destroy(zio); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2324 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2325 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2326 |
return (ZIO_PIPELINE_STOP); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2327 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2328 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2329 |
/* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2330 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2331 |
* I/O pipeline definition |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2332 |
* ========================================================================== |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2333 |
*/ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2334 |
static zio_pipe_stage_t *zio_pipeline[ZIO_STAGES] = { |
5530 | 2335 |
NULL, |
2336 |
zio_issue_async, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2337 |
zio_read_bp_init, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2338 |
zio_write_bp_init, |
789 | 2339 |
zio_checksum_generate, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2340 |
zio_gang_assemble, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2341 |
zio_gang_issue, |
789 | 2342 |
zio_dva_allocate, |
2343 |
zio_dva_free, |
|
2344 |
zio_dva_claim, |
|
2345 |
zio_ready, |
|
2346 |
zio_vdev_io_start, |
|
2347 |
zio_vdev_io_done, |
|
2348 |
zio_vdev_io_assess, |
|
2349 |
zio_checksum_verify, |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7181
diff
changeset
|
2350 |
zio_done |
789 | 2351 |
}; |