vdev.c (208370) | vdev.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 --- 6 unchanged lines hidden (view full) --- 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/* | 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 --- 6 unchanged lines hidden (view full) --- 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/* |
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/fm/fs/zfs.h> 29#include <sys/spa.h> 30#include <sys/spa_impl.h> 31#include <sys/dmu.h> --- 290 unchanged lines hidden (view full) --- 322 vd->vdev_guid = guid; 323 vd->vdev_guid_sum = guid; 324 vd->vdev_ops = ops; 325 vd->vdev_state = VDEV_STATE_CLOSED; 326 327 mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); 328 mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); 329 mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL); | 24 * Use is subject to license terms. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/fm/fs/zfs.h> 29#include <sys/spa.h> 30#include <sys/spa_impl.h> 31#include <sys/dmu.h> --- 290 unchanged lines hidden (view full) --- 322 vd->vdev_guid = guid; 323 vd->vdev_guid_sum = guid; 324 vd->vdev_ops = ops; 325 vd->vdev_state = VDEV_STATE_CLOSED; 326 327 mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); 328 mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); 329 mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL); |
330 space_map_create(&vd->vdev_dtl_map, 0, -1ULL, 0, &vd->vdev_dtl_lock); 331 space_map_create(&vd->vdev_dtl_scrub, 0, -1ULL, 0, &vd->vdev_dtl_lock); | 330 for (int t = 0; t < DTL_TYPES; t++) { 331 space_map_create(&vd->vdev_dtl[t], 0, -1ULL, 0, 332 &vd->vdev_dtl_lock); 333 } |
332 txg_list_create(&vd->vdev_ms_list, 333 offsetof(struct metaslab, ms_txg_node)); 334 txg_list_create(&vd->vdev_dtl_list, 335 offsetof(struct vdev, vdev_dtl_node)); 336 vd->vdev_stat.vs_timestamp = gethrtime(); 337 vdev_queue_init(vd); 338 vdev_cache_init(vd); 339 --- 99 unchanged lines hidden (view full) --- 439 440 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &vd->vdev_path) == 0) 441 vd->vdev_path = spa_strdup(vd->vdev_path); 442 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &vd->vdev_devid) == 0) 443 vd->vdev_devid = spa_strdup(vd->vdev_devid); 444 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PHYS_PATH, 445 &vd->vdev_physpath) == 0) 446 vd->vdev_physpath = spa_strdup(vd->vdev_physpath); | 334 txg_list_create(&vd->vdev_ms_list, 335 offsetof(struct metaslab, ms_txg_node)); 336 txg_list_create(&vd->vdev_dtl_list, 337 offsetof(struct vdev, vdev_dtl_node)); 338 vd->vdev_stat.vs_timestamp = gethrtime(); 339 vdev_queue_init(vd); 340 vdev_cache_init(vd); 341 --- 99 unchanged lines hidden (view full) --- 441 442 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &vd->vdev_path) == 0) 443 vd->vdev_path = spa_strdup(vd->vdev_path); 444 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &vd->vdev_devid) == 0) 445 vd->vdev_devid = spa_strdup(vd->vdev_devid); 446 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PHYS_PATH, 447 &vd->vdev_physpath) == 0) 448 vd->vdev_physpath = spa_strdup(vd->vdev_physpath); |
449 if (nvlist_lookup_string(nv, ZPOOL_CONFIG_FRU, &vd->vdev_fru) == 0) 450 vd->vdev_fru = spa_strdup(vd->vdev_fru); |
|
447 448 /* 449 * Set the whole_disk property. If it's not specified, leave the value 450 * as -1. 451 */ 452 if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, 453 &vd->vdev_wholedisk) != 0) 454 vd->vdev_wholedisk = -1ULL; 455 456 /* 457 * Look for the 'not present' flag. This will only be set if the device 458 * was not present at the time of import. 459 */ | 451 452 /* 453 * Set the whole_disk property. If it's not specified, leave the value 454 * as -1. 455 */ 456 if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, 457 &vd->vdev_wholedisk) != 0) 458 vd->vdev_wholedisk = -1ULL; 459 460 /* 461 * Look for the 'not present' flag. This will only be set if the device 462 * was not present at the time of import. 463 */ |
460 if (!spa->spa_import_faulted) 461 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, 462 &vd->vdev_not_present); | 464 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, 465 &vd->vdev_not_present); |
463 464 /* 465 * Get the alignment requirement. 466 */ 467 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ASHIFT, &vd->vdev_ashift); 468 469 /* 470 * If we're a top-level vdev, try to load the allocation parameters. --- 9 unchanged lines hidden (view full) --- 480 481 /* 482 * If we're a leaf vdev, try to load the DTL object and other state. 483 */ 484 if (vd->vdev_ops->vdev_op_leaf && 485 (alloctype == VDEV_ALLOC_LOAD || alloctype == VDEV_ALLOC_L2CACHE)) { 486 if (alloctype == VDEV_ALLOC_LOAD) { 487 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_DTL, | 466 467 /* 468 * Get the alignment requirement. 469 */ 470 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ASHIFT, &vd->vdev_ashift); 471 472 /* 473 * If we're a top-level vdev, try to load the allocation parameters. --- 9 unchanged lines hidden (view full) --- 483 484 /* 485 * If we're a leaf vdev, try to load the DTL object and other state. 486 */ 487 if (vd->vdev_ops->vdev_op_leaf && 488 (alloctype == VDEV_ALLOC_LOAD || alloctype == VDEV_ALLOC_L2CACHE)) { 489 if (alloctype == VDEV_ALLOC_LOAD) { 490 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_DTL, |
488 &vd->vdev_dtl.smo_object); | 491 &vd->vdev_dtl_smo.smo_object); |
489 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_UNSPARE, 490 &vd->vdev_unspare); 491 } 492 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_OFFLINE, 493 &vd->vdev_offline); 494 495 /* 496 * When importing a pool, we want to ignore the persistent fault --- 67 unchanged lines hidden (view full) --- 564 vdev_cache_fini(vd); 565 566 if (vd->vdev_path) 567 spa_strfree(vd->vdev_path); 568 if (vd->vdev_devid) 569 spa_strfree(vd->vdev_devid); 570 if (vd->vdev_physpath) 571 spa_strfree(vd->vdev_physpath); | 492 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_UNSPARE, 493 &vd->vdev_unspare); 494 } 495 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_OFFLINE, 496 &vd->vdev_offline); 497 498 /* 499 * When importing a pool, we want to ignore the persistent fault --- 67 unchanged lines hidden (view full) --- 567 vdev_cache_fini(vd); 568 569 if (vd->vdev_path) 570 spa_strfree(vd->vdev_path); 571 if (vd->vdev_devid) 572 spa_strfree(vd->vdev_devid); 573 if (vd->vdev_physpath) 574 spa_strfree(vd->vdev_physpath); |
575 if (vd->vdev_fru) 576 spa_strfree(vd->vdev_fru); |
|
572 573 if (vd->vdev_isspare) 574 spa_spare_remove(vd); 575 if (vd->vdev_isl2cache) 576 spa_l2cache_remove(vd); 577 578 txg_list_destroy(&vd->vdev_ms_list); 579 txg_list_destroy(&vd->vdev_dtl_list); | 577 578 if (vd->vdev_isspare) 579 spa_spare_remove(vd); 580 if (vd->vdev_isl2cache) 581 spa_l2cache_remove(vd); 582 583 txg_list_destroy(&vd->vdev_ms_list); 584 txg_list_destroy(&vd->vdev_dtl_list); |
585 |
|
580 mutex_enter(&vd->vdev_dtl_lock); | 586 mutex_enter(&vd->vdev_dtl_lock); |
581 space_map_unload(&vd->vdev_dtl_map); 582 space_map_destroy(&vd->vdev_dtl_map); 583 space_map_vacate(&vd->vdev_dtl_scrub, NULL, NULL); 584 space_map_destroy(&vd->vdev_dtl_scrub); | 587 for (int t = 0; t < DTL_TYPES; t++) { 588 space_map_unload(&vd->vdev_dtl[t]); 589 space_map_destroy(&vd->vdev_dtl[t]); 590 } |
585 mutex_exit(&vd->vdev_dtl_lock); | 591 mutex_exit(&vd->vdev_dtl_lock); |
592 |
|
586 mutex_destroy(&vd->vdev_dtl_lock); 587 mutex_destroy(&vd->vdev_stat_lock); 588 mutex_destroy(&vd->vdev_probe_lock); 589 590 if (vd == spa->spa_root_vdev) 591 spa->spa_root_vdev = NULL; 592 593 kmem_free(vd, sizeof (vdev_t)); --- 121 unchanged lines hidden (view full) --- 715 ASSERT(mvd->vdev_children == 1); 716 ASSERT(mvd->vdev_ops == &vdev_mirror_ops || 717 mvd->vdev_ops == &vdev_replacing_ops || 718 mvd->vdev_ops == &vdev_spare_ops); 719 cvd->vdev_ashift = mvd->vdev_ashift; 720 721 vdev_remove_child(mvd, cvd); 722 vdev_remove_child(pvd, mvd); | 593 mutex_destroy(&vd->vdev_dtl_lock); 594 mutex_destroy(&vd->vdev_stat_lock); 595 mutex_destroy(&vd->vdev_probe_lock); 596 597 if (vd == spa->spa_root_vdev) 598 spa->spa_root_vdev = NULL; 599 600 kmem_free(vd, sizeof (vdev_t)); --- 121 unchanged lines hidden (view full) --- 722 ASSERT(mvd->vdev_children == 1); 723 ASSERT(mvd->vdev_ops == &vdev_mirror_ops || 724 mvd->vdev_ops == &vdev_replacing_ops || 725 mvd->vdev_ops == &vdev_spare_ops); 726 cvd->vdev_ashift = mvd->vdev_ashift; 727 728 vdev_remove_child(mvd, cvd); 729 vdev_remove_child(pvd, mvd); |
730 |
|
723 /* 724 * If cvd will replace mvd as a top-level vdev, preserve mvd's guid. 725 * Otherwise, we could have detached an offline device, and when we 726 * go to import the pool we'll think we have two top-level vdevs, 727 * instead of a different version of the same top-level vdev. 728 */ | 731 /* 732 * If cvd will replace mvd as a top-level vdev, preserve mvd's guid. 733 * Otherwise, we could have detached an offline device, and when we 734 * go to import the pool we'll think we have two top-level vdevs, 735 * instead of a different version of the same top-level vdev. 736 */ |
729 if (mvd->vdev_top == mvd) 730 cvd->vdev_guid = cvd->vdev_guid_sum = mvd->vdev_guid; | 737 if (mvd->vdev_top == mvd) { 738 uint64_t guid_delta = mvd->vdev_guid - cvd->vdev_guid; 739 cvd->vdev_guid += guid_delta; 740 cvd->vdev_guid_sum += guid_delta; 741 } |
731 cvd->vdev_id = mvd->vdev_id; 732 vdev_add_child(pvd, cvd); 733 vdev_top_update(cvd->vdev_top, cvd->vdev_top); 734 735 if (cvd == cvd->vdev_top) 736 vdev_top_transfer(mvd, cvd); 737 738 ASSERT(mvd->vdev_children == 0); --- 35 unchanged lines hidden (view full) --- 774 vd->vdev_ms = mspp; 775 vd->vdev_ms_count = newc; 776 777 for (m = oldc; m < newc; m++) { 778 space_map_obj_t smo = { 0, 0, 0 }; 779 if (txg == 0) { 780 uint64_t object = 0; 781 error = dmu_read(mos, vd->vdev_ms_array, | 742 cvd->vdev_id = mvd->vdev_id; 743 vdev_add_child(pvd, cvd); 744 vdev_top_update(cvd->vdev_top, cvd->vdev_top); 745 746 if (cvd == cvd->vdev_top) 747 vdev_top_transfer(mvd, cvd); 748 749 ASSERT(mvd->vdev_children == 0); --- 35 unchanged lines hidden (view full) --- 785 vd->vdev_ms = mspp; 786 vd->vdev_ms_count = newc; 787 788 for (m = oldc; m < newc; m++) { 789 space_map_obj_t smo = { 0, 0, 0 }; 790 if (txg == 0) { 791 uint64_t object = 0; 792 error = dmu_read(mos, vd->vdev_ms_array, |
782 m * sizeof (uint64_t), sizeof (uint64_t), &object); | 793 m * sizeof (uint64_t), sizeof (uint64_t), &object, 794 DMU_READ_PREFETCH); |
783 if (error) 784 return (error); 785 if (object != 0) { 786 dmu_buf_t *db; 787 error = dmu_bonus_hold(mos, object, FTAG, &db); 788 if (error) 789 return (error); 790 ASSERT3U(db->db_size, >=, sizeof (smo)); --- 23 unchanged lines hidden (view full) --- 814 vd->vdev_ms = NULL; 815 } 816} 817 818typedef struct vdev_probe_stats { 819 boolean_t vps_readable; 820 boolean_t vps_writeable; 821 int vps_flags; | 795 if (error) 796 return (error); 797 if (object != 0) { 798 dmu_buf_t *db; 799 error = dmu_bonus_hold(mos, object, FTAG, &db); 800 if (error) 801 return (error); 802 ASSERT3U(db->db_size, >=, sizeof (smo)); --- 23 unchanged lines hidden (view full) --- 826 vd->vdev_ms = NULL; 827 } 828} 829 830typedef struct vdev_probe_stats { 831 boolean_t vps_readable; 832 boolean_t vps_writeable; 833 int vps_flags; |
822 zio_t *vps_root; 823 vdev_t *vps_vd; | |
824} vdev_probe_stats_t; 825 826static void 827vdev_probe_done(zio_t *zio) 828{ | 834} vdev_probe_stats_t; 835 836static void 837vdev_probe_done(zio_t *zio) 838{ |
839 spa_t *spa = zio->io_spa; 840 vdev_t *vd = zio->io_vd; |
|
829 vdev_probe_stats_t *vps = zio->io_private; | 841 vdev_probe_stats_t *vps = zio->io_private; |
830 vdev_t *vd = vps->vps_vd; | |
831 | 842 |
843 ASSERT(vd->vdev_probe_zio != NULL); 844 |
|
832 if (zio->io_type == ZIO_TYPE_READ) { | 845 if (zio->io_type == ZIO_TYPE_READ) { |
833 ASSERT(zio->io_vd == vd); | |
834 if (zio->io_error == 0) 835 vps->vps_readable = 1; | 846 if (zio->io_error == 0) 847 vps->vps_readable = 1; |
836 if (zio->io_error == 0 && (spa_mode & FWRITE)) { 837 zio_nowait(zio_write_phys(vps->vps_root, vd, | 848 if (zio->io_error == 0 && spa_writeable(spa)) { 849 zio_nowait(zio_write_phys(vd->vdev_probe_zio, vd, |
838 zio->io_offset, zio->io_size, zio->io_data, 839 ZIO_CHECKSUM_OFF, vdev_probe_done, vps, 840 ZIO_PRIORITY_SYNC_WRITE, vps->vps_flags, B_TRUE)); 841 } else { 842 zio_buf_free(zio->io_data, zio->io_size); 843 } 844 } else if (zio->io_type == ZIO_TYPE_WRITE) { | 850 zio->io_offset, zio->io_size, zio->io_data, 851 ZIO_CHECKSUM_OFF, vdev_probe_done, vps, 852 ZIO_PRIORITY_SYNC_WRITE, vps->vps_flags, B_TRUE)); 853 } else { 854 zio_buf_free(zio->io_data, zio->io_size); 855 } 856 } else if (zio->io_type == ZIO_TYPE_WRITE) { |
845 ASSERT(zio->io_vd == vd); | |
846 if (zio->io_error == 0) 847 vps->vps_writeable = 1; 848 zio_buf_free(zio->io_data, zio->io_size); 849 } else if (zio->io_type == ZIO_TYPE_NULL) { | 857 if (zio->io_error == 0) 858 vps->vps_writeable = 1; 859 zio_buf_free(zio->io_data, zio->io_size); 860 } else if (zio->io_type == ZIO_TYPE_NULL) { |
850 ASSERT(zio->io_vd == NULL); 851 ASSERT(zio == vps->vps_root); | 861 zio_t *pio; |
852 853 vd->vdev_cant_read |= !vps->vps_readable; 854 vd->vdev_cant_write |= !vps->vps_writeable; 855 856 if (vdev_readable(vd) && | 862 863 vd->vdev_cant_read |= !vps->vps_readable; 864 vd->vdev_cant_write |= !vps->vps_writeable; 865 866 if (vdev_readable(vd) && |
857 (vdev_writeable(vd) || !(spa_mode & FWRITE))) { | 867 (vdev_writeable(vd) || !spa_writeable(spa))) { |
858 zio->io_error = 0; 859 } else { 860 ASSERT(zio->io_error != 0); 861 zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE, | 868 zio->io_error = 0; 869 } else { 870 ASSERT(zio->io_error != 0); 871 zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE, |
862 zio->io_spa, vd, NULL, 0, 0); | 872 spa, vd, NULL, 0, 0); |
863 zio->io_error = ENXIO; 864 } | 873 zio->io_error = ENXIO; 874 } |
875 876 mutex_enter(&vd->vdev_probe_lock); 877 ASSERT(vd->vdev_probe_zio == zio); 878 vd->vdev_probe_zio = NULL; 879 mutex_exit(&vd->vdev_probe_lock); 880 881 while ((pio = zio_walk_parents(zio)) != NULL) 882 if (!vdev_accessible(vd, pio)) 883 pio->io_error = ENXIO; 884 |
|
865 kmem_free(vps, sizeof (*vps)); 866 } 867} 868 869/* 870 * Determine whether this device is accessible by reading and writing 871 * to several known locations: the pad regions of each vdev label 872 * but the first (which we leave alone in case it contains a VTOC). 873 */ 874zio_t * | 885 kmem_free(vps, sizeof (*vps)); 886 } 887} 888 889/* 890 * Determine whether this device is accessible by reading and writing 891 * to several known locations: the pad regions of each vdev label 892 * but the first (which we leave alone in case it contains a VTOC). 893 */ 894zio_t * |
875vdev_probe(vdev_t *vd, zio_t *pio) | 895vdev_probe(vdev_t *vd, zio_t *zio) |
876{ 877 spa_t *spa = vd->vdev_spa; | 896{ 897 spa_t *spa = vd->vdev_spa; |
878 vdev_probe_stats_t *vps; 879 zio_t *zio; | 898 vdev_probe_stats_t *vps = NULL; 899 zio_t *pio; |
880 | 900 |
881 vps = kmem_zalloc(sizeof (*vps), KM_SLEEP); | 901 ASSERT(vd->vdev_ops->vdev_op_leaf); |
882 | 902 |
883 vps->vps_flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_PROBE | 884 ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_AGGREGATE | ZIO_FLAG_DONT_RETRY; | 903 /* 904 * Don't probe the probe. 905 */ 906 if (zio && (zio->io_flags & ZIO_FLAG_PROBE)) 907 return (NULL); |
885 | 908 |
886 if (spa_config_held(spa, SCL_ZIO, RW_WRITER)) { 887 /* 888 * vdev_cant_read and vdev_cant_write can only transition 889 * from TRUE to FALSE when we have the SCL_ZIO lock as writer; 890 * otherwise they can only transition from FALSE to TRUE. 891 * This ensures that any zio looking at these values can 892 * assume that failures persist for the life of the I/O. 893 * That's important because when a device has intermittent 894 * connectivity problems, we want to ensure that they're 895 * ascribed to the device (ENXIO) and not the zio (EIO). 896 * 897 * Since we hold SCL_ZIO as writer here, clear both values 898 * so the probe can reevaluate from first principles. 899 */ 900 vps->vps_flags |= ZIO_FLAG_CONFIG_WRITER; 901 vd->vdev_cant_read = B_FALSE; 902 vd->vdev_cant_write = B_FALSE; | 909 /* 910 * To prevent 'probe storms' when a device fails, we create 911 * just one probe i/o at a time. All zios that want to probe 912 * this vdev will become parents of the probe io. 913 */ 914 mutex_enter(&vd->vdev_probe_lock); 915 916 if ((pio = vd->vdev_probe_zio) == NULL) { 917 vps = kmem_zalloc(sizeof (*vps), KM_SLEEP); 918 919 vps->vps_flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_PROBE | 920 ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_AGGREGATE | 921 ZIO_FLAG_DONT_RETRY; 922 923 if (spa_config_held(spa, SCL_ZIO, RW_WRITER)) { 924 /* 925 * vdev_cant_read and vdev_cant_write can only 926 * transition from TRUE to FALSE when we have the 927 * SCL_ZIO lock as writer; otherwise they can only 928 * transition from FALSE to TRUE. This ensures that 929 * any zio looking at these values can assume that 930 * failures persist for the life of the I/O. That's 931 * important because when a device has intermittent 932 * connectivity problems, we want to ensure that 933 * they're ascribed to the device (ENXIO) and not 934 * the zio (EIO). 935 * 936 * Since we hold SCL_ZIO as writer here, clear both 937 * values so the probe can reevaluate from first 938 * principles. 939 */ 940 vps->vps_flags |= ZIO_FLAG_CONFIG_WRITER; 941 vd->vdev_cant_read = B_FALSE; 942 vd->vdev_cant_write = B_FALSE; 943 } 944 945 vd->vdev_probe_zio = pio = zio_null(NULL, spa, vd, 946 vdev_probe_done, vps, 947 vps->vps_flags | ZIO_FLAG_DONT_PROPAGATE); 948 949 if (zio != NULL) { 950 vd->vdev_probe_wanted = B_TRUE; 951 spa_async_request(spa, SPA_ASYNC_PROBE); 952 } |
903 } 904 | 953 } 954 |
905 ASSERT(vd->vdev_ops->vdev_op_leaf); | 955 if (zio != NULL) 956 zio_add_child(zio, pio); |
906 | 957 |
907 zio = zio_null(pio, spa, vdev_probe_done, vps, vps->vps_flags); | 958 mutex_exit(&vd->vdev_probe_lock); |
908 | 959 |
909 vps->vps_root = zio; 910 vps->vps_vd = vd; | 960 if (vps == NULL) { 961 ASSERT(zio != NULL); 962 return (NULL); 963 } |
911 912 for (int l = 1; l < VDEV_LABELS; l++) { | 964 965 for (int l = 1; l < VDEV_LABELS; l++) { |
913 zio_nowait(zio_read_phys(zio, vd, | 966 zio_nowait(zio_read_phys(pio, vd, |
914 vdev_label_offset(vd->vdev_psize, l, | 967 vdev_label_offset(vd->vdev_psize, l, |
915 offsetof(vdev_label_t, vl_pad)), 916 VDEV_SKIP_SIZE, zio_buf_alloc(VDEV_SKIP_SIZE), | 968 offsetof(vdev_label_t, vl_pad2)), 969 VDEV_PAD_SIZE, zio_buf_alloc(VDEV_PAD_SIZE), |
917 ZIO_CHECKSUM_OFF, vdev_probe_done, vps, 918 ZIO_PRIORITY_SYNC_READ, vps->vps_flags, B_TRUE)); 919 } 920 | 970 ZIO_CHECKSUM_OFF, vdev_probe_done, vps, 971 ZIO_PRIORITY_SYNC_READ, vps->vps_flags, B_TRUE)); 972 } 973 |
921 return (zio); | 974 if (zio == NULL) 975 return (pio); 976 977 zio_nowait(pio); 978 return (NULL); |
922} 923 924/* 925 * Prepare a virtual device for access. 926 */ 927int 928vdev_open(vdev_t *vd) 929{ | 979} 980 981/* 982 * Prepare a virtual device for access. 983 */ 984int 985vdev_open(vdev_t *vd) 986{ |
987 spa_t *spa = vd->vdev_spa; |
|
930 int error; 931 int c; 932 uint64_t osize = 0; 933 uint64_t asize, psize; 934 uint64_t ashift = 0; 935 | 988 int error; 989 int c; 990 uint64_t osize = 0; 991 uint64_t asize, psize; 992 uint64_t ashift = 0; 993 |
994 ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); 995 |
|
936 ASSERT(vd->vdev_state == VDEV_STATE_CLOSED || 937 vd->vdev_state == VDEV_STATE_CANT_OPEN || 938 vd->vdev_state == VDEV_STATE_OFFLINE); 939 940 vd->vdev_stat.vs_aux = VDEV_AUX_NONE; 941 942 if (!vd->vdev_removed && vd->vdev_faulted) { 943 ASSERT(vd->vdev_children == 0); --- 117 unchanged lines hidden (view full) --- 1061 */ 1062 if (vd->vdev_top == vd) { 1063 vd->vdev_deflate_ratio = (1<<17) / 1064 (vdev_psize_to_asize(vd, 1<<17) >> SPA_MINBLOCKSHIFT); 1065 } 1066 1067 /* 1068 * If a leaf vdev has a DTL, and seems healthy, then kick off a | 996 ASSERT(vd->vdev_state == VDEV_STATE_CLOSED || 997 vd->vdev_state == VDEV_STATE_CANT_OPEN || 998 vd->vdev_state == VDEV_STATE_OFFLINE); 999 1000 vd->vdev_stat.vs_aux = VDEV_AUX_NONE; 1001 1002 if (!vd->vdev_removed && vd->vdev_faulted) { 1003 ASSERT(vd->vdev_children == 0); --- 117 unchanged lines hidden (view full) --- 1121 */ 1122 if (vd->vdev_top == vd) { 1123 vd->vdev_deflate_ratio = (1<<17) / 1124 (vdev_psize_to_asize(vd, 1<<17) >> SPA_MINBLOCKSHIFT); 1125 } 1126 1127 /* 1128 * If a leaf vdev has a DTL, and seems healthy, then kick off a |
1069 * resilver. But don't do this if we are doing a reopen for a 1070 * scrub, since this would just restart the scrub we are already 1071 * doing. | 1129 * resilver. But don't do this if we are doing a reopen for a scrub, 1130 * since this would just restart the scrub we are already doing. |
1072 */ | 1131 */ |
1073 if (vd->vdev_children == 0 && !vd->vdev_spa->spa_scrub_reopen) { 1074 mutex_enter(&vd->vdev_dtl_lock); 1075 if (vd->vdev_dtl_map.sm_space != 0 && vdev_writeable(vd)) 1076 spa_async_request(vd->vdev_spa, SPA_ASYNC_RESILVER); 1077 mutex_exit(&vd->vdev_dtl_lock); 1078 } | 1132 if (vd->vdev_ops->vdev_op_leaf && !spa->spa_scrub_reopen && 1133 vdev_resilver_needed(vd, NULL, NULL)) 1134 spa_async_request(spa, SPA_ASYNC_RESILVER); |
1079 1080 return (0); 1081} 1082 1083/* 1084 * Called once the vdevs are all opened, this routine validates the label 1085 * contents. This needs to be done before vdev_load() so that we don't 1086 * inadvertently do repair I/Os to the wrong device. --- 62 unchanged lines hidden (view full) --- 1149 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, 1150 VDEV_AUX_CORRUPT_DATA); 1151 nvlist_free(label); 1152 return (0); 1153 } 1154 1155 nvlist_free(label); 1156 | 1135 1136 return (0); 1137} 1138 1139/* 1140 * Called once the vdevs are all opened, this routine validates the label 1141 * contents. This needs to be done before vdev_load() so that we don't 1142 * inadvertently do repair I/Os to the wrong device. --- 62 unchanged lines hidden (view full) --- 1205 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, 1206 VDEV_AUX_CORRUPT_DATA); 1207 nvlist_free(label); 1208 return (0); 1209 } 1210 1211 nvlist_free(label); 1212 |
1157 if (spa->spa_load_state == SPA_LOAD_OPEN && | 1213 /* 1214 * If spa->spa_load_verbatim is true, no need to check the 1215 * state of the pool. 1216 */ 1217 if (!spa->spa_load_verbatim && 1218 spa->spa_load_state == SPA_LOAD_OPEN && |
1158 state != POOL_STATE_ACTIVE) 1159 return (EBADF); 1160 1161 /* 1162 * If we were able to open and validate a vdev that was 1163 * previously marked permanently unavailable, clear that state 1164 * now. 1165 */ --- 5 unchanged lines hidden (view full) --- 1171} 1172 1173/* 1174 * Close a virtual device. 1175 */ 1176void 1177vdev_close(vdev_t *vd) 1178{ | 1219 state != POOL_STATE_ACTIVE) 1220 return (EBADF); 1221 1222 /* 1223 * If we were able to open and validate a vdev that was 1224 * previously marked permanently unavailable, clear that state 1225 * now. 1226 */ --- 5 unchanged lines hidden (view full) --- 1232} 1233 1234/* 1235 * Close a virtual device. 1236 */ 1237void 1238vdev_close(vdev_t *vd) 1239{ |
1240 spa_t *spa = vd->vdev_spa; 1241 1242 ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); 1243 |
|
1179 vd->vdev_ops->vdev_op_close(vd); 1180 1181 vdev_cache_purge(vd); 1182 1183 /* 1184 * We record the previous state before we close it, so that if we are 1185 * doing a reopen(), we don't generate FMA ereports if we notice that 1186 * it's still faulted. --- 20 unchanged lines hidden (view full) --- 1207 /* 1208 * Call vdev_validate() here to make sure we have the same device. 1209 * Otherwise, a device with an invalid label could be successfully 1210 * opened in response to vdev_reopen(). 1211 */ 1212 if (vd->vdev_aux) { 1213 (void) vdev_validate_aux(vd); 1214 if (vdev_readable(vd) && vdev_writeable(vd) && | 1244 vd->vdev_ops->vdev_op_close(vd); 1245 1246 vdev_cache_purge(vd); 1247 1248 /* 1249 * We record the previous state before we close it, so that if we are 1250 * doing a reopen(), we don't generate FMA ereports if we notice that 1251 * it's still faulted. --- 20 unchanged lines hidden (view full) --- 1272 /* 1273 * Call vdev_validate() here to make sure we have the same device. 1274 * Otherwise, a device with an invalid label could be successfully 1275 * opened in response to vdev_reopen(). 1276 */ 1277 if (vd->vdev_aux) { 1278 (void) vdev_validate_aux(vd); 1279 if (vdev_readable(vd) && vdev_writeable(vd) && |
1280 vd->vdev_aux == &spa->spa_l2cache && |
|
1215 !l2arc_vdev_present(vd)) { 1216 uint64_t size = vdev_get_rsize(vd); 1217 l2arc_add_vdev(spa, vd, 1218 VDEV_LABEL_START_SIZE, 1219 size - VDEV_LABEL_START_SIZE); 1220 } 1221 } else { 1222 (void) vdev_validate(vd); --- 66 unchanged lines hidden (view full) --- 1289 (void) txg_list_add(&vd->vdev_ms_list, arg, txg); 1290 1291 if (flags & VDD_DTL) 1292 (void) txg_list_add(&vd->vdev_dtl_list, arg, txg); 1293 1294 (void) txg_list_add(&vd->vdev_spa->spa_vdev_txg_list, vd, txg); 1295} 1296 | 1281 !l2arc_vdev_present(vd)) { 1282 uint64_t size = vdev_get_rsize(vd); 1283 l2arc_add_vdev(spa, vd, 1284 VDEV_LABEL_START_SIZE, 1285 size - VDEV_LABEL_START_SIZE); 1286 } 1287 } else { 1288 (void) vdev_validate(vd); --- 66 unchanged lines hidden (view full) --- 1355 (void) txg_list_add(&vd->vdev_ms_list, arg, txg); 1356 1357 if (flags & VDD_DTL) 1358 (void) txg_list_add(&vd->vdev_dtl_list, arg, txg); 1359 1360 (void) txg_list_add(&vd->vdev_spa->spa_vdev_txg_list, vd, txg); 1361} 1362 |
1363/* 1364 * DTLs. 1365 * 1366 * A vdev's DTL (dirty time log) is the set of transaction groups for which 1367 * the vdev has less than perfect replication. There are three kinds of DTL: 1368 * 1369 * DTL_MISSING: txgs for which the vdev has no valid copies of the data 1370 * 1371 * DTL_PARTIAL: txgs for which data is available, but not fully replicated 1372 * 1373 * DTL_SCRUB: the txgs that could not be repaired by the last scrub; upon 1374 * scrub completion, DTL_SCRUB replaces DTL_MISSING in the range of 1375 * txgs that was scrubbed. 1376 * 1377 * DTL_OUTAGE: txgs which cannot currently be read, whether due to 1378 * persistent errors or just some device being offline. 1379 * Unlike the other three, the DTL_OUTAGE map is not generally 1380 * maintained; it's only computed when needed, typically to 1381 * determine whether a device can be detached. 1382 * 1383 * For leaf vdevs, DTL_MISSING and DTL_PARTIAL are identical: the device 1384 * either has the data or it doesn't. 1385 * 1386 * For interior vdevs such as mirror and RAID-Z the picture is more complex. 1387 * A vdev's DTL_PARTIAL is the union of its children's DTL_PARTIALs, because 1388 * if any child is less than fully replicated, then so is its parent. 1389 * A vdev's DTL_MISSING is a modified union of its children's DTL_MISSINGs, 1390 * comprising only those txgs which appear in 'maxfaults' or more children; 1391 * those are the txgs we don't have enough replication to read. For example, 1392 * double-parity RAID-Z can tolerate up to two missing devices (maxfaults == 2); 1393 * thus, its DTL_MISSING consists of the set of txgs that appear in more than 1394 * two child DTL_MISSING maps. 1395 * 1396 * It should be clear from the above that to compute the DTLs and outage maps 1397 * for all vdevs, it suffices to know just the leaf vdevs' DTL_MISSING maps. 1398 * Therefore, that is all we keep on disk. When loading the pool, or after 1399 * a configuration change, we generate all other DTLs from first principles. 1400 */ |
|
1297void | 1401void |
1298vdev_dtl_dirty(space_map_t *sm, uint64_t txg, uint64_t size) | 1402vdev_dtl_dirty(vdev_t *vd, vdev_dtl_type_t t, uint64_t txg, uint64_t size) |
1299{ | 1403{ |
1404 space_map_t *sm = &vd->vdev_dtl[t]; 1405 1406 ASSERT(t < DTL_TYPES); 1407 ASSERT(vd != vd->vdev_spa->spa_root_vdev); 1408 |
|
1300 mutex_enter(sm->sm_lock); 1301 if (!space_map_contains(sm, txg, size)) 1302 space_map_add(sm, txg, size); 1303 mutex_exit(sm->sm_lock); 1304} 1305 | 1409 mutex_enter(sm->sm_lock); 1410 if (!space_map_contains(sm, txg, size)) 1411 space_map_add(sm, txg, size); 1412 mutex_exit(sm->sm_lock); 1413} 1414 |
1306int 1307vdev_dtl_contains(space_map_t *sm, uint64_t txg, uint64_t size) | 1415boolean_t 1416vdev_dtl_contains(vdev_t *vd, vdev_dtl_type_t t, uint64_t txg, uint64_t size) |
1308{ | 1417{ |
1309 int dirty; | 1418 space_map_t *sm = &vd->vdev_dtl[t]; 1419 boolean_t dirty = B_FALSE; |
1310 | 1420 |
1311 /* 1312 * Quick test without the lock -- covers the common case that 1313 * there are no dirty time segments. 1314 */ 1315 if (sm->sm_space == 0) 1316 return (0); | 1421 ASSERT(t < DTL_TYPES); 1422 ASSERT(vd != vd->vdev_spa->spa_root_vdev); |
1317 1318 mutex_enter(sm->sm_lock); | 1423 1424 mutex_enter(sm->sm_lock); |
1319 dirty = space_map_contains(sm, txg, size); | 1425 if (sm->sm_space != 0) 1426 dirty = space_map_contains(sm, txg, size); |
1320 mutex_exit(sm->sm_lock); 1321 1322 return (dirty); 1323} 1324 | 1427 mutex_exit(sm->sm_lock); 1428 1429 return (dirty); 1430} 1431 |
1432boolean_t 1433vdev_dtl_empty(vdev_t *vd, vdev_dtl_type_t t) 1434{ 1435 space_map_t *sm = &vd->vdev_dtl[t]; 1436 boolean_t empty; 1437 1438 mutex_enter(sm->sm_lock); 1439 empty = (sm->sm_space == 0); 1440 mutex_exit(sm->sm_lock); 1441 1442 return (empty); 1443} 1444 |
|
1325/* 1326 * Reassess DTLs after a config change or scrub completion. 1327 */ 1328void 1329vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) 1330{ 1331 spa_t *spa = vd->vdev_spa; | 1445/* 1446 * Reassess DTLs after a config change or scrub completion. 1447 */ 1448void 1449vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) 1450{ 1451 spa_t *spa = vd->vdev_spa; |
1332 int c; | 1452 avl_tree_t reftree; 1453 int minref; |
1333 | 1454 |
1334 ASSERT(spa_config_held(spa, SCL_CONFIG, RW_READER)); | 1455 ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); |
1335 | 1456 |
1336 if (vd->vdev_children == 0) { | 1457 for (int c = 0; c < vd->vdev_children; c++) 1458 vdev_dtl_reassess(vd->vdev_child[c], txg, 1459 scrub_txg, scrub_done); 1460 1461 if (vd == spa->spa_root_vdev) 1462 return; 1463 1464 if (vd->vdev_ops->vdev_op_leaf) { |
1337 mutex_enter(&vd->vdev_dtl_lock); 1338 if (scrub_txg != 0 && 1339 (spa->spa_scrub_started || spa->spa_scrub_errors == 0)) { 1340 /* XXX should check scrub_done? */ 1341 /* 1342 * We completed a scrub up to scrub_txg. If we 1343 * did it without rebooting, then the scrub dtl 1344 * will be valid, so excise the old region and 1345 * fold in the scrub dtl. Otherwise, leave the 1346 * dtl as-is if there was an error. | 1465 mutex_enter(&vd->vdev_dtl_lock); 1466 if (scrub_txg != 0 && 1467 (spa->spa_scrub_started || spa->spa_scrub_errors == 0)) { 1468 /* XXX should check scrub_done? */ 1469 /* 1470 * We completed a scrub up to scrub_txg. If we 1471 * did it without rebooting, then the scrub dtl 1472 * will be valid, so excise the old region and 1473 * fold in the scrub dtl. Otherwise, leave the 1474 * dtl as-is if there was an error. |
1475 * 1476 * There's little trick here: to excise the beginning 1477 * of the DTL_MISSING map, we put it into a reference 1478 * tree and then add a segment with refcnt -1 that 1479 * covers the range [0, scrub_txg). This means 1480 * that each txg in that range has refcnt -1 or 0. 1481 * We then add DTL_SCRUB with a refcnt of 2, so that 1482 * entries in the range [0, scrub_txg) will have a 1483 * positive refcnt -- either 1 or 2. We then convert 1484 * the reference tree into the new DTL_MISSING map. |
|
1347 */ | 1485 */ |
1348 space_map_excise(&vd->vdev_dtl_map, 0, scrub_txg); 1349 space_map_union(&vd->vdev_dtl_map, &vd->vdev_dtl_scrub); | 1486 space_map_ref_create(&reftree); 1487 space_map_ref_add_map(&reftree, 1488 &vd->vdev_dtl[DTL_MISSING], 1); 1489 space_map_ref_add_seg(&reftree, 0, scrub_txg, -1); 1490 space_map_ref_add_map(&reftree, 1491 &vd->vdev_dtl[DTL_SCRUB], 2); 1492 space_map_ref_generate_map(&reftree, 1493 &vd->vdev_dtl[DTL_MISSING], 1); 1494 space_map_ref_destroy(&reftree); |
1350 } | 1495 } |
1496 space_map_vacate(&vd->vdev_dtl[DTL_PARTIAL], NULL, NULL); 1497 space_map_walk(&vd->vdev_dtl[DTL_MISSING], 1498 space_map_add, &vd->vdev_dtl[DTL_PARTIAL]); |
|
1351 if (scrub_done) | 1499 if (scrub_done) |
1352 space_map_vacate(&vd->vdev_dtl_scrub, NULL, NULL); | 1500 space_map_vacate(&vd->vdev_dtl[DTL_SCRUB], NULL, NULL); 1501 space_map_vacate(&vd->vdev_dtl[DTL_OUTAGE], NULL, NULL); 1502 if (!vdev_readable(vd)) 1503 space_map_add(&vd->vdev_dtl[DTL_OUTAGE], 0, -1ULL); 1504 else 1505 space_map_walk(&vd->vdev_dtl[DTL_MISSING], 1506 space_map_add, &vd->vdev_dtl[DTL_OUTAGE]); |
1353 mutex_exit(&vd->vdev_dtl_lock); 1354 1355 if (txg != 0) 1356 vdev_dirty(vd->vdev_top, VDD_DTL, vd, txg); 1357 return; 1358 } 1359 | 1507 mutex_exit(&vd->vdev_dtl_lock); 1508 1509 if (txg != 0) 1510 vdev_dirty(vd->vdev_top, VDD_DTL, vd, txg); 1511 return; 1512 } 1513 |
1360 /* 1361 * Make sure the DTLs are always correct under the scrub lock. 1362 */ 1363 if (vd == spa->spa_root_vdev) 1364 mutex_enter(&spa->spa_scrub_lock); 1365 | |
1366 mutex_enter(&vd->vdev_dtl_lock); | 1514 mutex_enter(&vd->vdev_dtl_lock); |
1367 space_map_vacate(&vd->vdev_dtl_map, NULL, NULL); 1368 space_map_vacate(&vd->vdev_dtl_scrub, NULL, NULL); 1369 mutex_exit(&vd->vdev_dtl_lock); 1370 1371 for (c = 0; c < vd->vdev_children; c++) { 1372 vdev_t *cvd = vd->vdev_child[c]; 1373 vdev_dtl_reassess(cvd, txg, scrub_txg, scrub_done); 1374 mutex_enter(&vd->vdev_dtl_lock); 1375 space_map_union(&vd->vdev_dtl_map, &cvd->vdev_dtl_map); 1376 space_map_union(&vd->vdev_dtl_scrub, &cvd->vdev_dtl_scrub); 1377 mutex_exit(&vd->vdev_dtl_lock); | 1515 for (int t = 0; t < DTL_TYPES; t++) { 1516 /* account for child's outage in parent's missing map */ 1517 int s = (t == DTL_MISSING) ? DTL_OUTAGE: t; 1518 if (t == DTL_SCRUB) 1519 continue; /* leaf vdevs only */ 1520 if (t == DTL_PARTIAL) 1521 minref = 1; /* i.e. non-zero */ 1522 else if (vd->vdev_nparity != 0) 1523 minref = vd->vdev_nparity + 1; /* RAID-Z */ 1524 else 1525 minref = vd->vdev_children; /* any kind of mirror */ 1526 space_map_ref_create(&reftree); 1527 for (int c = 0; c < vd->vdev_children; c++) { 1528 vdev_t *cvd = vd->vdev_child[c]; 1529 mutex_enter(&cvd->vdev_dtl_lock); 1530 space_map_ref_add_map(&reftree, &cvd->vdev_dtl[s], 1); 1531 mutex_exit(&cvd->vdev_dtl_lock); 1532 } 1533 space_map_ref_generate_map(&reftree, &vd->vdev_dtl[t], minref); 1534 space_map_ref_destroy(&reftree); |
1378 } | 1535 } |
1379 1380 if (vd == spa->spa_root_vdev) 1381 mutex_exit(&spa->spa_scrub_lock); | 1536 mutex_exit(&vd->vdev_dtl_lock); |
1382} 1383 1384static int 1385vdev_dtl_load(vdev_t *vd) 1386{ 1387 spa_t *spa = vd->vdev_spa; | 1537} 1538 1539static int 1540vdev_dtl_load(vdev_t *vd) 1541{ 1542 spa_t *spa = vd->vdev_spa; |
1388 space_map_obj_t *smo = &vd->vdev_dtl; | 1543 space_map_obj_t *smo = &vd->vdev_dtl_smo; |
1389 objset_t *mos = spa->spa_meta_objset; 1390 dmu_buf_t *db; 1391 int error; 1392 1393 ASSERT(vd->vdev_children == 0); 1394 1395 if (smo->smo_object == 0) 1396 return (0); 1397 1398 if ((error = dmu_bonus_hold(mos, smo->smo_object, FTAG, &db)) != 0) 1399 return (error); 1400 1401 ASSERT3U(db->db_size, >=, sizeof (*smo)); 1402 bcopy(db->db_data, smo, sizeof (*smo)); 1403 dmu_buf_rele(db, FTAG); 1404 1405 mutex_enter(&vd->vdev_dtl_lock); | 1544 objset_t *mos = spa->spa_meta_objset; 1545 dmu_buf_t *db; 1546 int error; 1547 1548 ASSERT(vd->vdev_children == 0); 1549 1550 if (smo->smo_object == 0) 1551 return (0); 1552 1553 if ((error = dmu_bonus_hold(mos, smo->smo_object, FTAG, &db)) != 0) 1554 return (error); 1555 1556 ASSERT3U(db->db_size, >=, sizeof (*smo)); 1557 bcopy(db->db_data, smo, sizeof (*smo)); 1558 dmu_buf_rele(db, FTAG); 1559 1560 mutex_enter(&vd->vdev_dtl_lock); |
1406 error = space_map_load(&vd->vdev_dtl_map, NULL, SM_ALLOC, smo, mos); | 1561 error = space_map_load(&vd->vdev_dtl[DTL_MISSING], 1562 NULL, SM_ALLOC, smo, mos); |
1407 mutex_exit(&vd->vdev_dtl_lock); 1408 1409 return (error); 1410} 1411 1412void 1413vdev_dtl_sync(vdev_t *vd, uint64_t txg) 1414{ 1415 spa_t *spa = vd->vdev_spa; | 1563 mutex_exit(&vd->vdev_dtl_lock); 1564 1565 return (error); 1566} 1567 1568void 1569vdev_dtl_sync(vdev_t *vd, uint64_t txg) 1570{ 1571 spa_t *spa = vd->vdev_spa; |
1416 space_map_obj_t *smo = &vd->vdev_dtl; 1417 space_map_t *sm = &vd->vdev_dtl_map; | 1572 space_map_obj_t *smo = &vd->vdev_dtl_smo; 1573 space_map_t *sm = &vd->vdev_dtl[DTL_MISSING]; |
1418 objset_t *mos = spa->spa_meta_objset; 1419 space_map_t smsync; 1420 kmutex_t smlock; 1421 dmu_buf_t *db; 1422 dmu_tx_t *tx; 1423 1424 tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg); 1425 --- 41 unchanged lines hidden (view full) --- 1467 ASSERT3U(db->db_size, >=, sizeof (*smo)); 1468 bcopy(smo, db->db_data, sizeof (*smo)); 1469 dmu_buf_rele(db, FTAG); 1470 1471 dmu_tx_commit(tx); 1472} 1473 1474/* | 1574 objset_t *mos = spa->spa_meta_objset; 1575 space_map_t smsync; 1576 kmutex_t smlock; 1577 dmu_buf_t *db; 1578 dmu_tx_t *tx; 1579 1580 tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg); 1581 --- 41 unchanged lines hidden (view full) --- 1623 ASSERT3U(db->db_size, >=, sizeof (*smo)); 1624 bcopy(smo, db->db_data, sizeof (*smo)); 1625 dmu_buf_rele(db, FTAG); 1626 1627 dmu_tx_commit(tx); 1628} 1629 1630/* |
1631 * Determine whether the specified vdev can be offlined/detached/removed 1632 * without losing data. 1633 */ 1634boolean_t 1635vdev_dtl_required(vdev_t *vd) 1636{ 1637 spa_t *spa = vd->vdev_spa; 1638 vdev_t *tvd = vd->vdev_top; 1639 uint8_t cant_read = vd->vdev_cant_read; 1640 boolean_t required; 1641 1642 ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); 1643 1644 if (vd == spa->spa_root_vdev || vd == tvd) 1645 return (B_TRUE); 1646 1647 /* 1648 * Temporarily mark the device as unreadable, and then determine 1649 * whether this results in any DTL outages in the top-level vdev. 1650 * If not, we can safely offline/detach/remove the device. 1651 */ 1652 vd->vdev_cant_read = B_TRUE; 1653 vdev_dtl_reassess(tvd, 0, 0, B_FALSE); 1654 required = !vdev_dtl_empty(tvd, DTL_OUTAGE); 1655 vd->vdev_cant_read = cant_read; 1656 vdev_dtl_reassess(tvd, 0, 0, B_FALSE); 1657 1658 return (required); 1659} 1660 1661/* |
|
1475 * Determine if resilver is needed, and if so the txg range. 1476 */ 1477boolean_t 1478vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) 1479{ 1480 boolean_t needed = B_FALSE; 1481 uint64_t thismin = UINT64_MAX; 1482 uint64_t thismax = 0; 1483 1484 if (vd->vdev_children == 0) { 1485 mutex_enter(&vd->vdev_dtl_lock); | 1662 * Determine if resilver is needed, and if so the txg range. 1663 */ 1664boolean_t 1665vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) 1666{ 1667 boolean_t needed = B_FALSE; 1668 uint64_t thismin = UINT64_MAX; 1669 uint64_t thismax = 0; 1670 1671 if (vd->vdev_children == 0) { 1672 mutex_enter(&vd->vdev_dtl_lock); |
1486 if (vd->vdev_dtl_map.sm_space != 0 && vdev_writeable(vd)) { | 1673 if (vd->vdev_dtl[DTL_MISSING].sm_space != 0 && 1674 vdev_writeable(vd)) { |
1487 space_seg_t *ss; 1488 | 1675 space_seg_t *ss; 1676 |
1489 ss = avl_first(&vd->vdev_dtl_map.sm_root); | 1677 ss = avl_first(&vd->vdev_dtl[DTL_MISSING].sm_root); |
1490 thismin = ss->ss_start - 1; | 1678 thismin = ss->ss_start - 1; |
1491 ss = avl_last(&vd->vdev_dtl_map.sm_root); | 1679 ss = avl_last(&vd->vdev_dtl[DTL_MISSING].sm_root); |
1492 thismax = ss->ss_end; 1493 needed = B_TRUE; 1494 } 1495 mutex_exit(&vd->vdev_dtl_lock); 1496 } else { | 1680 thismax = ss->ss_end; 1681 needed = B_TRUE; 1682 } 1683 mutex_exit(&vd->vdev_dtl_lock); 1684 } else { |
1497 int c; 1498 for (c = 0; c < vd->vdev_children; c++) { | 1685 for (int c = 0; c < vd->vdev_children; c++) { |
1499 vdev_t *cvd = vd->vdev_child[c]; 1500 uint64_t cmin, cmax; 1501 1502 if (vdev_resilver_needed(cvd, &cmin, &cmax)) { 1503 thismin = MIN(thismin, cmin); 1504 thismax = MAX(thismax, cmax); 1505 needed = B_TRUE; 1506 } --- 5 unchanged lines hidden (view full) --- 1512 *maxp = thismax; 1513 } 1514 return (needed); 1515} 1516 1517void 1518vdev_load(vdev_t *vd) 1519{ | 1686 vdev_t *cvd = vd->vdev_child[c]; 1687 uint64_t cmin, cmax; 1688 1689 if (vdev_resilver_needed(cvd, &cmin, &cmax)) { 1690 thismin = MIN(thismin, cmin); 1691 thismax = MAX(thismax, cmax); 1692 needed = B_TRUE; 1693 } --- 5 unchanged lines hidden (view full) --- 1699 *maxp = thismax; 1700 } 1701 return (needed); 1702} 1703 1704void 1705vdev_load(vdev_t *vd) 1706{ |
1520 int c; 1521 | |
1522 /* 1523 * Recursively load all children. 1524 */ | 1707 /* 1708 * Recursively load all children. 1709 */ |
1525 for (c = 0; c < vd->vdev_children; c++) | 1710 for (int c = 0; c < vd->vdev_children; c++) |
1526 vdev_load(vd->vdev_child[c]); 1527 1528 /* 1529 * If this is a top-level vdev, initialize its metaslabs. 1530 */ 1531 if (vd == vd->vdev_top && 1532 (vd->vdev_ashift == 0 || vd->vdev_asize == 0 || 1533 vdev_metaslab_init(vd, 0) != 0)) --- 203 unchanged lines hidden (view full) --- 1737 if (newstate) 1738 *newstate = vd->vdev_state; 1739 if ((flags & ZFS_ONLINE_UNSPARE) && 1740 !vdev_is_dead(vd) && vd->vdev_parent && 1741 vd->vdev_parent->vdev_ops == &vdev_spare_ops && 1742 vd->vdev_parent->vdev_child[0] == vd) 1743 vd->vdev_unspare = B_TRUE; 1744 | 1711 vdev_load(vd->vdev_child[c]); 1712 1713 /* 1714 * If this is a top-level vdev, initialize its metaslabs. 1715 */ 1716 if (vd == vd->vdev_top && 1717 (vd->vdev_ashift == 0 || vd->vdev_asize == 0 || 1718 vdev_metaslab_init(vd, 0) != 0)) --- 203 unchanged lines hidden (view full) --- 1922 if (newstate) 1923 *newstate = vd->vdev_state; 1924 if ((flags & ZFS_ONLINE_UNSPARE) && 1925 !vdev_is_dead(vd) && vd->vdev_parent && 1926 vd->vdev_parent->vdev_ops == &vdev_spare_ops && 1927 vd->vdev_parent->vdev_child[0] == vd) 1928 vd->vdev_unspare = B_TRUE; 1929 |
1745 (void) spa_vdev_state_exit(spa, vd, 0); 1746 1747 VERIFY3U(spa_scrub(spa, POOL_SCRUB_RESILVER), ==, 0); 1748 1749 return (0); | 1930 return (spa_vdev_state_exit(spa, vd, 0)); |
1750} 1751 1752int 1753vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags) 1754{ 1755 vdev_t *vd; 1756 1757 spa_vdev_state_enter(spa); --- 4 unchanged lines hidden (view full) --- 1762 if (!vd->vdev_ops->vdev_op_leaf) 1763 return (spa_vdev_state_exit(spa, NULL, ENOTSUP)); 1764 1765 /* 1766 * If the device isn't already offline, try to offline it. 1767 */ 1768 if (!vd->vdev_offline) { 1769 /* | 1931} 1932 1933int 1934vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags) 1935{ 1936 vdev_t *vd; 1937 1938 spa_vdev_state_enter(spa); --- 4 unchanged lines hidden (view full) --- 1943 if (!vd->vdev_ops->vdev_op_leaf) 1944 return (spa_vdev_state_exit(spa, NULL, ENOTSUP)); 1945 1946 /* 1947 * If the device isn't already offline, try to offline it. 1948 */ 1949 if (!vd->vdev_offline) { 1950 /* |
1770 * If this device's top-level vdev has a non-empty DTL, 1771 * don't allow the device to be offlined. 1772 * 1773 * XXX -- make this more precise by allowing the offline 1774 * as long as the remaining devices don't have any DTL holes. | 1951 * If this device has the only valid copy of some data, 1952 * don't allow it to be offlined. |
1775 */ | 1953 */ |
1776 if (vd->vdev_top->vdev_dtl_map.sm_space != 0) | 1954 if (vd->vdev_aux == NULL && vdev_dtl_required(vd)) |
1777 return (spa_vdev_state_exit(spa, NULL, EBUSY)); 1778 1779 /* 1780 * Offline this device and reopen its top-level vdev. 1781 * If this action results in the top-level vdev becoming 1782 * unusable, undo it and fail the request. 1783 */ 1784 vd->vdev_offline = B_TRUE; 1785 vdev_reopen(vd->vdev_top); | 1955 return (spa_vdev_state_exit(spa, NULL, EBUSY)); 1956 1957 /* 1958 * Offline this device and reopen its top-level vdev. 1959 * If this action results in the top-level vdev becoming 1960 * unusable, undo it and fail the request. 1961 */ 1962 vd->vdev_offline = B_TRUE; 1963 vdev_reopen(vd->vdev_top); |
1786 if (vdev_is_dead(vd->vdev_top) && vd->vdev_aux == NULL) { | 1964 if (vd->vdev_aux == NULL && vdev_is_dead(vd->vdev_top)) { |
1787 vd->vdev_offline = B_FALSE; 1788 vdev_reopen(vd->vdev_top); 1789 return (spa_vdev_state_exit(spa, NULL, EBUSY)); 1790 } 1791 } 1792 1793 vd->vdev_tmpoffline = !!(flags & ZFS_OFFLINE_TEMPORARY); 1794 --- 63 unchanged lines hidden (view full) --- 1858vdev_writeable(vdev_t *vd) 1859{ 1860 return (!vdev_is_dead(vd) && !vd->vdev_cant_write); 1861} 1862 1863boolean_t 1864vdev_allocatable(vdev_t *vd) 1865{ | 1965 vd->vdev_offline = B_FALSE; 1966 vdev_reopen(vd->vdev_top); 1967 return (spa_vdev_state_exit(spa, NULL, EBUSY)); 1968 } 1969 } 1970 1971 vd->vdev_tmpoffline = !!(flags & ZFS_OFFLINE_TEMPORARY); 1972 --- 63 unchanged lines hidden (view full) --- 2036vdev_writeable(vdev_t *vd) 2037{ 2038 return (!vdev_is_dead(vd) && !vd->vdev_cant_write); 2039} 2040 2041boolean_t 2042vdev_allocatable(vdev_t *vd) 2043{ |
2044 uint64_t state = vd->vdev_state; 2045 |
|
1866 /* | 2046 /* |
1867 * We currently allow allocations from vdevs which maybe in the | 2047 * We currently allow allocations from vdevs which may be in the |
1868 * process of reopening (i.e. VDEV_STATE_CLOSED). If the device 1869 * fails to reopen then we'll catch it later when we're holding | 2048 * process of reopening (i.e. VDEV_STATE_CLOSED). If the device 2049 * fails to reopen then we'll catch it later when we're holding |
1870 * the proper locks. | 2050 * the proper locks. Note that we have to get the vdev state 2051 * in a local variable because although it changes atomically, 2052 * we're asking two separate questions about it. |
1871 */ | 2053 */ |
1872 return (!(vdev_is_dead(vd) && vd->vdev_state != VDEV_STATE_CLOSED) && | 2054 return (!(state < VDEV_STATE_DEGRADED && state != VDEV_STATE_CLOSED) && |
1873 !vd->vdev_cant_write); 1874} 1875 1876boolean_t 1877vdev_accessible(vdev_t *vd, zio_t *zio) 1878{ 1879 ASSERT(zio->io_vd == vd); 1880 --- 53 unchanged lines hidden (view full) --- 1934 vd->vdev_stat.vs_dspace = 0; 1935 vd->vdev_stat.vs_alloc = 0; 1936 mutex_exit(&vd->vdev_stat_lock); 1937} 1938 1939void 1940vdev_stat_update(zio_t *zio, uint64_t psize) 1941{ | 2055 !vd->vdev_cant_write); 2056} 2057 2058boolean_t 2059vdev_accessible(vdev_t *vd, zio_t *zio) 2060{ 2061 ASSERT(zio->io_vd == vd); 2062 --- 53 unchanged lines hidden (view full) --- 2116 vd->vdev_stat.vs_dspace = 0; 2117 vd->vdev_stat.vs_alloc = 0; 2118 mutex_exit(&vd->vdev_stat_lock); 2119} 2120 2121void 2122vdev_stat_update(zio_t *zio, uint64_t psize) 2123{ |
1942 vdev_t *rvd = zio->io_spa->spa_root_vdev; | 2124 spa_t *spa = zio->io_spa; 2125 vdev_t *rvd = spa->spa_root_vdev; |
1943 vdev_t *vd = zio->io_vd ? zio->io_vd : rvd; 1944 vdev_t *pvd; 1945 uint64_t txg = zio->io_txg; 1946 vdev_stat_t *vs = &vd->vdev_stat; 1947 zio_type_t type = zio->io_type; 1948 int flags = zio->io_flags; 1949 1950 /* --- 16 unchanged lines hidden (view full) --- 1967 * because unlike i/o counts, errors are not additive. 1968 * When reading a ditto block, for example, failure of 1969 * one top-level vdev does not imply a root-level error. 1970 */ 1971 if (vd == rvd) 1972 return; 1973 1974 ASSERT(vd == zio->io_vd); | 2126 vdev_t *vd = zio->io_vd ? zio->io_vd : rvd; 2127 vdev_t *pvd; 2128 uint64_t txg = zio->io_txg; 2129 vdev_stat_t *vs = &vd->vdev_stat; 2130 zio_type_t type = zio->io_type; 2131 int flags = zio->io_flags; 2132 2133 /* --- 16 unchanged lines hidden (view full) --- 2150 * because unlike i/o counts, errors are not additive. 2151 * When reading a ditto block, for example, failure of 2152 * one top-level vdev does not imply a root-level error. 2153 */ 2154 if (vd == rvd) 2155 return; 2156 2157 ASSERT(vd == zio->io_vd); |
1975 if (!(flags & ZIO_FLAG_IO_BYPASS)) { 1976 mutex_enter(&vd->vdev_stat_lock); 1977 vs->vs_ops[type]++; 1978 vs->vs_bytes[type] += psize; 1979 mutex_exit(&vd->vdev_stat_lock); 1980 } | 2158 2159 if (flags & ZIO_FLAG_IO_BYPASS) 2160 return; 2161 2162 mutex_enter(&vd->vdev_stat_lock); 2163 |
1981 if (flags & ZIO_FLAG_IO_REPAIR) { | 2164 if (flags & ZIO_FLAG_IO_REPAIR) { |
1982 ASSERT(zio->io_delegate_list == NULL); 1983 mutex_enter(&vd->vdev_stat_lock); | |
1984 if (flags & ZIO_FLAG_SCRUB_THREAD) 1985 vs->vs_scrub_repaired += psize; | 2165 if (flags & ZIO_FLAG_SCRUB_THREAD) 2166 vs->vs_scrub_repaired += psize; |
1986 else | 2167 if (flags & ZIO_FLAG_SELF_HEAL) |
1987 vs->vs_self_healed += psize; | 2168 vs->vs_self_healed += psize; |
1988 mutex_exit(&vd->vdev_stat_lock); | |
1989 } | 2169 } |
2170 2171 vs->vs_ops[type]++; 2172 vs->vs_bytes[type] += psize; 2173 2174 mutex_exit(&vd->vdev_stat_lock); |
|
1990 return; 1991 } 1992 1993 if (flags & ZIO_FLAG_SPECULATIVE) 1994 return; 1995 1996 mutex_enter(&vd->vdev_stat_lock); | 2175 return; 2176 } 2177 2178 if (flags & ZIO_FLAG_SPECULATIVE) 2179 return; 2180 2181 mutex_enter(&vd->vdev_stat_lock); |
1997 if (type == ZIO_TYPE_READ) { | 2182 if (type == ZIO_TYPE_READ && !vdev_is_dead(vd)) { |
1998 if (zio->io_error == ECKSUM) 1999 vs->vs_checksum_errors++; 2000 else 2001 vs->vs_read_errors++; 2002 } | 2183 if (zio->io_error == ECKSUM) 2184 vs->vs_checksum_errors++; 2185 else 2186 vs->vs_read_errors++; 2187 } |
2003 if (type == ZIO_TYPE_WRITE) | 2188 if (type == ZIO_TYPE_WRITE && !vdev_is_dead(vd)) |
2004 vs->vs_write_errors++; 2005 mutex_exit(&vd->vdev_stat_lock); 2006 | 2189 vs->vs_write_errors++; 2190 mutex_exit(&vd->vdev_stat_lock); 2191 |
2007 if (type == ZIO_TYPE_WRITE && txg != 0 && vd->vdev_children == 0) { 2008 if (flags & ZIO_FLAG_SCRUB_THREAD) { 2009 ASSERT(flags & ZIO_FLAG_IO_REPAIR); 2010 for (pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) 2011 vdev_dtl_dirty(&pvd->vdev_dtl_scrub, txg, 1); 2012 } 2013 if (!(flags & ZIO_FLAG_IO_REPAIR)) { 2014 if (vdev_dtl_contains(&vd->vdev_dtl_map, txg, 1)) | 2192 if (type == ZIO_TYPE_WRITE && txg != 0 && 2193 (!(flags & ZIO_FLAG_IO_REPAIR) || 2194 (flags & ZIO_FLAG_SCRUB_THREAD))) { 2195 /* 2196 * This is either a normal write (not a repair), or it's a 2197 * repair induced by the scrub thread. In the normal case, 2198 * we commit the DTL change in the same txg as the block 2199 * was born. In the scrub-induced repair case, we know that 2200 * scrubs run in first-pass syncing context, so we commit 2201 * the DTL change in spa->spa_syncing_txg. 2202 * 2203 * We currently do not make DTL entries for failed spontaneous 2204 * self-healing writes triggered by normal (non-scrubbing) 2205 * reads, because we have no transactional context in which to 2206 * do so -- and it's not clear that it'd be desirable anyway. 2207 */ 2208 if (vd->vdev_ops->vdev_op_leaf) { 2209 uint64_t commit_txg = txg; 2210 if (flags & ZIO_FLAG_SCRUB_THREAD) { 2211 ASSERT(flags & ZIO_FLAG_IO_REPAIR); 2212 ASSERT(spa_sync_pass(spa) == 1); 2213 vdev_dtl_dirty(vd, DTL_SCRUB, txg, 1); 2214 commit_txg = spa->spa_syncing_txg; 2215 } 2216 ASSERT(commit_txg >= spa->spa_syncing_txg); 2217 if (vdev_dtl_contains(vd, DTL_MISSING, txg, 1)) |
2015 return; | 2218 return; |
2016 vdev_dirty(vd->vdev_top, VDD_DTL, vd, txg); 2017 for (pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) 2018 vdev_dtl_dirty(&pvd->vdev_dtl_map, txg, 1); | 2219 for (pvd = vd; pvd != rvd; pvd = pvd->vdev_parent) 2220 vdev_dtl_dirty(pvd, DTL_PARTIAL, txg, 1); 2221 vdev_dirty(vd->vdev_top, VDD_DTL, vd, commit_txg); |
2019 } | 2222 } |
2223 if (vd != rvd) 2224 vdev_dtl_dirty(vd, DTL_MISSING, txg, 1); |
|
2020 } 2021} 2022 2023void 2024vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type, boolean_t complete) 2025{ 2026 int c; 2027 vdev_stat_t *vs = &vd->vdev_stat; --- 78 unchanged lines hidden (view full) --- 2106void 2107vdev_config_dirty(vdev_t *vd) 2108{ 2109 spa_t *spa = vd->vdev_spa; 2110 vdev_t *rvd = spa->spa_root_vdev; 2111 int c; 2112 2113 /* | 2225 } 2226} 2227 2228void 2229vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type, boolean_t complete) 2230{ 2231 int c; 2232 vdev_stat_t *vs = &vd->vdev_stat; --- 78 unchanged lines hidden (view full) --- 2311void 2312vdev_config_dirty(vdev_t *vd) 2313{ 2314 spa_t *spa = vd->vdev_spa; 2315 vdev_t *rvd = spa->spa_root_vdev; 2316 int c; 2317 2318 /* |
2114 * If this is an aux vdev (as with l2cache devices), then we update the 2115 * vdev config manually and set the sync flag. | 2319 * If this is an aux vdev (as with l2cache and spare devices), then we 2320 * update the vdev config manually and set the sync flag. |
2116 */ 2117 if (vd->vdev_aux != NULL) { 2118 spa_aux_vdev_t *sav = vd->vdev_aux; 2119 nvlist_t **aux; 2120 uint_t naux; 2121 2122 for (c = 0; c < sav->sav_count; c++) { 2123 if (sav->sav_vdevs[c] == vd) --- 5 unchanged lines hidden (view full) --- 2129 * We're being removed. There's nothing more to do. 2130 */ 2131 ASSERT(sav->sav_sync == B_TRUE); 2132 return; 2133 } 2134 2135 sav->sav_sync = B_TRUE; 2136 | 2321 */ 2322 if (vd->vdev_aux != NULL) { 2323 spa_aux_vdev_t *sav = vd->vdev_aux; 2324 nvlist_t **aux; 2325 uint_t naux; 2326 2327 for (c = 0; c < sav->sav_count; c++) { 2328 if (sav->sav_vdevs[c] == vd) --- 5 unchanged lines hidden (view full) --- 2334 * We're being removed. There's nothing more to do. 2335 */ 2336 ASSERT(sav->sav_sync == B_TRUE); 2337 return; 2338 } 2339 2340 sav->sav_sync = B_TRUE; 2341 |
2137 VERIFY(nvlist_lookup_nvlist_array(sav->sav_config, 2138 ZPOOL_CONFIG_L2CACHE, &aux, &naux) == 0); | 2342 if (nvlist_lookup_nvlist_array(sav->sav_config, 2343 ZPOOL_CONFIG_L2CACHE, &aux, &naux) != 0) { 2344 VERIFY(nvlist_lookup_nvlist_array(sav->sav_config, 2345 ZPOOL_CONFIG_SPARES, &aux, &naux) == 0); 2346 } |
2139 2140 ASSERT(c < naux); 2141 2142 /* 2143 * Setting the nvlist in the middle if the array is a little 2144 * sketchy, but it will work. 2145 */ 2146 nvlist_free(aux[c]); --- 77 unchanged lines hidden (view full) --- 2224} 2225 2226/* 2227 * Propagate vdev state up from children to parent. 2228 */ 2229void 2230vdev_propagate_state(vdev_t *vd) 2231{ | 2347 2348 ASSERT(c < naux); 2349 2350 /* 2351 * Setting the nvlist in the middle if the array is a little 2352 * sketchy, but it will work. 2353 */ 2354 nvlist_free(aux[c]); --- 77 unchanged lines hidden (view full) --- 2432} 2433 2434/* 2435 * Propagate vdev state up from children to parent. 2436 */ 2437void 2438vdev_propagate_state(vdev_t *vd) 2439{ |
2232 vdev_t *rvd = vd->vdev_spa->spa_root_vdev; | 2440 spa_t *spa = vd->vdev_spa; 2441 vdev_t *rvd = spa->spa_root_vdev; |
2233 int degraded = 0, faulted = 0; 2234 int corrupted = 0; 2235 int c; 2236 vdev_t *child; 2237 2238 if (vd->vdev_children > 0) { 2239 for (c = 0; c < vd->vdev_children; c++) { 2240 child = vd->vdev_child[c]; 2241 2242 if (!vdev_readable(child) || | 2442 int degraded = 0, faulted = 0; 2443 int corrupted = 0; 2444 int c; 2445 vdev_t *child; 2446 2447 if (vd->vdev_children > 0) { 2448 for (c = 0; c < vd->vdev_children; c++) { 2449 child = vd->vdev_child[c]; 2450 2451 if (!vdev_readable(child) || |
2243 (!vdev_writeable(child) && (spa_mode & FWRITE))) { | 2452 (!vdev_writeable(child) && spa_writeable(spa))) { |
2244 /* 2245 * Root special: if there is a top-level log 2246 * device, treat the root vdev as if it were 2247 * degraded. 2248 */ 2249 if (child->vdev_islog && vd == rvd) 2250 degraded++; 2251 else --- 83 unchanged lines hidden (view full) --- 2335 } else if (state == VDEV_STATE_CANT_OPEN) { 2336 /* 2337 * If we fail to open a vdev during an import, we mark it as 2338 * "not available", which signifies that it was never there to 2339 * begin with. Failure to open such a device is not considered 2340 * an error. 2341 */ 2342 if (spa->spa_load_state == SPA_LOAD_IMPORT && | 2453 /* 2454 * Root special: if there is a top-level log 2455 * device, treat the root vdev as if it were 2456 * degraded. 2457 */ 2458 if (child->vdev_islog && vd == rvd) 2459 degraded++; 2460 else --- 83 unchanged lines hidden (view full) --- 2544 } else if (state == VDEV_STATE_CANT_OPEN) { 2545 /* 2546 * If we fail to open a vdev during an import, we mark it as 2547 * "not available", which signifies that it was never there to 2548 * begin with. Failure to open such a device is not considered 2549 * an error. 2550 */ 2551 if (spa->spa_load_state == SPA_LOAD_IMPORT && |
2343 !spa->spa_import_faulted && | |
2344 vd->vdev_ops->vdev_op_leaf) 2345 vd->vdev_not_present = 1; 2346 2347 /* 2348 * Post the appropriate ereport. If the 'prevstate' field is 2349 * set to something other than VDEV_STATE_UNKNOWN, it indicates 2350 * that this is part of a vdev_reopen(). In this case, we don't 2351 * want to post the ereport if the device was already in the --- 42 unchanged lines hidden (view full) --- 2394 } 2395 2396 /* Erase any notion of persistent removed state */ 2397 vd->vdev_removed = B_FALSE; 2398 } else { 2399 vd->vdev_removed = B_FALSE; 2400 } 2401 | 2552 vd->vdev_ops->vdev_op_leaf) 2553 vd->vdev_not_present = 1; 2554 2555 /* 2556 * Post the appropriate ereport. If the 'prevstate' field is 2557 * set to something other than VDEV_STATE_UNKNOWN, it indicates 2558 * that this is part of a vdev_reopen(). In this case, we don't 2559 * want to post the ereport if the device was already in the --- 42 unchanged lines hidden (view full) --- 2602 } 2603 2604 /* Erase any notion of persistent removed state */ 2605 vd->vdev_removed = B_FALSE; 2606 } else { 2607 vd->vdev_removed = B_FALSE; 2608 } 2609 |
2402 if (!isopen) 2403 vdev_propagate_state(vd); | 2610 if (!isopen && vd->vdev_parent) 2611 vdev_propagate_state(vd->vdev_parent); |
2404} 2405 2406/* 2407 * Check the vdev configuration to ensure that it's capable of supporting 2408 * a root pool. 2409 * 2410 * On Solaris, we do not support RAID-Z or partial configuration. In 2411 * addition, only a single top-level vdev is allowed and none of the --- 36 unchanged lines hidden --- | 2612} 2613 2614/* 2615 * Check the vdev configuration to ensure that it's capable of supporting 2616 * a root pool. 2617 * 2618 * On Solaris, we do not support RAID-Z or partial configuration. In 2619 * addition, only a single top-level vdev is allowed and none of the --- 36 unchanged lines hidden --- |