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

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

2559}
2560
2561/*
2562 * Pool export/destroy
2563 *
2564 * The act of destroying or exporting a pool is very simple. We make sure there
2565 * is no more pending I/O and any references to the pool are gone. Then, we
2566 * update the pool state and sync all the labels to disk, removing the
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

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

2559}
2560
2561/*
2562 * Pool export/destroy
2563 *
2564 * The act of destroying or exporting a pool is very simple. We make sure there
2565 * is no more pending I/O and any references to the pool are gone. Then, we
2566 * update the pool state and sync all the labels to disk, removing the
2567 * configuration from the cache afterwards.
2567 * configuration from the cache afterwards. If the 'hardforce' flag is set, then
2568 * we don't sync the labels or remove the configuration cache.
2568 */
2569static int
2570spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
2569 */
2570static int
2571spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
2571 boolean_t force)
2572 boolean_t force, boolean_t hardforce)
2572{
2573 spa_t *spa;
2574
2575 if (oldconfig)
2576 *oldconfig = NULL;
2577
2578 if (!(spa_mode & FWRITE))
2579 return (EROFS);

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

2631 return (EXDEV);
2632 }
2633
2634 /*
2635 * We want this to be reflected on every label,
2636 * so mark them all dirty. spa_unload() will do the
2637 * final sync that pushes these changes out.
2638 */
2573{
2574 spa_t *spa;
2575
2576 if (oldconfig)
2577 *oldconfig = NULL;
2578
2579 if (!(spa_mode & FWRITE))
2580 return (EROFS);

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

2632 return (EXDEV);
2633 }
2634
2635 /*
2636 * We want this to be reflected on every label,
2637 * so mark them all dirty. spa_unload() will do the
2638 * final sync that pushes these changes out.
2639 */
2639 if (new_state != POOL_STATE_UNINITIALIZED) {
2640 if (new_state != POOL_STATE_UNINITIALIZED && !hardforce) {
2640 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2641 spa->spa_state = new_state;
2642 spa->spa_final_txg = spa_last_synced_txg(spa) + 1;
2643 vdev_config_dirty(spa->spa_root_vdev);
2644 spa_config_exit(spa, SCL_ALL, FTAG);
2645 }
2646 }
2647
2648 spa_event_notify(spa, NULL, ESC_ZFS_POOL_DESTROY);
2649
2650 if (spa->spa_state != POOL_STATE_UNINITIALIZED) {
2651 spa_unload(spa);
2652 spa_deactivate(spa);
2653 }
2654
2655 if (oldconfig && spa->spa_config)
2656 VERIFY(nvlist_dup(spa->spa_config, oldconfig, 0) == 0);
2657
2658 if (new_state != POOL_STATE_UNINITIALIZED) {
2641 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
2642 spa->spa_state = new_state;
2643 spa->spa_final_txg = spa_last_synced_txg(spa) + 1;
2644 vdev_config_dirty(spa->spa_root_vdev);
2645 spa_config_exit(spa, SCL_ALL, FTAG);
2646 }
2647 }
2648
2649 spa_event_notify(spa, NULL, ESC_ZFS_POOL_DESTROY);
2650
2651 if (spa->spa_state != POOL_STATE_UNINITIALIZED) {
2652 spa_unload(spa);
2653 spa_deactivate(spa);
2654 }
2655
2656 if (oldconfig && spa->spa_config)
2657 VERIFY(nvlist_dup(spa->spa_config, oldconfig, 0) == 0);
2658
2659 if (new_state != POOL_STATE_UNINITIALIZED) {
2659 spa_config_sync(spa, B_TRUE, B_TRUE);
2660 if (!hardforce)
2661 spa_config_sync(spa, B_TRUE, B_TRUE);
2660 spa_remove(spa);
2661 }
2662 mutex_exit(&spa_namespace_lock);
2663
2664 return (0);
2665}
2666
2667/*
2668 * Destroy a storage pool.
2669 */
2670int
2671spa_destroy(char *pool)
2672{
2662 spa_remove(spa);
2663 }
2664 mutex_exit(&spa_namespace_lock);
2665
2666 return (0);
2667}
2668
2669/*
2670 * Destroy a storage pool.
2671 */
2672int
2673spa_destroy(char *pool)
2674{
2673 return (spa_export_common(pool, POOL_STATE_DESTROYED, NULL, B_FALSE));
2675 return (spa_export_common(pool, POOL_STATE_DESTROYED, NULL,
2676 B_FALSE, B_FALSE));
2674}
2675
2676/*
2677 * Export a storage pool.
2678 */
2679int
2677}
2678
2679/*
2680 * Export a storage pool.
2681 */
2682int
2680spa_export(char *pool, nvlist_t **oldconfig, boolean_t force)
2683spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
2684 boolean_t hardforce)
2681{
2685{
2682 return (spa_export_common(pool, POOL_STATE_EXPORTED, oldconfig, force));
2686 return (spa_export_common(pool, POOL_STATE_EXPORTED, oldconfig,
2687 force, hardforce));
2683}
2684
2685/*
2686 * Similar to spa_export(), this unloads the spa_t without actually removing it
2687 * from the namespace in any way.
2688 */
2689int
2690spa_reset(char *pool)
2691{
2692 return (spa_export_common(pool, POOL_STATE_UNINITIALIZED, NULL,
2688}
2689
2690/*
2691 * Similar to spa_export(), this unloads the spa_t without actually removing it
2692 * from the namespace in any way.
2693 */
2694int
2695spa_reset(char *pool)
2696{
2697 return (spa_export_common(pool, POOL_STATE_UNINITIALIZED, NULL,
2693 B_FALSE));
2698 B_FALSE, B_FALSE));
2694}
2695
2696/*
2697 * ==========================================================================
2698 * Device manipulation
2699 * ==========================================================================
2700 */
2701

--- 1608 unchanged lines hidden ---
2699}
2700
2701/*
2702 * ==========================================================================
2703 * Device manipulation
2704 * ==========================================================================
2705 */
2706

--- 1608 unchanged lines hidden ---