Deleted Added
full compact
spa.c (332529) spa.c (332530)
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

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

1291 */
1292static void
1293spa_unload(spa_t *spa)
1294{
1295 int i;
1296
1297 ASSERT(MUTEX_HELD(&spa_namespace_lock));
1298
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

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

1291 */
1292static void
1293spa_unload(spa_t *spa)
1294{
1295 int i;
1296
1297 ASSERT(MUTEX_HELD(&spa_namespace_lock));
1298
1299 spa_load_note(spa, "UNLOADING");
1300
1299 /*
1300 * Stop TRIM thread.
1301 */
1302 trim_thread_destroy(spa);
1303
1304 /*
1305 * Stop async tasks.
1306 */

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

2064 dsl_pool_config_exit(spa->spa_dsl_pool, FTAG);
2065 if (error != 0)
2066 return (error);
2067
2068 rio = zio_root(spa, NULL, &sle,
2069 ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE);
2070
2071 if (spa_load_verify_metadata) {
1301 /*
1302 * Stop TRIM thread.
1303 */
1304 trim_thread_destroy(spa);
1305
1306 /*
1307 * Stop async tasks.
1308 */

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

2066 dsl_pool_config_exit(spa->spa_dsl_pool, FTAG);
2067 if (error != 0)
2068 return (error);
2069
2070 rio = zio_root(spa, NULL, &sle,
2071 ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE);
2072
2073 if (spa_load_verify_metadata) {
2074 if (spa->spa_extreme_rewind) {
2075 spa_load_note(spa, "performing a complete scan of the "
2076 "pool since extreme rewind is on. This may take "
2077 "a very long time.\n (spa_load_verify_data=%u, "
2078 "spa_load_verify_metadata=%u)",
2079 spa_load_verify_data, spa_load_verify_metadata);
2080 }
2072 error = traverse_pool(spa, spa->spa_verify_min_txg,
2073 TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA,
2074 spa_load_verify_cb, rio);
2075 }
2076
2077 (void) zio_wait(rio);
2078
2079 spa->spa_load_meta_errors = sle.sle_meta_count;

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

2116 (void) zap_lookup(spa->spa_meta_objset, spa->spa_pool_props_object,
2117 zpool_prop_to_name(prop), sizeof (uint64_t), 1, val);
2118}
2119
2120/*
2121 * Find a value in the pool directory object.
2122 */
2123static int
2081 error = traverse_pool(spa, spa->spa_verify_min_txg,
2082 TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA,
2083 spa_load_verify_cb, rio);
2084 }
2085
2086 (void) zio_wait(rio);
2087
2088 spa->spa_load_meta_errors = sle.sle_meta_count;

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

2125 (void) zap_lookup(spa->spa_meta_objset, spa->spa_pool_props_object,
2126 zpool_prop_to_name(prop), sizeof (uint64_t), 1, val);
2127}
2128
2129/*
2130 * Find a value in the pool directory object.
2131 */
2132static int
2124spa_dir_prop(spa_t *spa, const char *name, uint64_t *val)
2133spa_dir_prop(spa_t *spa, const char *name, uint64_t *val, boolean_t log_enoent)
2125{
2134{
2126 return (zap_lookup(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
2127 name, sizeof (uint64_t), 1, val));
2135 int error = zap_lookup(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
2136 name, sizeof (uint64_t), 1, val);
2137
2138 if (error != 0 && (error != ENOENT || log_enoent)) {
2139 spa_load_failed(spa, "couldn't get '%s' value in MOS directory "
2140 "[error=%d]", name, error);
2141 }
2142
2143 return (error);
2128}
2129
2130static int
2131spa_vdev_err(vdev_t *vdev, vdev_aux_t aux, int err)
2132{
2133 vdev_set_state(vdev, B_TRUE, VDEV_STATE_CANT_OPEN, aux);
2134 return (SET_ERROR(err));
2135}

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

2311 total += vdev_count_verify_zaps(vd->vdev_child[i]);
2312 }
2313
2314 return (total);
2315}
2316
2317static int
2318spa_ld_parse_config(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
2144}
2145
2146static int
2147spa_vdev_err(vdev_t *vdev, vdev_aux_t aux, int err)
2148{
2149 vdev_set_state(vdev, B_TRUE, VDEV_STATE_CANT_OPEN, aux);
2150 return (SET_ERROR(err));
2151}

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

2327 total += vdev_count_verify_zaps(vd->vdev_child[i]);
2328 }
2329
2330 return (total);
2331}
2332
2333static int
2334spa_ld_parse_config(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
2319 spa_load_state_t state, spa_import_type_t type)
2335 spa_import_type_t type)
2320{
2321 int error = 0;
2322 nvlist_t *nvtree = NULL;
2323 int parse;
2324 vdev_t *rvd;
2325
2336{
2337 int error = 0;
2338 nvlist_t *nvtree = NULL;
2339 int parse;
2340 vdev_t *rvd;
2341
2326 ASSERT(MUTEX_HELD(&spa_namespace_lock));
2327
2328 spa->spa_load_state = state;
2329
2330 if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvtree))
2342 if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvtree)) {
2343 spa_load_failed(spa, "invalid config provided: '%s' missing",
2344 ZPOOL_CONFIG_VDEV_TREE);
2331 return (SET_ERROR(EINVAL));
2345 return (SET_ERROR(EINVAL));
2346 }
2332
2333 parse = (type == SPA_IMPORT_EXISTING ?
2334 VDEV_ALLOC_LOAD : VDEV_ALLOC_SPLIT);
2335
2336 /*
2337 * Create "The Godfather" zio to hold all async IOs
2338 */
2339 spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),

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

2348 * Parse the configuration into a vdev tree. We explicitly set the
2349 * value that will be returned by spa_version() since parsing the
2350 * configuration requires knowing the version number.
2351 */
2352 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2353 error = spa_config_parse(spa, &rvd, nvtree, NULL, 0, parse);
2354 spa_config_exit(spa, SCL_ALL, FTAG);
2355
2347
2348 parse = (type == SPA_IMPORT_EXISTING ?
2349 VDEV_ALLOC_LOAD : VDEV_ALLOC_SPLIT);
2350
2351 /*
2352 * Create "The Godfather" zio to hold all async IOs
2353 */
2354 spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),

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

2363 * Parse the configuration into a vdev tree. We explicitly set the
2364 * value that will be returned by spa_version() since parsing the
2365 * configuration requires knowing the version number.
2366 */
2367 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2368 error = spa_config_parse(spa, &rvd, nvtree, NULL, 0, parse);
2369 spa_config_exit(spa, SCL_ALL, FTAG);
2370
2356 if (error != 0)
2371 if (error != 0) {
2372 spa_load_failed(spa, "unable to parse config [error=%d]",
2373 error);
2357 return (error);
2374 return (error);
2375 }
2358
2359 ASSERT(spa->spa_root_vdev == rvd);
2360 ASSERT3U(spa->spa_min_ashift, >=, SPA_MINBLOCKSHIFT);
2361 ASSERT3U(spa->spa_max_ashift, <=, SPA_MAXBLOCKSHIFT);
2362
2363 if (type != SPA_IMPORT_ASSEMBLE) {
2364 ASSERT(spa_guid(spa) == pool_guid);
2365 }

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

2370static int
2371spa_ld_open_vdevs(spa_t *spa)
2372{
2373 int error = 0;
2374
2375 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2376 error = vdev_open(spa->spa_root_vdev);
2377 spa_config_exit(spa, SCL_ALL, FTAG);
2376
2377 ASSERT(spa->spa_root_vdev == rvd);
2378 ASSERT3U(spa->spa_min_ashift, >=, SPA_MINBLOCKSHIFT);
2379 ASSERT3U(spa->spa_max_ashift, <=, SPA_MAXBLOCKSHIFT);
2380
2381 if (type != SPA_IMPORT_ASSEMBLE) {
2382 ASSERT(spa_guid(spa) == pool_guid);
2383 }

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

2388static int
2389spa_ld_open_vdevs(spa_t *spa)
2390{
2391 int error = 0;
2392
2393 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2394 error = vdev_open(spa->spa_root_vdev);
2395 spa_config_exit(spa, SCL_ALL, FTAG);
2396 if (error != 0) {
2397 spa_load_failed(spa, "unable to open vdev tree [error=%d]",
2398 error);
2399 }
2378
2379 return (error);
2380}
2381
2382static int
2383spa_ld_validate_vdevs(spa_t *spa, spa_import_type_t type,
2384 boolean_t trust_config)
2385{

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

2399 * existing pool, the labels haven't yet been updated so we skip
2400 * validation for now.
2401 */
2402 if (type != SPA_IMPORT_ASSEMBLE) {
2403 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2404 error = vdev_validate(rvd, trust_config);
2405 spa_config_exit(spa, SCL_ALL, FTAG);
2406
2400
2401 return (error);
2402}
2403
2404static int
2405spa_ld_validate_vdevs(spa_t *spa, spa_import_type_t type,
2406 boolean_t trust_config)
2407{

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

2421 * existing pool, the labels haven't yet been updated so we skip
2422 * validation for now.
2423 */
2424 if (type != SPA_IMPORT_ASSEMBLE) {
2425 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2426 error = vdev_validate(rvd, trust_config);
2427 spa_config_exit(spa, SCL_ALL, FTAG);
2428
2407 if (error != 0)
2429 if (error != 0) {
2430 spa_load_failed(spa, "vdev_validate failed [error=%d]",
2431 error);
2408 return (error);
2432 return (error);
2433 }
2409
2434
2410 if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN)
2435 if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN) {
2436 spa_load_failed(spa, "cannot open vdev tree after "
2437 "invalidating some vdevs");
2411 return (SET_ERROR(ENXIO));
2438 return (SET_ERROR(ENXIO));
2439 }
2412 }
2413
2414 return (0);
2415}
2416
2417static int
2418spa_ld_select_uberblock(spa_t *spa, nvlist_t *config, spa_import_type_t type,
2419 boolean_t trust_config)

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

2428 */
2429 vdev_uberblock_load(rvd, ub, &label);
2430
2431 /*
2432 * If we weren't able to find a single valid uberblock, return failure.
2433 */
2434 if (ub->ub_txg == 0) {
2435 nvlist_free(label);
2440 }
2441
2442 return (0);
2443}
2444
2445static int
2446spa_ld_select_uberblock(spa_t *spa, nvlist_t *config, spa_import_type_t type,
2447 boolean_t trust_config)

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

2456 */
2457 vdev_uberblock_load(rvd, ub, &label);
2458
2459 /*
2460 * If we weren't able to find a single valid uberblock, return failure.
2461 */
2462 if (ub->ub_txg == 0) {
2463 nvlist_free(label);
2464 spa_load_failed(spa, "no valid uberblock found");
2436 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, ENXIO));
2437 }
2438
2465 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, ENXIO));
2466 }
2467
2468 spa_load_note(spa, "using uberblock with txg=%llu",
2469 (u_longlong_t)ub->ub_txg);
2470
2439 /*
2440 * If the pool has an unsupported version we can't open it.
2441 */
2442 if (!SPA_VERSION_IS_SUPPORTED(ub->ub_version)) {
2443 nvlist_free(label);
2471 /*
2472 * If the pool has an unsupported version we can't open it.
2473 */
2474 if (!SPA_VERSION_IS_SUPPORTED(ub->ub_version)) {
2475 nvlist_free(label);
2476 spa_load_failed(spa, "version %llu is not supported",
2477 (u_longlong_t)ub->ub_version);
2444 return (spa_vdev_err(rvd, VDEV_AUX_VERSION_NEWER, ENOTSUP));
2445 }
2446
2447 if (ub->ub_version >= SPA_VERSION_FEATURES) {
2448 nvlist_t *features;
2449
2450 /*
2451 * If we weren't able to find what's necessary for reading the
2452 * MOS in the label, return failure.
2453 */
2478 return (spa_vdev_err(rvd, VDEV_AUX_VERSION_NEWER, ENOTSUP));
2479 }
2480
2481 if (ub->ub_version >= SPA_VERSION_FEATURES) {
2482 nvlist_t *features;
2483
2484 /*
2485 * If we weren't able to find what's necessary for reading the
2486 * MOS in the label, return failure.
2487 */
2454 if (label == NULL || nvlist_lookup_nvlist(label,
2455 ZPOOL_CONFIG_FEATURES_FOR_READ, &features) != 0) {
2488 if (label == NULL) {
2489 spa_load_failed(spa, "label config unavailable");
2490 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
2491 ENXIO));
2492 }
2493
2494 if (nvlist_lookup_nvlist(label, ZPOOL_CONFIG_FEATURES_FOR_READ,
2495 &features) != 0) {
2456 nvlist_free(label);
2496 nvlist_free(label);
2497 spa_load_failed(spa, "invalid label: '%s' missing",
2498 ZPOOL_CONFIG_FEATURES_FOR_READ);
2457 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
2458 ENXIO));
2459 }
2460
2461 /*
2462 * Update our in-core representation with the definitive values
2463 * from the label.
2464 */

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

2487 nvpair_name(nvp), "") == 0);
2488 }
2489 }
2490
2491 if (!nvlist_empty(unsup_feat)) {
2492 VERIFY(nvlist_add_nvlist(spa->spa_load_info,
2493 ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat) == 0);
2494 nvlist_free(unsup_feat);
2499 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
2500 ENXIO));
2501 }
2502
2503 /*
2504 * Update our in-core representation with the definitive values
2505 * from the label.
2506 */

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

2529 nvpair_name(nvp), "") == 0);
2530 }
2531 }
2532
2533 if (!nvlist_empty(unsup_feat)) {
2534 VERIFY(nvlist_add_nvlist(spa->spa_load_info,
2535 ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat) == 0);
2536 nvlist_free(unsup_feat);
2537 spa_load_failed(spa, "some features are unsupported");
2495 return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
2496 ENOTSUP));
2497 }
2498
2499 nvlist_free(unsup_feat);
2500 }
2501
2502 /*
2503 * If the vdev guid sum doesn't match the uberblock, we have an
2504 * incomplete configuration. We first check to see if the pool
2505 * is aware of the complete config (i.e ZPOOL_CONFIG_VDEV_CHILDREN).
2506 * If it is, defer the vdev_guid_sum check till later so we
2507 * can handle missing vdevs.
2508 */
2509 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_VDEV_CHILDREN,
2510 &children) != 0 && trust_config && type != SPA_IMPORT_ASSEMBLE &&
2538 return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
2539 ENOTSUP));
2540 }
2541
2542 nvlist_free(unsup_feat);
2543 }
2544
2545 /*
2546 * If the vdev guid sum doesn't match the uberblock, we have an
2547 * incomplete configuration. We first check to see if the pool
2548 * is aware of the complete config (i.e ZPOOL_CONFIG_VDEV_CHILDREN).
2549 * If it is, defer the vdev_guid_sum check till later so we
2550 * can handle missing vdevs.
2551 */
2552 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_VDEV_CHILDREN,
2553 &children) != 0 && trust_config && type != SPA_IMPORT_ASSEMBLE &&
2511 rvd->vdev_guid_sum != ub->ub_guid_sum)
2554 rvd->vdev_guid_sum != ub->ub_guid_sum) {
2555 spa_load_failed(spa, "guid sum in config doesn't match guid "
2556 "sum in uberblock (%llu != %llu)",
2557 (u_longlong_t)rvd->vdev_guid_sum,
2558 (u_longlong_t)ub->ub_guid_sum);
2512 return (spa_vdev_err(rvd, VDEV_AUX_BAD_GUID_SUM, ENXIO));
2559 return (spa_vdev_err(rvd, VDEV_AUX_BAD_GUID_SUM, ENXIO));
2560 }
2513
2514 if (type != SPA_IMPORT_ASSEMBLE && spa->spa_config_splitting) {
2515 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2516 spa_try_repair(spa, config);
2517 spa_config_exit(spa, SCL_ALL, FTAG);
2518 nvlist_free(spa->spa_config_splitting);
2519 spa->spa_config_splitting = NULL;
2520 }

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

2536
2537static int
2538spa_ld_open_rootbp(spa_t *spa)
2539{
2540 int error = 0;
2541 vdev_t *rvd = spa->spa_root_vdev;
2542
2543 error = dsl_pool_init(spa, spa->spa_first_txg, &spa->spa_dsl_pool);
2561
2562 if (type != SPA_IMPORT_ASSEMBLE && spa->spa_config_splitting) {
2563 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2564 spa_try_repair(spa, config);
2565 spa_config_exit(spa, SCL_ALL, FTAG);
2566 nvlist_free(spa->spa_config_splitting);
2567 spa->spa_config_splitting = NULL;
2568 }

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

2584
2585static int
2586spa_ld_open_rootbp(spa_t *spa)
2587{
2588 int error = 0;
2589 vdev_t *rvd = spa->spa_root_vdev;
2590
2591 error = dsl_pool_init(spa, spa->spa_first_txg, &spa->spa_dsl_pool);
2544 if (error)
2592 if (error != 0) {
2593 spa_load_failed(spa, "unable to open rootbp in dsl_pool_init "
2594 "[error=%d]", error);
2545 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2595 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2596 }
2546 spa->spa_meta_objset = spa->spa_dsl_pool->dp_meta_objset;
2547
2548 return (0);
2549}
2550
2551static int
2552spa_ld_validate_config(spa_t *spa, spa_import_type_t type)
2553{
2554 vdev_t *rvd = spa->spa_root_vdev;
2555
2597 spa->spa_meta_objset = spa->spa_dsl_pool->dp_meta_objset;
2598
2599 return (0);
2600}
2601
2602static int
2603spa_ld_validate_config(spa_t *spa, spa_import_type_t type)
2604{
2605 vdev_t *rvd = spa->spa_root_vdev;
2606
2556 if (spa_dir_prop(spa, DMU_POOL_CONFIG, &spa->spa_config_object) != 0)
2607 if (spa_dir_prop(spa, DMU_POOL_CONFIG, &spa->spa_config_object, B_TRUE)
2608 != 0)
2557 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2558
2559 /*
2560 * Validate the config, using the MOS config to fill in any
2561 * information which might be missing. If we fail to validate
2562 * the config then declare the pool unfit for use. If we're
2563 * assembling a pool from a split, the log is not transferred
2564 * over.
2565 */
2566 if (type != SPA_IMPORT_ASSEMBLE) {
2567 nvlist_t *mos_config;
2609 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2610
2611 /*
2612 * Validate the config, using the MOS config to fill in any
2613 * information which might be missing. If we fail to validate
2614 * the config then declare the pool unfit for use. If we're
2615 * assembling a pool from a split, the log is not transferred
2616 * over.
2617 */
2618 if (type != SPA_IMPORT_ASSEMBLE) {
2619 nvlist_t *mos_config;
2568 if (load_nvlist(spa, spa->spa_config_object, &mos_config) != 0)
2620 if (load_nvlist(spa, spa->spa_config_object, &mos_config)
2621 != 0) {
2622 spa_load_failed(spa, "unable to retrieve MOS config");
2569 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2623 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2624 }
2570
2571 if (!spa_config_valid(spa, mos_config)) {
2572 nvlist_free(mos_config);
2625
2626 if (!spa_config_valid(spa, mos_config)) {
2627 nvlist_free(mos_config);
2628 spa_load_failed(spa, "mismatch between config provided "
2629 "and config stored in MOS");
2573 return (spa_vdev_err(rvd, VDEV_AUX_BAD_GUID_SUM,
2574 ENXIO));
2575 }
2576 nvlist_free(mos_config);
2577
2578 /*
2579 * Now that we've validated the config, check the state of the
2580 * root vdev. If it can't be opened, it indicates one or
2581 * more toplevel vdevs are faulted.
2582 */
2630 return (spa_vdev_err(rvd, VDEV_AUX_BAD_GUID_SUM,
2631 ENXIO));
2632 }
2633 nvlist_free(mos_config);
2634
2635 /*
2636 * Now that we've validated the config, check the state of the
2637 * root vdev. If it can't be opened, it indicates one or
2638 * more toplevel vdevs are faulted.
2639 */
2583 if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN)
2640 if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN) {
2641 spa_load_failed(spa, "some top vdevs are unavailable");
2584 return (SET_ERROR(ENXIO));
2642 return (SET_ERROR(ENXIO));
2643 }
2585 }
2586
2587 return (0);
2588}
2589
2590static int
2591spa_ld_open_indirect_vdev_metadata(spa_t *spa)
2592{
2593 int error = 0;
2594 vdev_t *rvd = spa->spa_root_vdev;
2595
2596 /*
2597 * Everything that we read before spa_remove_init() must be stored
2598 * on concreted vdevs. Therefore we do this as early as possible.
2599 */
2644 }
2645
2646 return (0);
2647}
2648
2649static int
2650spa_ld_open_indirect_vdev_metadata(spa_t *spa)
2651{
2652 int error = 0;
2653 vdev_t *rvd = spa->spa_root_vdev;
2654
2655 /*
2656 * Everything that we read before spa_remove_init() must be stored
2657 * on concreted vdevs. Therefore we do this as early as possible.
2658 */
2600 if (spa_remove_init(spa) != 0)
2659 error = spa_remove_init(spa);
2660 if (error != 0) {
2661 spa_load_failed(spa, "spa_remove_init failed [error=%d]",
2662 error);
2601 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2663 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2664 }
2602
2603 /*
2604 * Retrieve information needed to condense indirect vdev mappings.
2605 */
2606 error = spa_condense_init(spa);
2607 if (error != 0) {
2665
2666 /*
2667 * Retrieve information needed to condense indirect vdev mappings.
2668 */
2669 error = spa_condense_init(spa);
2670 if (error != 0) {
2671 spa_load_failed(spa, "spa_condense_init failed [error=%d]",
2672 error);
2608 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, error));
2609 }
2610
2611 return (0);
2612}
2613
2614static int
2673 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, error));
2674 }
2675
2676 return (0);
2677}
2678
2679static int
2615spa_ld_check_features(spa_t *spa, spa_load_state_t state,
2616 boolean_t *missing_feat_writep)
2680spa_ld_check_features(spa_t *spa, boolean_t *missing_feat_writep)
2617{
2618 int error = 0;
2619 vdev_t *rvd = spa->spa_root_vdev;
2620
2621 if (spa_version(spa) >= SPA_VERSION_FEATURES) {
2622 boolean_t missing_feat_read = B_FALSE;
2623 nvlist_t *unsup_feat, *enabled_feat;
2624
2625 if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_READ,
2681{
2682 int error = 0;
2683 vdev_t *rvd = spa->spa_root_vdev;
2684
2685 if (spa_version(spa) >= SPA_VERSION_FEATURES) {
2686 boolean_t missing_feat_read = B_FALSE;
2687 nvlist_t *unsup_feat, *enabled_feat;
2688
2689 if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_READ,
2626 &spa->spa_feat_for_read_obj) != 0) {
2690 &spa->spa_feat_for_read_obj, B_TRUE) != 0) {
2627 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2628 }
2629
2630 if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_WRITE,
2691 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2692 }
2693
2694 if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_WRITE,
2631 &spa->spa_feat_for_write_obj) != 0) {
2695 &spa->spa_feat_for_write_obj, B_TRUE) != 0) {
2632 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2633 }
2634
2635 if (spa_dir_prop(spa, DMU_POOL_FEATURE_DESCRIPTIONS,
2696 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2697 }
2698
2699 if (spa_dir_prop(spa, DMU_POOL_FEATURE_DESCRIPTIONS,
2636 &spa->spa_feat_desc_obj) != 0) {
2700 &spa->spa_feat_desc_obj, B_TRUE) != 0) {
2637 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2638 }
2639
2640 enabled_feat = fnvlist_alloc();
2641 unsup_feat = fnvlist_alloc();
2642
2643 if (!spa_features_check(spa, B_FALSE,
2644 unsup_feat, enabled_feat))
2645 missing_feat_read = B_TRUE;
2646
2701 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2702 }
2703
2704 enabled_feat = fnvlist_alloc();
2705 unsup_feat = fnvlist_alloc();
2706
2707 if (!spa_features_check(spa, B_FALSE,
2708 unsup_feat, enabled_feat))
2709 missing_feat_read = B_TRUE;
2710
2647 if (spa_writeable(spa) || state == SPA_LOAD_TRYIMPORT) {
2711 if (spa_writeable(spa) ||
2712 spa->spa_load_state == SPA_LOAD_TRYIMPORT) {
2648 if (!spa_features_check(spa, B_TRUE,
2649 unsup_feat, enabled_feat)) {
2650 *missing_feat_writep = B_TRUE;
2651 }
2652 }
2653
2654 fnvlist_add_nvlist(spa->spa_load_info,
2655 ZPOOL_CONFIG_ENABLED_FEAT, enabled_feat);

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

2683 * As a result, if the state is SPA_LOAD_TRYIMPORT and we are
2684 * missing a feature for write, we must first determine whether
2685 * the pool can be opened read-only before returning to
2686 * userland in order to know whether to display the
2687 * abovementioned note.
2688 */
2689 if (missing_feat_read || (*missing_feat_writep &&
2690 spa_writeable(spa))) {
2713 if (!spa_features_check(spa, B_TRUE,
2714 unsup_feat, enabled_feat)) {
2715 *missing_feat_writep = B_TRUE;
2716 }
2717 }
2718
2719 fnvlist_add_nvlist(spa->spa_load_info,
2720 ZPOOL_CONFIG_ENABLED_FEAT, enabled_feat);

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

2748 * As a result, if the state is SPA_LOAD_TRYIMPORT and we are
2749 * missing a feature for write, we must first determine whether
2750 * the pool can be opened read-only before returning to
2751 * userland in order to know whether to display the
2752 * abovementioned note.
2753 */
2754 if (missing_feat_read || (*missing_feat_writep &&
2755 spa_writeable(spa))) {
2756 spa_load_failed(spa, "pool uses unsupported features");
2691 return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
2692 ENOTSUP));
2693 }
2694
2695 /*
2696 * Load refcounts for ZFS features from disk into an in-memory
2697 * cache during SPA initialization.
2698 */
2699 for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
2700 uint64_t refcount;
2701
2702 error = feature_get_refcount_from_disk(spa,
2703 &spa_feature_table[i], &refcount);
2704 if (error == 0) {
2705 spa->spa_feat_refcount_cache[i] = refcount;
2706 } else if (error == ENOTSUP) {
2707 spa->spa_feat_refcount_cache[i] =
2708 SPA_FEATURE_DISABLED;
2709 } else {
2757 return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
2758 ENOTSUP));
2759 }
2760
2761 /*
2762 * Load refcounts for ZFS features from disk into an in-memory
2763 * cache during SPA initialization.
2764 */
2765 for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
2766 uint64_t refcount;
2767
2768 error = feature_get_refcount_from_disk(spa,
2769 &spa_feature_table[i], &refcount);
2770 if (error == 0) {
2771 spa->spa_feat_refcount_cache[i] = refcount;
2772 } else if (error == ENOTSUP) {
2773 spa->spa_feat_refcount_cache[i] =
2774 SPA_FEATURE_DISABLED;
2775 } else {
2776 spa_load_failed(spa, "error getting refcount "
2777 "for feature %s [error=%d]",
2778 spa_feature_table[i].fi_guid, error);
2710 return (spa_vdev_err(rvd,
2711 VDEV_AUX_CORRUPT_DATA, EIO));
2712 }
2713 }
2714 }
2715
2716 if (spa_feature_is_active(spa, SPA_FEATURE_ENABLED_TXG)) {
2717 if (spa_dir_prop(spa, DMU_POOL_FEATURE_ENABLED_TXG,
2779 return (spa_vdev_err(rvd,
2780 VDEV_AUX_CORRUPT_DATA, EIO));
2781 }
2782 }
2783 }
2784
2785 if (spa_feature_is_active(spa, SPA_FEATURE_ENABLED_TXG)) {
2786 if (spa_dir_prop(spa, DMU_POOL_FEATURE_ENABLED_TXG,
2718 &spa->spa_feat_enabled_txg_obj) != 0)
2787 &spa->spa_feat_enabled_txg_obj, B_TRUE) != 0)
2719 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2720 }
2721
2722 return (0);
2723}
2724
2725static int
2726spa_ld_load_special_directories(spa_t *spa)
2727{
2728 int error = 0;
2729 vdev_t *rvd = spa->spa_root_vdev;
2730
2731 spa->spa_is_initializing = B_TRUE;
2732 error = dsl_pool_open(spa->spa_dsl_pool);
2733 spa->spa_is_initializing = B_FALSE;
2788 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2789 }
2790
2791 return (0);
2792}
2793
2794static int
2795spa_ld_load_special_directories(spa_t *spa)
2796{
2797 int error = 0;
2798 vdev_t *rvd = spa->spa_root_vdev;
2799
2800 spa->spa_is_initializing = B_TRUE;
2801 error = dsl_pool_open(spa->spa_dsl_pool);
2802 spa->spa_is_initializing = B_FALSE;
2734 if (error != 0)
2803 if (error != 0) {
2804 spa_load_failed(spa, "dsl_pool_open failed [error=%d]", error);
2735 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2805 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2806 }
2736
2737 return (0);
2738}
2739
2740static int
2741spa_ld_prepare_for_reload(spa_t *spa, int orig_mode)
2742{
2743 vdev_t *rvd = spa->spa_root_vdev;
2744
2745 uint64_t hostid;
2746 nvlist_t *policy = NULL;
2747 nvlist_t *mos_config;
2748
2807
2808 return (0);
2809}
2810
2811static int
2812spa_ld_prepare_for_reload(spa_t *spa, int orig_mode)
2813{
2814 vdev_t *rvd = spa->spa_root_vdev;
2815
2816 uint64_t hostid;
2817 nvlist_t *policy = NULL;
2818 nvlist_t *mos_config;
2819
2749 if (load_nvlist(spa, spa->spa_config_object, &mos_config) != 0)
2820 if (load_nvlist(spa, spa->spa_config_object, &mos_config) != 0) {
2821 spa_load_failed(spa, "unable to retrieve MOS config");
2750 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2822 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2823 }
2751
2752 if (!spa_is_root(spa) && nvlist_lookup_uint64(mos_config,
2753 ZPOOL_CONFIG_HOSTID, &hostid) == 0) {
2754 char *hostname;
2755 unsigned long myhostid = 0;
2756
2757 VERIFY(nvlist_lookup_string(mos_config,
2758 ZPOOL_CONFIG_HOSTNAME, &hostname) == 0);

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

2803 DMU_POOL_CHECKSUM_SALT, 1,
2804 sizeof (spa->spa_cksum_salt.zcs_bytes),
2805 spa->spa_cksum_salt.zcs_bytes);
2806 if (error == ENOENT) {
2807 /* Generate a new salt for subsequent use */
2808 (void) random_get_pseudo_bytes(spa->spa_cksum_salt.zcs_bytes,
2809 sizeof (spa->spa_cksum_salt.zcs_bytes));
2810 } else if (error != 0) {
2824
2825 if (!spa_is_root(spa) && nvlist_lookup_uint64(mos_config,
2826 ZPOOL_CONFIG_HOSTID, &hostid) == 0) {
2827 char *hostname;
2828 unsigned long myhostid = 0;
2829
2830 VERIFY(nvlist_lookup_string(mos_config,
2831 ZPOOL_CONFIG_HOSTNAME, &hostname) == 0);

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

2876 DMU_POOL_CHECKSUM_SALT, 1,
2877 sizeof (spa->spa_cksum_salt.zcs_bytes),
2878 spa->spa_cksum_salt.zcs_bytes);
2879 if (error == ENOENT) {
2880 /* Generate a new salt for subsequent use */
2881 (void) random_get_pseudo_bytes(spa->spa_cksum_salt.zcs_bytes,
2882 sizeof (spa->spa_cksum_salt.zcs_bytes));
2883 } else if (error != 0) {
2884 spa_load_failed(spa, "unable to retrieve checksum salt from "
2885 "MOS [error=%d]", error);
2811 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2812 }
2813
2886 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2887 }
2888
2814 if (spa_dir_prop(spa, DMU_POOL_SYNC_BPOBJ, &obj) != 0)
2889 if (spa_dir_prop(spa, DMU_POOL_SYNC_BPOBJ, &obj, B_TRUE) != 0)
2815 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2816 error = bpobj_open(&spa->spa_deferred_bpobj, spa->spa_meta_objset, obj);
2890 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2891 error = bpobj_open(&spa->spa_deferred_bpobj, spa->spa_meta_objset, obj);
2817 if (error != 0)
2892 if (error != 0) {
2893 spa_load_failed(spa, "error opening deferred-frees bpobj "
2894 "[error=%d]", error);
2818 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2895 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2896 }
2819
2820 /*
2821 * Load the bit that tells us to use the new accounting function
2822 * (raid-z deflation). If we have an older pool, this will not
2823 * be present.
2824 */
2897
2898 /*
2899 * Load the bit that tells us to use the new accounting function
2900 * (raid-z deflation). If we have an older pool, this will not
2901 * be present.
2902 */
2825 error = spa_dir_prop(spa, DMU_POOL_DEFLATE, &spa->spa_deflate);
2903 error = spa_dir_prop(spa, DMU_POOL_DEFLATE, &spa->spa_deflate, B_FALSE);
2826 if (error != 0 && error != ENOENT)
2827 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2828
2829 error = spa_dir_prop(spa, DMU_POOL_CREATION_VERSION,
2904 if (error != 0 && error != ENOENT)
2905 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2906
2907 error = spa_dir_prop(spa, DMU_POOL_CREATION_VERSION,
2830 &spa->spa_creation_version);
2908 &spa->spa_creation_version, B_FALSE);
2831 if (error != 0 && error != ENOENT)
2832 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2833
2834 /*
2835 * Load the persistent error log. If we have an older pool, this will
2836 * not be present.
2837 */
2909 if (error != 0 && error != ENOENT)
2910 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2911
2912 /*
2913 * Load the persistent error log. If we have an older pool, this will
2914 * not be present.
2915 */
2838 error = spa_dir_prop(spa, DMU_POOL_ERRLOG_LAST, &spa->spa_errlog_last);
2916 error = spa_dir_prop(spa, DMU_POOL_ERRLOG_LAST, &spa->spa_errlog_last,
2917 B_FALSE);
2839 if (error != 0 && error != ENOENT)
2840 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2841
2842 error = spa_dir_prop(spa, DMU_POOL_ERRLOG_SCRUB,
2918 if (error != 0 && error != ENOENT)
2919 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2920
2921 error = spa_dir_prop(spa, DMU_POOL_ERRLOG_SCRUB,
2843 &spa->spa_errlog_scrub);
2922 &spa->spa_errlog_scrub, B_FALSE);
2844 if (error != 0 && error != ENOENT)
2845 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2846
2847 /*
2848 * Load the history object. If we have an older pool, this
2849 * will not be present.
2850 */
2923 if (error != 0 && error != ENOENT)
2924 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2925
2926 /*
2927 * Load the history object. If we have an older pool, this
2928 * will not be present.
2929 */
2851 error = spa_dir_prop(spa, DMU_POOL_HISTORY, &spa->spa_history);
2930 error = spa_dir_prop(spa, DMU_POOL_HISTORY, &spa->spa_history, B_FALSE);
2852 if (error != 0 && error != ENOENT)
2853 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2854
2855 /*
2856 * Load the per-vdev ZAP map. If we have an older pool, this will not
2857 * be present; in this case, defer its creation to a later time to
2858 * avoid dirtying the MOS this early / out of sync context. See
2859 * spa_sync_config_object.
2860 */
2861
2862 /* The sentinel is only available in the MOS config. */
2863 nvlist_t *mos_config;
2931 if (error != 0 && error != ENOENT)
2932 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2933
2934 /*
2935 * Load the per-vdev ZAP map. If we have an older pool, this will not
2936 * be present; in this case, defer its creation to a later time to
2937 * avoid dirtying the MOS this early / out of sync context. See
2938 * spa_sync_config_object.
2939 */
2940
2941 /* The sentinel is only available in the MOS config. */
2942 nvlist_t *mos_config;
2864 if (load_nvlist(spa, spa->spa_config_object, &mos_config) != 0)
2943 if (load_nvlist(spa, spa->spa_config_object, &mos_config) != 0) {
2944 spa_load_failed(spa, "unable to retrieve MOS config");
2865 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2945 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2946 }
2866
2867 error = spa_dir_prop(spa, DMU_POOL_VDEV_ZAP_MAP,
2947
2948 error = spa_dir_prop(spa, DMU_POOL_VDEV_ZAP_MAP,
2868 &spa->spa_all_vdev_zaps);
2949 &spa->spa_all_vdev_zaps, B_FALSE);
2869
2870 if (error == ENOENT) {
2871 VERIFY(!nvlist_exists(mos_config,
2872 ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS));
2873 spa->spa_avz_action = AVZ_ACTION_INITIALIZE;
2874 ASSERT0(vdev_count_verify_zaps(spa->spa_root_vdev));
2875 } else if (error != 0) {
2876 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));

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

2886 * before this. Better be sure of it.
2887 */
2888 ASSERT0(vdev_count_verify_zaps(spa->spa_root_vdev));
2889 }
2890 nvlist_free(mos_config);
2891
2892 spa->spa_delegation = zpool_prop_default_numeric(ZPOOL_PROP_DELEGATION);
2893
2950
2951 if (error == ENOENT) {
2952 VERIFY(!nvlist_exists(mos_config,
2953 ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS));
2954 spa->spa_avz_action = AVZ_ACTION_INITIALIZE;
2955 ASSERT0(vdev_count_verify_zaps(spa->spa_root_vdev));
2956 } else if (error != 0) {
2957 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));

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

2967 * before this. Better be sure of it.
2968 */
2969 ASSERT0(vdev_count_verify_zaps(spa->spa_root_vdev));
2970 }
2971 nvlist_free(mos_config);
2972
2973 spa->spa_delegation = zpool_prop_default_numeric(ZPOOL_PROP_DELEGATION);
2974
2894 error = spa_dir_prop(spa, DMU_POOL_PROPS, &spa->spa_pool_props_object);
2975 error = spa_dir_prop(spa, DMU_POOL_PROPS, &spa->spa_pool_props_object,
2976 B_FALSE);
2895 if (error && error != ENOENT)
2896 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2897
2898 if (error == 0) {
2899 uint64_t autoreplace;
2900
2901 spa_prop_find(spa, ZPOOL_PROP_BOOTFS, &spa->spa_bootfs);
2902 spa_prop_find(spa, ZPOOL_PROP_AUTOREPLACE, &autoreplace);

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

2922 * If we're assembling the pool from the split-off vdevs of
2923 * an existing pool, we don't want to attach the spares & cache
2924 * devices.
2925 */
2926
2927 /*
2928 * Load any hot spares for this pool.
2929 */
2977 if (error && error != ENOENT)
2978 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2979
2980 if (error == 0) {
2981 uint64_t autoreplace;
2982
2983 spa_prop_find(spa, ZPOOL_PROP_BOOTFS, &spa->spa_bootfs);
2984 spa_prop_find(spa, ZPOOL_PROP_AUTOREPLACE, &autoreplace);

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

3004 * If we're assembling the pool from the split-off vdevs of
3005 * an existing pool, we don't want to attach the spares & cache
3006 * devices.
3007 */
3008
3009 /*
3010 * Load any hot spares for this pool.
3011 */
2930 error = spa_dir_prop(spa, DMU_POOL_SPARES, &spa->spa_spares.sav_object);
3012 error = spa_dir_prop(spa, DMU_POOL_SPARES, &spa->spa_spares.sav_object,
3013 B_FALSE);
2931 if (error != 0 && error != ENOENT)
2932 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2933 if (error == 0 && type != SPA_IMPORT_ASSEMBLE) {
2934 ASSERT(spa_version(spa) >= SPA_VERSION_SPARES);
2935 if (load_nvlist(spa, spa->spa_spares.sav_object,
3014 if (error != 0 && error != ENOENT)
3015 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3016 if (error == 0 && type != SPA_IMPORT_ASSEMBLE) {
3017 ASSERT(spa_version(spa) >= SPA_VERSION_SPARES);
3018 if (load_nvlist(spa, spa->spa_spares.sav_object,
2936 &spa->spa_spares.sav_config) != 0)
3019 &spa->spa_spares.sav_config) != 0) {
3020 spa_load_failed(spa, "error loading spares nvlist");
2937 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3021 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3022 }
2938
2939 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2940 spa_load_spares(spa);
2941 spa_config_exit(spa, SCL_ALL, FTAG);
2942 } else if (error == 0) {
2943 spa->spa_spares.sav_sync = B_TRUE;
2944 }
2945
2946 /*
2947 * Load any level 2 ARC devices for this pool.
2948 */
2949 error = spa_dir_prop(spa, DMU_POOL_L2CACHE,
3023
3024 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3025 spa_load_spares(spa);
3026 spa_config_exit(spa, SCL_ALL, FTAG);
3027 } else if (error == 0) {
3028 spa->spa_spares.sav_sync = B_TRUE;
3029 }
3030
3031 /*
3032 * Load any level 2 ARC devices for this pool.
3033 */
3034 error = spa_dir_prop(spa, DMU_POOL_L2CACHE,
2950 &spa->spa_l2cache.sav_object);
3035 &spa->spa_l2cache.sav_object, B_FALSE);
2951 if (error != 0 && error != ENOENT)
2952 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2953 if (error == 0 && type != SPA_IMPORT_ASSEMBLE) {
2954 ASSERT(spa_version(spa) >= SPA_VERSION_L2CACHE);
2955 if (load_nvlist(spa, spa->spa_l2cache.sav_object,
3036 if (error != 0 && error != ENOENT)
3037 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3038 if (error == 0 && type != SPA_IMPORT_ASSEMBLE) {
3039 ASSERT(spa_version(spa) >= SPA_VERSION_L2CACHE);
3040 if (load_nvlist(spa, spa->spa_l2cache.sav_object,
2956 &spa->spa_l2cache.sav_config) != 0)
3041 &spa->spa_l2cache.sav_config) != 0) {
3042 spa_load_failed(spa, "error loading l2cache nvlist");
2957 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3043 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3044 }
2958
2959 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2960 spa_load_l2cache(spa);
2961 spa_config_exit(spa, SCL_ALL, FTAG);
2962 } else if (error == 0) {
2963 spa->spa_l2cache.sav_sync = B_TRUE;
2964 }
2965
2966 return (0);
2967}
2968
2969static int
3045
3046 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3047 spa_load_l2cache(spa);
3048 spa_config_exit(spa, SCL_ALL, FTAG);
3049 } else if (error == 0) {
3050 spa->spa_l2cache.sav_sync = B_TRUE;
3051 }
3052
3053 return (0);
3054}
3055
3056static int
2970spa_ld_load_vdev_metadata(spa_t *spa, spa_load_state_t state)
3057spa_ld_load_vdev_metadata(spa_t *spa)
2971{
2972 int error = 0;
2973 vdev_t *rvd = spa->spa_root_vdev;
2974
2975 /*
2976 * If the 'autoreplace' property is set, then post a resource notifying
2977 * the ZFS DE that it should not issue any faults for unopenable
2978 * devices. We also iterate over the vdevs, and post a sysevent for any
2979 * unopenable vdevs so that the normal autoreplace handler can take
2980 * over.
2981 */
3058{
3059 int error = 0;
3060 vdev_t *rvd = spa->spa_root_vdev;
3061
3062 /*
3063 * If the 'autoreplace' property is set, then post a resource notifying
3064 * the ZFS DE that it should not issue any faults for unopenable
3065 * devices. We also iterate over the vdevs, and post a sysevent for any
3066 * unopenable vdevs so that the normal autoreplace handler can take
3067 * over.
3068 */
2982 if (spa->spa_autoreplace && state != SPA_LOAD_TRYIMPORT) {
3069 if (spa->spa_autoreplace && spa->spa_load_state != SPA_LOAD_TRYIMPORT) {
2983 spa_check_removed(spa->spa_root_vdev);
2984 /*
2985 * For the import case, this is done in spa_import(), because
2986 * at this point we're using the spare definitions from
2987 * the MOS config, not necessarily from the userland config.
2988 */
3070 spa_check_removed(spa->spa_root_vdev);
3071 /*
3072 * For the import case, this is done in spa_import(), because
3073 * at this point we're using the spare definitions from
3074 * the MOS config, not necessarily from the userland config.
3075 */
2989 if (state != SPA_LOAD_IMPORT) {
3076 if (spa->spa_load_state != SPA_LOAD_IMPORT) {
2990 spa_aux_check_removed(&spa->spa_spares);
2991 spa_aux_check_removed(&spa->spa_l2cache);
2992 }
2993 }
2994
2995 /*
2996 * Load the vdev metadata such as metaslabs, DTLs, spacemap object, etc.
2997 */
2998 error = vdev_load(rvd);
2999 if (error != 0) {
3077 spa_aux_check_removed(&spa->spa_spares);
3078 spa_aux_check_removed(&spa->spa_l2cache);
3079 }
3080 }
3081
3082 /*
3083 * Load the vdev metadata such as metaslabs, DTLs, spacemap object, etc.
3084 */
3085 error = vdev_load(rvd);
3086 if (error != 0) {
3087 spa_load_failed(spa, "vdev_load failed [error=%d]", error);
3000 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, error));
3001 }
3002
3003 /*
3004 * Propagate the leaf DTLs we just loaded all the way up the vdev tree.
3005 */
3006 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3007 vdev_dtl_reassess(rvd, 0, 0, B_FALSE);

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

3012
3013static int
3014spa_ld_load_dedup_tables(spa_t *spa)
3015{
3016 int error = 0;
3017 vdev_t *rvd = spa->spa_root_vdev;
3018
3019 error = ddt_load(spa);
3088 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, error));
3089 }
3090
3091 /*
3092 * Propagate the leaf DTLs we just loaded all the way up the vdev tree.
3093 */
3094 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3095 vdev_dtl_reassess(rvd, 0, 0, B_FALSE);

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

3100
3101static int
3102spa_ld_load_dedup_tables(spa_t *spa)
3103{
3104 int error = 0;
3105 vdev_t *rvd = spa->spa_root_vdev;
3106
3107 error = ddt_load(spa);
3020 if (error != 0)
3108 if (error != 0) {
3109 spa_load_failed(spa, "ddt_load failed [error=%d]", error);
3021 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3110 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
3111 }
3022
3023 return (0);
3024}
3025
3026static int
3027spa_ld_verify_logs(spa_t *spa, spa_import_type_t type, char **ereport)
3028{
3029 vdev_t *rvd = spa->spa_root_vdev;
3030
3112
3113 return (0);
3114}
3115
3116static int
3117spa_ld_verify_logs(spa_t *spa, spa_import_type_t type, char **ereport)
3118{
3119 vdev_t *rvd = spa->spa_root_vdev;
3120
3031 if (type != SPA_IMPORT_ASSEMBLE && spa_writeable(spa) &&
3032 spa_check_logs(spa)) {
3033 *ereport = FM_EREPORT_ZFS_LOG_REPLAY;
3034 return (spa_vdev_err(rvd, VDEV_AUX_BAD_LOG, ENXIO));
3121 if (type != SPA_IMPORT_ASSEMBLE && spa_writeable(spa)) {
3122 boolean_t missing = spa_check_logs(spa);
3123 if (missing) {
3124 *ereport = FM_EREPORT_ZFS_LOG_REPLAY;
3125 spa_load_failed(spa, "spa_check_logs failed");
3126 return (spa_vdev_err(rvd, VDEV_AUX_BAD_LOG, ENXIO));
3127 }
3035 }
3036
3037 return (0);
3038}
3039
3040static int
3128 }
3129
3130 return (0);
3131}
3132
3133static int
3041spa_ld_verify_pool_data(spa_t *spa, spa_load_state_t state)
3134spa_ld_verify_pool_data(spa_t *spa)
3042{
3043 int error = 0;
3044 vdev_t *rvd = spa->spa_root_vdev;
3045
3046 /*
3047 * We've successfully opened the pool, verify that we're ready
3048 * to start pushing transactions.
3049 */
3135{
3136 int error = 0;
3137 vdev_t *rvd = spa->spa_root_vdev;
3138
3139 /*
3140 * We've successfully opened the pool, verify that we're ready
3141 * to start pushing transactions.
3142 */
3050 if (state != SPA_LOAD_TRYIMPORT) {
3143 if (spa->spa_load_state != SPA_LOAD_TRYIMPORT) {
3051 error = spa_load_verify(spa);
3052 if (error != 0) {
3144 error = spa_load_verify(spa);
3145 if (error != 0) {
3146 spa_load_failed(spa, "spa_load_verify failed "
3147 "[error=%d]", error);
3053 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
3054 error));
3055 }
3056 }
3057
3058 return (0);
3059}
3060

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

3079 dmu_tx_commit(tx);
3080
3081 spa->spa_claiming = B_FALSE;
3082
3083 spa_set_log_state(spa, SPA_LOG_GOOD);
3084}
3085
3086static void
3148 return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
3149 error));
3150 }
3151 }
3152
3153 return (0);
3154}
3155

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

3174 dmu_tx_commit(tx);
3175
3176 spa->spa_claiming = B_FALSE;
3177
3178 spa_set_log_state(spa, SPA_LOG_GOOD);
3179}
3180
3181static void
3087spa_ld_check_for_config_update(spa_t *spa, spa_load_state_t state,
3088 int64_t config_cache_txg)
3182spa_ld_check_for_config_update(spa_t *spa, uint64_t config_cache_txg)
3089{
3090 vdev_t *rvd = spa->spa_root_vdev;
3091 int need_update = B_FALSE;
3092
3093 /*
3094 * If the config cache is stale, or we have uninitialized
3095 * metaslabs (see spa_vdev_add()), then update the config.
3096 *
3097 * If this is a verbatim import, trust the current
3098 * in-core spa_config and update the disk labels.
3099 */
3100 if (config_cache_txg != spa->spa_config_txg ||
3183{
3184 vdev_t *rvd = spa->spa_root_vdev;
3185 int need_update = B_FALSE;
3186
3187 /*
3188 * If the config cache is stale, or we have uninitialized
3189 * metaslabs (see spa_vdev_add()), then update the config.
3190 *
3191 * If this is a verbatim import, trust the current
3192 * in-core spa_config and update the disk labels.
3193 */
3194 if (config_cache_txg != spa->spa_config_txg ||
3101 state == SPA_LOAD_IMPORT ||
3102 state == SPA_LOAD_RECOVER ||
3195 spa->spa_load_state == SPA_LOAD_IMPORT ||
3196 spa->spa_load_state == SPA_LOAD_RECOVER ||
3103 (spa->spa_import_flags & ZFS_IMPORT_VERBATIM))
3104 need_update = B_TRUE;
3105
3106 for (int c = 0; c < rvd->vdev_children; c++)
3107 if (rvd->vdev_child[c]->vdev_ms_array == 0)
3108 need_update = B_TRUE;
3109
3110 /*

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

3126 spa_load_state_t state, spa_import_type_t type, boolean_t trust_config,
3127 char **ereport)
3128{
3129 int error = 0;
3130 uint64_t config_cache_txg = spa->spa_config_txg;
3131 int orig_mode = spa->spa_mode;
3132 boolean_t missing_feat_write = B_FALSE;
3133
3197 (spa->spa_import_flags & ZFS_IMPORT_VERBATIM))
3198 need_update = B_TRUE;
3199
3200 for (int c = 0; c < rvd->vdev_children; c++)
3201 if (rvd->vdev_child[c]->vdev_ms_array == 0)
3202 need_update = B_TRUE;
3203
3204 /*

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

3220 spa_load_state_t state, spa_import_type_t type, boolean_t trust_config,
3221 char **ereport)
3222{
3223 int error = 0;
3224 uint64_t config_cache_txg = spa->spa_config_txg;
3225 int orig_mode = spa->spa_mode;
3226 boolean_t missing_feat_write = B_FALSE;
3227
3228 ASSERT(MUTEX_HELD(&spa_namespace_lock));
3229
3230 spa->spa_load_state = state;
3231 spa_load_note(spa, "LOADING");
3232
3134 /*
3135 * If this is an untrusted config, first access the pool in read-only
3136 * mode. We will then retrieve a trusted copy of the config from the MOS
3137 * and use it to reopen the pool in read-write mode.
3138 */
3139 if (!trust_config)
3140 spa->spa_mode = FREAD;
3141
3142 /*
3143 * Parse the config provided to create a vdev tree.
3144 */
3233 /*
3234 * If this is an untrusted config, first access the pool in read-only
3235 * mode. We will then retrieve a trusted copy of the config from the MOS
3236 * and use it to reopen the pool in read-write mode.
3237 */
3238 if (!trust_config)
3239 spa->spa_mode = FREAD;
3240
3241 /*
3242 * Parse the config provided to create a vdev tree.
3243 */
3145 error = spa_ld_parse_config(spa, pool_guid, config, state, type);
3244 error = spa_ld_parse_config(spa, pool_guid, config, type);
3146 if (error != 0)
3147 return (error);
3148
3149 /*
3150 * Now that we have the vdev tree, try to open each vdev. This involves
3151 * opening the underlying physical device, retrieving its geometry and
3152 * probing the vdev with a dummy I/O. The state of each vdev will be set
3153 * based on the success of those operations. After this we'll be ready

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

3205 error = spa_ld_open_indirect_vdev_metadata(spa);
3206 if (error != 0)
3207 return (error);
3208
3209 /*
3210 * Retrieve the full list of active features from the MOS and check if
3211 * they are all supported.
3212 */
3245 if (error != 0)
3246 return (error);
3247
3248 /*
3249 * Now that we have the vdev tree, try to open each vdev. This involves
3250 * opening the underlying physical device, retrieving its geometry and
3251 * probing the vdev with a dummy I/O. The state of each vdev will be set
3252 * based on the success of those operations. After this we'll be ready

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

3304 error = spa_ld_open_indirect_vdev_metadata(spa);
3305 if (error != 0)
3306 return (error);
3307
3308 /*
3309 * Retrieve the full list of active features from the MOS and check if
3310 * they are all supported.
3311 */
3213 error = spa_ld_check_features(spa, state, &missing_feat_write);
3312 error = spa_ld_check_features(spa, &missing_feat_write);
3214 if (error != 0)
3215 return (error);
3216
3217 /*
3218 * Load several special directories from the MOS needed by the dsl_pool
3219 * layer.
3220 */
3221 error = spa_ld_load_special_directories(spa);
3222 if (error != 0)
3223 return (error);
3224
3225 /*
3226 * If the config provided is not trusted, discard it and use the config
3227 * from the MOS to reload the pool.
3228 */
3229 if (!trust_config) {
3230 error = spa_ld_prepare_for_reload(spa, orig_mode);
3231 if (error != 0)
3232 return (error);
3313 if (error != 0)
3314 return (error);
3315
3316 /*
3317 * Load several special directories from the MOS needed by the dsl_pool
3318 * layer.
3319 */
3320 error = spa_ld_load_special_directories(spa);
3321 if (error != 0)
3322 return (error);
3323
3324 /*
3325 * If the config provided is not trusted, discard it and use the config
3326 * from the MOS to reload the pool.
3327 */
3328 if (!trust_config) {
3329 error = spa_ld_prepare_for_reload(spa, orig_mode);
3330 if (error != 0)
3331 return (error);
3332
3333 spa_load_note(spa, "RELOADING");
3233 return (spa_load(spa, state, SPA_IMPORT_EXISTING, B_TRUE));
3234 }
3235
3236 /*
3237 * Retrieve pool properties from the MOS.
3238 */
3239 error = spa_ld_get_props(spa);
3240 if (error != 0)

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

3247 error = spa_ld_open_aux_vdevs(spa, type);
3248 if (error != 0)
3249 return (error);
3250
3251 /*
3252 * Load the metadata for all vdevs. Also check if unopenable devices
3253 * should be autoreplaced.
3254 */
3334 return (spa_load(spa, state, SPA_IMPORT_EXISTING, B_TRUE));
3335 }
3336
3337 /*
3338 * Retrieve pool properties from the MOS.
3339 */
3340 error = spa_ld_get_props(spa);
3341 if (error != 0)

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

3348 error = spa_ld_open_aux_vdevs(spa, type);
3349 if (error != 0)
3350 return (error);
3351
3352 /*
3353 * Load the metadata for all vdevs. Also check if unopenable devices
3354 * should be autoreplaced.
3355 */
3255 error = spa_ld_load_vdev_metadata(spa, state);
3356 error = spa_ld_load_vdev_metadata(spa);
3256 if (error != 0)
3257 return (error);
3258
3259 error = spa_ld_load_dedup_tables(spa);
3260 if (error != 0)
3261 return (error);
3262
3263 /*

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

3280 ENOTSUP));
3281 }
3282
3283 /*
3284 * Traverse the last txgs to make sure the pool was left off in a safe
3285 * state. When performing an extreme rewind, we verify the whole pool,
3286 * which can take a very long time.
3287 */
3357 if (error != 0)
3358 return (error);
3359
3360 error = spa_ld_load_dedup_tables(spa);
3361 if (error != 0)
3362 return (error);
3363
3364 /*

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

3381 ENOTSUP));
3382 }
3383
3384 /*
3385 * Traverse the last txgs to make sure the pool was left off in a safe
3386 * state. When performing an extreme rewind, we verify the whole pool,
3387 * which can take a very long time.
3388 */
3288 error = spa_ld_verify_pool_data(spa, state);
3389 error = spa_ld_verify_pool_data(spa);
3289 if (error != 0)
3290 return (error);
3291
3292 /*
3293 * Calculate the deflated space for the pool. This must be done before
3294 * we write anything to the pool because we'd need to update the space
3295 * accounting using the deflated sizes.
3296 */

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

3337 */
3338 txg_wait_synced(spa->spa_dsl_pool, spa->spa_claim_max_txg);
3339
3340 /*
3341 * Check if we need to request an update of the config. On the
3342 * next sync, we would update the config stored in vdev labels
3343 * and the cachefile (by default /etc/zfs/zpool.cache).
3344 */
3390 if (error != 0)
3391 return (error);
3392
3393 /*
3394 * Calculate the deflated space for the pool. This must be done before
3395 * we write anything to the pool because we'd need to update the space
3396 * accounting using the deflated sizes.
3397 */

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

3438 */
3439 txg_wait_synced(spa->spa_dsl_pool, spa->spa_claim_max_txg);
3440
3441 /*
3442 * Check if we need to request an update of the config. On the
3443 * next sync, we would update the config stored in vdev labels
3444 * and the cachefile (by default /etc/zfs/zpool.cache).
3445 */
3345 spa_ld_check_for_config_update(spa, state, config_cache_txg);
3446 spa_ld_check_for_config_update(spa, config_cache_txg);
3346
3347 /*
3348 * Check all DTLs to see if anything needs resilvering.
3349 */
3350 if (!dsl_scan_resilvering(spa->spa_dsl_pool) &&
3351 vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
3352 spa_async_request(spa, SPA_ASYNC_RESILVER);
3353

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

3374 * can start a removal while we hold the spa_namespace_lock.
3375 */
3376 spa_restart_removal(spa);
3377
3378 if (condense_in_progress)
3379 spa_condense_indirect_restart(spa);
3380 }
3381
3447
3448 /*
3449 * Check all DTLs to see if anything needs resilvering.
3450 */
3451 if (!dsl_scan_resilvering(spa->spa_dsl_pool) &&
3452 vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
3453 spa_async_request(spa, SPA_ASYNC_RESILVER);
3454

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

3475 * can start a removal while we hold the spa_namespace_lock.
3476 */
3477 spa_restart_removal(spa);
3478
3479 if (condense_in_progress)
3480 spa_condense_indirect_restart(spa);
3481 }
3482
3483 spa_load_note(spa, "LOADED");
3484
3382 return (0);
3383}
3384
3385static int
3386spa_load_retry(spa_t *spa, spa_load_state_t state, int trust_config)
3387{
3388 int mode = spa->spa_mode;
3389
3390 spa_unload(spa);
3391 spa_deactivate(spa);
3392
3393 spa->spa_load_max_txg = spa->spa_uberblock.ub_txg - 1;
3394
3395 spa_activate(spa, mode);
3396 spa_async_suspend(spa);
3397
3485 return (0);
3486}
3487
3488static int
3489spa_load_retry(spa_t *spa, spa_load_state_t state, int trust_config)
3490{
3491 int mode = spa->spa_mode;
3492
3493 spa_unload(spa);
3494 spa_deactivate(spa);
3495
3496 spa->spa_load_max_txg = spa->spa_uberblock.ub_txg - 1;
3497
3498 spa_activate(spa, mode);
3499 spa_async_suspend(spa);
3500
3501 spa_load_note(spa, "spa_load_retry: rewind, max txg: %llu",
3502 (u_longlong_t)spa->spa_load_max_txg);
3503
3398 return (spa_load(spa, state, SPA_IMPORT_EXISTING, trust_config));
3399}
3400
3401/*
3402 * If spa_load() fails this function will try loading prior txg's. If
3403 * 'state' is SPA_LOAD_RECOVER and one of these loads succeeds the pool
3404 * will be rewound to that txg. If 'state' is not SPA_LOAD_RECOVER this
3405 * function will not rewind the pool and will return the same error as

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

3544 if (policy.zrp_request & ZPOOL_DO_REWIND)
3545 state = SPA_LOAD_RECOVER;
3546
3547 spa_activate(spa, spa_mode_global);
3548
3549 if (state != SPA_LOAD_RECOVER)
3550 spa->spa_last_ubsync_txg = spa->spa_load_txg = 0;
3551
3504 return (spa_load(spa, state, SPA_IMPORT_EXISTING, trust_config));
3505}
3506
3507/*
3508 * If spa_load() fails this function will try loading prior txg's. If
3509 * 'state' is SPA_LOAD_RECOVER and one of these loads succeeds the pool
3510 * will be rewound to that txg. If 'state' is not SPA_LOAD_RECOVER this
3511 * function will not rewind the pool and will return the same error as

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

3650 if (policy.zrp_request & ZPOOL_DO_REWIND)
3651 state = SPA_LOAD_RECOVER;
3652
3653 spa_activate(spa, spa_mode_global);
3654
3655 if (state != SPA_LOAD_RECOVER)
3656 spa->spa_last_ubsync_txg = spa->spa_load_txg = 0;
3657
3658 zfs_dbgmsg("spa_open_common: opening %s", pool);
3552 error = spa_load_best(spa, state, B_FALSE, policy.zrp_txg,
3553 policy.zrp_request);
3554
3555 if (error == EBADF) {
3556 /*
3557 * If vdev_validate() returns failure (indicated by
3558 * EBADF), it indicates that one of the vdevs indicates
3559 * that the pool has been exported or destroyed. If

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

4766 * as if it had been loaded at boot.
4767 */
4768 if (spa->spa_import_flags & ZFS_IMPORT_VERBATIM) {
4769 if (props != NULL)
4770 spa_configfile_set(spa, props, B_FALSE);
4771
4772 spa_write_cachefile(spa, B_FALSE, B_TRUE);
4773 spa_event_notify(spa, NULL, NULL, ESC_ZFS_POOL_IMPORT);
3659 error = spa_load_best(spa, state, B_FALSE, policy.zrp_txg,
3660 policy.zrp_request);
3661
3662 if (error == EBADF) {
3663 /*
3664 * If vdev_validate() returns failure (indicated by
3665 * EBADF), it indicates that one of the vdevs indicates
3666 * that the pool has been exported or destroyed. If

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

4873 * as if it had been loaded at boot.
4874 */
4875 if (spa->spa_import_flags & ZFS_IMPORT_VERBATIM) {
4876 if (props != NULL)
4877 spa_configfile_set(spa, props, B_FALSE);
4878
4879 spa_write_cachefile(spa, B_FALSE, B_TRUE);
4880 spa_event_notify(spa, NULL, NULL, ESC_ZFS_POOL_IMPORT);
4774
4881 zfs_dbgmsg("spa_import: verbatim import of %s", pool);
4775 mutex_exit(&spa_namespace_lock);
4776 return (0);
4777 }
4778
4779 spa_activate(spa, mode);
4780
4781 /*
4782 * Don't start async tasks until we know everything is healthy.

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

4790 /*
4791 * Pass off the heavy lifting to spa_load(). Pass TRUE for trust_config
4792 * because the user-supplied config is actually the one to trust when
4793 * doing an import.
4794 */
4795 if (state != SPA_LOAD_RECOVER)
4796 spa->spa_last_ubsync_txg = spa->spa_load_txg = 0;
4797
4882 mutex_exit(&spa_namespace_lock);
4883 return (0);
4884 }
4885
4886 spa_activate(spa, mode);
4887
4888 /*
4889 * Don't start async tasks until we know everything is healthy.

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

4897 /*
4898 * Pass off the heavy lifting to spa_load(). Pass TRUE for trust_config
4899 * because the user-supplied config is actually the one to trust when
4900 * doing an import.
4901 */
4902 if (state != SPA_LOAD_RECOVER)
4903 spa->spa_last_ubsync_txg = spa->spa_load_txg = 0;
4904
4905 zfs_dbgmsg("spa_import: importing %s%s", pool,
4906 (state == SPA_LOAD_RECOVER) ? " (RECOVERY MODE)" : "");
4798 error = spa_load_best(spa, state, B_TRUE, policy.zrp_txg,
4799 policy.zrp_request);
4800
4801 /*
4802 * Propagate anything learned while loading the pool and pass it
4803 * back to caller (i.e. rewind info, missing devices, etc).
4804 */
4805 VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,

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

4932
4933 /*
4934 * Create and initialize the spa structure.
4935 */
4936 mutex_enter(&spa_namespace_lock);
4937 spa = spa_add(TRYIMPORT_NAME, tryconfig, NULL);
4938 spa_activate(spa, FREAD);
4939
4907 error = spa_load_best(spa, state, B_TRUE, policy.zrp_txg,
4908 policy.zrp_request);
4909
4910 /*
4911 * Propagate anything learned while loading the pool and pass it
4912 * back to caller (i.e. rewind info, missing devices, etc).
4913 */
4914 VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,

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

5041
5042 /*
5043 * Create and initialize the spa structure.
5044 */
5045 mutex_enter(&spa_namespace_lock);
5046 spa = spa_add(TRYIMPORT_NAME, tryconfig, NULL);
5047 spa_activate(spa, FREAD);
5048
5049 zfs_dbgmsg("spa_tryimport: importing %s", poolname);
5050
4940 /*
4941 * Pass off the heavy lifting to spa_load().
4942 * Pass TRUE for trust_config because the user-supplied config
4943 * is actually the one to trust when doing an import.
4944 */
4945 error = spa_load(spa, SPA_LOAD_TRYIMPORT, SPA_IMPORT_EXISTING, B_TRUE);
4946
4947 /*

--- 2699 unchanged lines hidden ---
5051 /*
5052 * Pass off the heavy lifting to spa_load().
5053 * Pass TRUE for trust_config because the user-supplied config
5054 * is actually the one to trust when doing an import.
5055 */
5056 error = spa_load(spa, SPA_LOAD_TRYIMPORT, SPA_IMPORT_EXISTING, B_TRUE);
5057
5058 /*

--- 2699 unchanged lines hidden ---