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 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) { |
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); |
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 } |
233 if (!vdev_dtl_contains(mc->mc_vd, DTL_MISSING, txg, 1)) |
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 /* |
290 * Writes go to all children. |
291 */ |
292 c = 0; 293 children = mm->mm_children; |
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 |
396 if (good_copies && spa_writeable(zio->io_spa) && |
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) && |
417 !vdev_dtl_contains(mc->mc_vd, DTL_PARTIAL, |
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, |
427 ZIO_FLAG_IO_REPAIR | (unexpected_errors ? 428 ZIO_FLAG_SELF_HEAL : 0), NULL, NULL)); |
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 --- |