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 --- 485 unchanged lines hidden (view full) --- 494 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_METASLAB_SHIFT, 495 &vd->vdev_ms_shift); 496 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ASIZE, 497 &vd->vdev_asize); 498 (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_REMOVING, 499 &vd->vdev_removing); 500 } 501 |
502 if (parent && !parent->vdev_parent && alloctype != VDEV_ALLOC_ATTACH) { |
503 ASSERT(alloctype == VDEV_ALLOC_LOAD || 504 alloctype == VDEV_ALLOC_ADD || 505 alloctype == VDEV_ALLOC_SPLIT || 506 alloctype == VDEV_ALLOC_ROOTPOOL); 507 vd->vdev_mg = metaslab_group_create(islog ? 508 spa_log_class(spa) : spa_normal_class(spa), vd); 509 } 510 --- 159 unchanged lines hidden (view full) --- 670 tvd->vdev_ms_array = svd->vdev_ms_array; 671 tvd->vdev_ms_shift = svd->vdev_ms_shift; 672 tvd->vdev_ms_count = svd->vdev_ms_count; 673 674 svd->vdev_ms_array = 0; 675 svd->vdev_ms_shift = 0; 676 svd->vdev_ms_count = 0; 677 |
678 if (tvd->vdev_mg) 679 ASSERT3P(tvd->vdev_mg, ==, svd->vdev_mg); |
680 tvd->vdev_mg = svd->vdev_mg; 681 tvd->vdev_ms = svd->vdev_ms; 682 683 svd->vdev_mg = NULL; 684 svd->vdev_ms = NULL; 685 686 if (tvd->vdev_mg != NULL) 687 tvd->vdev_mg->mg_vd = tvd; --- 603 unchanged lines hidden (view full) --- 1291 return (0); 1292} 1293 1294/* 1295 * Called once the vdevs are all opened, this routine validates the label 1296 * contents. This needs to be done before vdev_load() so that we don't 1297 * inadvertently do repair I/Os to the wrong device. 1298 * |
1299 * If 'strict' is false ignore the spa guid check. This is necessary because 1300 * if the machine crashed during a re-guid the new guid might have been written 1301 * to all of the vdev labels, but not the cached config. The strict check 1302 * will be performed when the pool is opened again using the mos config. 1303 * |
1304 * This function will only return failure if one of the vdevs indicates that it 1305 * has since been destroyed or exported. This is only possible if 1306 * /etc/zfs/zpool.cache was readonly at the time. Otherwise, the vdev state 1307 * will be updated but the function will return 0. 1308 */ 1309int |
1310vdev_validate(vdev_t *vd, boolean_t strict) |
1311{ 1312 spa_t *spa = vd->vdev_spa; 1313 nvlist_t *label; 1314 uint64_t guid = 0, top_guid; 1315 uint64_t state; 1316 1317 for (int c = 0; c < vd->vdev_children; c++) |
1318 if (vdev_validate(vd->vdev_child[c], strict) != 0) |
1319 return (EBADF); 1320 1321 /* 1322 * If the device has already failed, or was marked offline, don't do 1323 * any further validation. Otherwise, label I/O will fail and we will 1324 * overwrite the previous state. 1325 */ 1326 if (vd->vdev_ops->vdev_op_leaf && vdev_readable(vd)) { --- 13 unchanged lines hidden (view full) --- 1340 if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_SPLIT_GUID, 1341 &aux_guid) == 0 && aux_guid == spa_guid(spa)) { 1342 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, 1343 VDEV_AUX_SPLIT_POOL); 1344 nvlist_free(label); 1345 return (0); 1346 } 1347 |
1348 if (strict && (nvlist_lookup_uint64(label, 1349 ZPOOL_CONFIG_POOL_GUID, &guid) != 0 || 1350 guid != spa_guid(spa))) { |
1351 vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, 1352 VDEV_AUX_CORRUPT_DATA); 1353 nvlist_free(label); 1354 return (0); 1355 } 1356 1357 if (nvlist_lookup_nvlist(label, ZPOOL_CONFIG_VDEV_TREE, &nvl) 1358 != 0 || nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_ORIG_GUID, --- 145 unchanged lines hidden (view full) --- 1504 */ 1505 if (vd->vdev_aux) { 1506 (void) vdev_validate_aux(vd); 1507 if (vdev_readable(vd) && vdev_writeable(vd) && 1508 vd->vdev_aux == &spa->spa_l2cache && 1509 !l2arc_vdev_present(vd)) 1510 l2arc_add_vdev(spa, vd); 1511 } else { |
1512 (void) vdev_validate(vd, B_TRUE); |
1513 } 1514 1515 /* 1516 * Reassess parent vdev's health. 1517 */ 1518 vdev_propagate_state(vd); 1519} 1520 --- 1641 unchanged lines hidden --- |