Deleted Added
full compact
vdev_mirror.c (185029) vdev_mirror.c (209962)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

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/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

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/*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#include <sys/zfs_context.h>
27#include <sys/spa.h>
28#include <sys/vdev_impl.h>
29#include <sys/zio.h>
30#include <sys/fs/zfs.h>

--- 144 unchanged lines hidden (view full) ---

175}
176
177static void
178vdev_mirror_scrub_done(zio_t *zio)
179{
180 mirror_child_t *mc = zio->io_private;
181
182 if (zio->io_error == 0) {
23 * Use is subject to license terms.
24 */
25
26#include <sys/zfs_context.h>
27#include <sys/spa.h>
28#include <sys/vdev_impl.h>
29#include <sys/zio.h>
30#include <sys/fs/zfs.h>

--- 144 unchanged lines hidden (view full) ---

175}
176
177static void
178vdev_mirror_scrub_done(zio_t *zio)
179{
180 mirror_child_t *mc = zio->io_private;
181
182 if (zio->io_error == 0) {
183 zio_t *pio = zio->io_parent;
184 mutex_enter(&pio->io_lock);
185 ASSERT3U(zio->io_size, >=, pio->io_size);
186 bcopy(zio->io_data, pio->io_data, pio->io_size);
187 mutex_exit(&pio->io_lock);
183 zio_t *pio;
184
185 mutex_enter(&zio->io_lock);
186 while ((pio = zio_walk_parents(zio)) != NULL) {
187 mutex_enter(&pio->io_lock);
188 ASSERT3U(zio->io_size, >=, pio->io_size);
189 bcopy(zio->io_data, pio->io_data, pio->io_size);
190 mutex_exit(&pio->io_lock);
191 }
192 mutex_exit(&zio->io_lock);
188 }
189
190 zio_buf_free(zio->io_data, zio->io_size);
191
192 mc->mc_error = zio->io_error;
193 mc->mc_tried = 1;
194 mc->mc_skipped = 0;
195}

--- 24 unchanged lines hidden (view full) ---

220 if (mc->mc_tried || mc->mc_skipped)
221 continue;
222 if (!vdev_readable(mc->mc_vd)) {
223 mc->mc_error = ENXIO;
224 mc->mc_tried = 1; /* don't even try */
225 mc->mc_skipped = 1;
226 continue;
227 }
193 }
194
195 zio_buf_free(zio->io_data, zio->io_size);
196
197 mc->mc_error = zio->io_error;
198 mc->mc_tried = 1;
199 mc->mc_skipped = 0;
200}

--- 24 unchanged lines hidden (view full) ---

225 if (mc->mc_tried || mc->mc_skipped)
226 continue;
227 if (!vdev_readable(mc->mc_vd)) {
228 mc->mc_error = ENXIO;
229 mc->mc_tried = 1; /* don't even try */
230 mc->mc_skipped = 1;
231 continue;
232 }
228 if (!vdev_dtl_contains(&mc->mc_vd->vdev_dtl_map, txg, 1))
233 if (!vdev_dtl_contains(mc->mc_vd, DTL_MISSING, txg, 1))
229 return (c);
230 mc->mc_error = ESTALE;
231 mc->mc_skipped = 1;
232 mc->mc_speculative = 1;
233 }
234
235 /*
236 * Every device is either missing or has this txg in its DTL.

--- 40 unchanged lines hidden (view full) ---

277 * For normal reads just pick one child.
278 */
279 c = vdev_mirror_child_select(zio);
280 children = (c >= 0);
281 } else {
282 ASSERT(zio->io_type == ZIO_TYPE_WRITE);
283
284 /*
234 return (c);
235 mc->mc_error = ESTALE;
236 mc->mc_skipped = 1;
237 mc->mc_speculative = 1;
238 }
239
240 /*
241 * Every device is either missing or has this txg in its DTL.

--- 40 unchanged lines hidden (view full) ---

282 * For normal reads just pick one child.
283 */
284 c = vdev_mirror_child_select(zio);
285 children = (c >= 0);
286 } else {
287 ASSERT(zio->io_type == ZIO_TYPE_WRITE);
288
289 /*
285 * If this is a resilvering I/O to a replacing vdev,
286 * only the last child should be written -- unless the
287 * first child happens to have a DTL entry here as well.
288 * All other writes go to all children.
290 * Writes go to all children.
289 */
291 */
290 if ((zio->io_flags & ZIO_FLAG_RESILVER) && mm->mm_replacing &&
291 !vdev_dtl_contains(&mm->mm_child[0].mc_vd->vdev_dtl_map,
292 zio->io_txg, 1)) {
293 c = mm->mm_children - 1;
294 children = 1;
295 } else {
296 c = 0;
297 children = mm->mm_children;
298 }
292 c = 0;
293 children = mm->mm_children;
299 }
300
301 while (children--) {
302 mc = &mm->mm_child[c];
303 zio_nowait(zio_vdev_child_io(zio, zio->io_bp,
304 mc->mc_vd, mc->mc_offset, zio->io_data, zio->io_size,
305 zio->io_type, zio->io_priority, 0,
306 vdev_mirror_child_done, mc));

--- 86 unchanged lines hidden (view full) ---

393 }
394
395 /* XXPOLICY */
396 if (good_copies == 0) {
397 zio->io_error = vdev_mirror_worst_error(mm);
398 ASSERT(zio->io_error != 0);
399 }
400
294 }
295
296 while (children--) {
297 mc = &mm->mm_child[c];
298 zio_nowait(zio_vdev_child_io(zio, zio->io_bp,
299 mc->mc_vd, mc->mc_offset, zio->io_data, zio->io_size,
300 zio->io_type, zio->io_priority, 0,
301 vdev_mirror_child_done, mc));

--- 86 unchanged lines hidden (view full) ---

388 }
389
390 /* XXPOLICY */
391 if (good_copies == 0) {
392 zio->io_error = vdev_mirror_worst_error(mm);
393 ASSERT(zio->io_error != 0);
394 }
395
401 if (good_copies && (spa_mode & FWRITE) &&
396 if (good_copies && spa_writeable(zio->io_spa) &&
402 (unexpected_errors ||
403 (zio->io_flags & ZIO_FLAG_RESILVER) ||
404 ((zio->io_flags & ZIO_FLAG_SCRUB) && mm->mm_replacing))) {
405 /*
406 * Use the good data we have in hand to repair damaged children.
407 */
408 for (c = 0; c < mm->mm_children; c++) {
409 /*

--- 4 unchanged lines hidden (view full) ---

414 * there would be no good copies left!
415 */
416 mc = &mm->mm_child[c];
417
418 if (mc->mc_error == 0) {
419 if (mc->mc_tried)
420 continue;
421 if (!(zio->io_flags & ZIO_FLAG_SCRUB) &&
397 (unexpected_errors ||
398 (zio->io_flags & ZIO_FLAG_RESILVER) ||
399 ((zio->io_flags & ZIO_FLAG_SCRUB) && mm->mm_replacing))) {
400 /*
401 * Use the good data we have in hand to repair damaged children.
402 */
403 for (c = 0; c < mm->mm_children; c++) {
404 /*

--- 4 unchanged lines hidden (view full) ---

409 * there would be no good copies left!
410 */
411 mc = &mm->mm_child[c];
412
413 if (mc->mc_error == 0) {
414 if (mc->mc_tried)
415 continue;
416 if (!(zio->io_flags & ZIO_FLAG_SCRUB) &&
422 !vdev_dtl_contains(&mc->mc_vd->vdev_dtl_map,
417 !vdev_dtl_contains(mc->mc_vd, DTL_PARTIAL,
423 zio->io_txg, 1))
424 continue;
425 mc->mc_error = ESTALE;
426 }
427
428 zio_nowait(zio_vdev_child_io(zio, zio->io_bp,
429 mc->mc_vd, mc->mc_offset,
430 zio->io_data, zio->io_size,
431 ZIO_TYPE_WRITE, zio->io_priority,
418 zio->io_txg, 1))
419 continue;
420 mc->mc_error = ESTALE;
421 }
422
423 zio_nowait(zio_vdev_child_io(zio, zio->io_bp,
424 mc->mc_vd, mc->mc_offset,
425 zio->io_data, zio->io_size,
426 ZIO_TYPE_WRITE, zio->io_priority,
432 ZIO_FLAG_IO_REPAIR, NULL, NULL));
427 ZIO_FLAG_IO_REPAIR | (unexpected_errors ?
428 ZIO_FLAG_SELF_HEAL : 0), NULL, NULL));
433 }
434 }
435}
436
437static void
438vdev_mirror_state_change(vdev_t *vd, int faulted, int degraded)
439{
440 if (faulted == vd->vdev_children)

--- 40 unchanged lines hidden ---
429 }
430 }
431}
432
433static void
434vdev_mirror_state_change(vdev_t *vd, int faulted, int degraded)
435{
436 if (faulted == vd->vdev_children)

--- 40 unchanged lines hidden ---