* Remove a log device. The config lock is held for the specified TXG. */
| 1850 | * Remove a log device. The config lock is held for the specified TXG. |
| 1851 | */ |
| 1852 | static int |
| 1853 | spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) |
| 1854 | { |
| 1855 | metaslab_group_t *mg = vd->vdev_mg; |
| 1856 | spa_t *spa = vd->vdev_spa; |
| 1857 | int error = 0; |
| 1858 | |
| 1859 | ASSERT(vd->vdev_islog); |
| 1860 | ASSERT(vd == vd->vdev_top); |
| 1861 | ASSERT(MUTEX_HELD(&spa_namespace_lock)); |
| 1862 | |
| 1863 | /* |
| 1864 | * Stop allocating from this vdev. |
| 1865 | */ |
| 1866 | metaslab_group_passivate(mg); |
| 1867 | |
| 1868 | /* |
| 1869 | * Wait for the youngest allocations and frees to sync, |
| 1870 | * and then wait for the deferral of those frees to finish. |
| 1871 | */ |
| 1872 | spa_vdev_config_exit(spa, NULL, |
| 1873 | *txg + TXG_CONCURRENT_STATES + TXG_DEFER_SIZE, 0, FTAG); |
| 1874 | |
| 1875 | /* |
| 1876 | * Cancel any initialize or TRIM which was in progress. |
| 1877 | */ |
| 1878 | vdev_initialize_stop_all(vd, VDEV_INITIALIZE_CANCELED); |
| 1879 | vdev_trim_stop_all(vd, VDEV_TRIM_CANCELED); |
| 1880 | vdev_autotrim_stop_wait(vd); |
| 1881 | |
| 1882 | /* |
| 1883 | * Evacuate the device. We don't hold the config lock as |
| 1884 | * writer since we need to do I/O but we do keep the |
| 1885 | * spa_namespace_lock held. Once this completes the device |
| 1886 | * should no longer have any blocks allocated on it. |
| 1887 | */ |
| 1888 | ASSERT(MUTEX_HELD(&spa_namespace_lock)); |
| 1889 | if (vd->vdev_stat.vs_alloc != 0) |
| 1890 | error = spa_reset_logs(spa); |
| 1891 | |
| 1892 | *txg = spa_vdev_config_enter(spa); |
| 1893 | |
| 1894 | if (error != 0) { |
| 1895 | metaslab_group_activate(mg); |
| 1896 | return (error); |
| 1897 | } |
| 1898 | ASSERT0(vd->vdev_stat.vs_alloc); |
| 1899 | |
| 1900 | /* |
| 1901 | * The evacuation succeeded. Remove any remaining MOS metadata |
| 1902 | * associated with this vdev, and wait for these changes to sync. |
| 1903 | */ |
| 1904 | vd->vdev_removing = B_TRUE; |
| 1905 | |
| 1906 | vdev_dirty_leaves(vd, VDD_DTL, *txg); |
| 1907 | vdev_config_dirty(vd); |
| 1908 | |
| 1909 | /* |
no test coverage detected