Deleted Added
full compact
vdev_label.c (209962) vdev_label.c (213198)
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

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

334
335nvlist_t *
336vdev_label_read_config(vdev_t *vd)
337{
338 spa_t *spa = vd->vdev_spa;
339 nvlist_t *config = NULL;
340 vdev_phys_t *vp;
341 zio_t *zio;
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

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

334
335nvlist_t *
336vdev_label_read_config(vdev_t *vd)
337{
338 spa_t *spa = vd->vdev_spa;
339 nvlist_t *config = NULL;
340 vdev_phys_t *vp;
341 zio_t *zio;
342 int flags =
343 ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE;
342 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
343 ZIO_FLAG_SPECULATIVE;
344
345 ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL);
346
347 if (!vdev_readable(vd))
348 return (NULL);
349
350 vp = zio_buf_alloc(sizeof (vdev_phys_t));
351
344
345 ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL);
346
347 if (!vdev_readable(vd))
348 return (NULL);
349
350 vp = zio_buf_alloc(sizeof (vdev_phys_t));
351
352retry:
352 for (int l = 0; l < VDEV_LABELS; l++) {
353
354 zio = zio_root(spa, NULL, NULL, flags);
355
356 vdev_label_read(zio, vd, l, vp,
357 offsetof(vdev_label_t, vl_vdev_phys),
358 sizeof (vdev_phys_t), NULL, NULL, flags);
359
360 if (zio_wait(zio) == 0 &&
361 nvlist_unpack(vp->vp_nvlist, sizeof (vp->vp_nvlist),
362 &config, 0) == 0)
363 break;
364
365 if (config != NULL) {
366 nvlist_free(config);
367 config = NULL;
368 }
369 }
370
353 for (int l = 0; l < VDEV_LABELS; l++) {
354
355 zio = zio_root(spa, NULL, NULL, flags);
356
357 vdev_label_read(zio, vd, l, vp,
358 offsetof(vdev_label_t, vl_vdev_phys),
359 sizeof (vdev_phys_t), NULL, NULL, flags);
360
361 if (zio_wait(zio) == 0 &&
362 nvlist_unpack(vp->vp_nvlist, sizeof (vp->vp_nvlist),
363 &config, 0) == 0)
364 break;
365
366 if (config != NULL) {
367 nvlist_free(config);
368 config = NULL;
369 }
370 }
371
372 if (config == NULL && !(flags & ZIO_FLAG_TRYHARD)) {
373 flags |= ZIO_FLAG_TRYHARD;
374 goto retry;
375 }
376
371 zio_buf_free(vp, sizeof (vdev_phys_t));
372
373 return (config);
374}
375
376/*
377 * Determine if a device is in use. The 'spare_guid' parameter will be filled
378 * in with the device guid if this spare is active elsewhere on the system.

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

643
644 /* Initialize the 2nd padding area. */
645 pad2 = zio_buf_alloc(VDEV_PAD_SIZE);
646 bzero(pad2, VDEV_PAD_SIZE);
647
648 /*
649 * Write everything in parallel.
650 */
377 zio_buf_free(vp, sizeof (vdev_phys_t));
378
379 return (config);
380}
381
382/*
383 * Determine if a device is in use. The 'spare_guid' parameter will be filled
384 * in with the device guid if this spare is active elsewhere on the system.

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

649
650 /* Initialize the 2nd padding area. */
651 pad2 = zio_buf_alloc(VDEV_PAD_SIZE);
652 bzero(pad2, VDEV_PAD_SIZE);
653
654 /*
655 * Write everything in parallel.
656 */
657retry:
651 zio = zio_root(spa, NULL, NULL, flags);
652
653 for (int l = 0; l < VDEV_LABELS; l++) {
654
655 vdev_label_write(zio, vd, l, vp,
656 offsetof(vdev_label_t, vl_vdev_phys),
657 sizeof (vdev_phys_t), NULL, NULL, flags);
658

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

669 vdev_label_write(zio, vd, l, ub,
670 VDEV_UBERBLOCK_OFFSET(vd, n),
671 VDEV_UBERBLOCK_SIZE(vd), NULL, NULL, flags);
672 }
673 }
674
675 error = zio_wait(zio);
676
658 zio = zio_root(spa, NULL, NULL, flags);
659
660 for (int l = 0; l < VDEV_LABELS; l++) {
661
662 vdev_label_write(zio, vd, l, vp,
663 offsetof(vdev_label_t, vl_vdev_phys),
664 sizeof (vdev_phys_t), NULL, NULL, flags);
665

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

676 vdev_label_write(zio, vd, l, ub,
677 VDEV_UBERBLOCK_OFFSET(vd, n),
678 VDEV_UBERBLOCK_SIZE(vd), NULL, NULL, flags);
679 }
680 }
681
682 error = zio_wait(zio);
683
684 if (error != 0 && !(flags & ZIO_FLAG_TRYHARD)) {
685 flags |= ZIO_FLAG_TRYHARD;
686 goto retry;
687 }
688
677 nvlist_free(label);
678 zio_buf_free(pad2, VDEV_PAD_SIZE);
679 zio_buf_free(ub, VDEV_UBERBLOCK_SIZE(vd));
680 zio_buf_free(vp, sizeof (vdev_phys_t));
681
682 /*
683 * If this vdev hasn't been previously identified as a spare, then we
684 * mark it as such only if a) we are labeling it as a spare, or b) it

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

755 zio_buf_free(zio->io_data, zio->io_size);
756}
757
758void
759vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest)
760{
761 spa_t *spa = vd->vdev_spa;
762 vdev_t *rvd = spa->spa_root_vdev;
689 nvlist_free(label);
690 zio_buf_free(pad2, VDEV_PAD_SIZE);
691 zio_buf_free(ub, VDEV_UBERBLOCK_SIZE(vd));
692 zio_buf_free(vp, sizeof (vdev_phys_t));
693
694 /*
695 * If this vdev hasn't been previously identified as a spare, then we
696 * mark it as such only if a) we are labeling it as a spare, or b) it

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

767 zio_buf_free(zio->io_data, zio->io_size);
768}
769
770void
771vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest)
772{
773 spa_t *spa = vd->vdev_spa;
774 vdev_t *rvd = spa->spa_root_vdev;
763 int flags =
764 ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE;
775 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
776 ZIO_FLAG_SPECULATIVE | ZIO_FLAG_TRYHARD;
765
766 if (vd == rvd) {
767 ASSERT(zio == NULL);
768 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
769 zio = zio_root(spa, NULL, ubbest, flags);
770 bzero(ubbest, sizeof (uberblock_t));
771 }
772

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

994 * if the system panics or loses power at any time, the state on disk
995 * is still transactionally consistent. The in-line comments below
996 * describe the failure semantics at each stage.
997 *
998 * Moreover, vdev_config_sync() is designed to be idempotent: if it fails
999 * at any time, you can just call it again, and it will resume its work.
1000 */
1001int
777
778 if (vd == rvd) {
779 ASSERT(zio == NULL);
780 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
781 zio = zio_root(spa, NULL, ubbest, flags);
782 bzero(ubbest, sizeof (uberblock_t));
783 }
784

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

1006 * if the system panics or loses power at any time, the state on disk
1007 * is still transactionally consistent. The in-line comments below
1008 * describe the failure semantics at each stage.
1009 *
1010 * Moreover, vdev_config_sync() is designed to be idempotent: if it fails
1011 * at any time, you can just call it again, and it will resume its work.
1012 */
1013int
1002vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
1014vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
1003{
1004 spa_t *spa = svd[0]->vdev_spa;
1005 uberblock_t *ub = &spa->spa_uberblock;
1006 vdev_t *vd;
1007 zio_t *zio;
1008 int error;
1009 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
1010
1015{
1016 spa_t *spa = svd[0]->vdev_spa;
1017 uberblock_t *ub = &spa->spa_uberblock;
1018 vdev_t *vd;
1019 zio_t *zio;
1020 int error;
1021 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
1022
1023 /*
1024 * Normally, we don't want to try too hard to write every label and
1025 * uberblock. If there is a flaky disk, we don't want the rest of the
1026 * sync process to block while we retry. But if we can't write a
1027 * single label out, we should retry with ZIO_FLAG_TRYHARD before
1028 * bailing out and declaring the pool faulted.
1029 */
1030 if (tryhard)
1031 flags |= ZIO_FLAG_TRYHARD;
1032
1011 ASSERT(ub->ub_txg <= txg);
1012
1013 /*
1014 * If this isn't a resync due to I/O errors,
1015 * and nothing changed in this transaction group,
1016 * and the vdev configuration hasn't changed,
1017 * then there's nothing to do.
1018 */

--- 66 unchanged lines hidden ---
1033 ASSERT(ub->ub_txg <= txg);
1034
1035 /*
1036 * If this isn't a resync due to I/O errors,
1037 * and nothing changed in this transaction group,
1038 * and the vdev configuration hasn't changed,
1039 * then there's nothing to do.
1040 */

--- 66 unchanged lines hidden ---