| 1434 | } |
| 1435 | |
| 1436 | void |
| 1437 | vdev_metaslab_fini(vdev_t *vd) |
| 1438 | { |
| 1439 | if (vd->vdev_checkpoint_sm != NULL) { |
| 1440 | ASSERT(spa_feature_is_active(vd->vdev_spa, |
| 1441 | SPA_FEATURE_POOL_CHECKPOINT)); |
| 1442 | space_map_close(vd->vdev_checkpoint_sm); |
| 1443 | /* |
| 1444 | * Even though we close the space map, we need to set its |
| 1445 | * pointer to NULL. The reason is that vdev_metaslab_fini() |
| 1446 | * may be called multiple times for certain operations |
| 1447 | * (i.e. when destroying a pool) so we need to ensure that |
| 1448 | * this clause never executes twice. This logic is similar |
| 1449 | * to the one used for the vdev_ms clause below. |
| 1450 | */ |
| 1451 | vd->vdev_checkpoint_sm = NULL; |
| 1452 | } |
| 1453 | |
| 1454 | if (vd->vdev_ms != NULL) { |
| 1455 | metaslab_group_t *mg = vd->vdev_mg; |
| 1456 | metaslab_group_passivate(mg); |
| 1457 | |
| 1458 | uint64_t count = vd->vdev_ms_count; |
| 1459 | for (uint64_t m = 0; m < count; m++) { |
| 1460 | metaslab_t *msp = vd->vdev_ms[m]; |
| 1461 | if (msp != NULL) |
| 1462 | metaslab_fini(msp); |
| 1463 | } |
| 1464 | vmem_free(vd->vdev_ms, count * sizeof (metaslab_t *)); |
| 1465 | vd->vdev_ms = NULL; |
| 1466 | |
| 1467 | vd->vdev_ms_count = 0; |
| 1468 | |
| 1469 | for (int i = 0; i < RANGE_TREE_HISTOGRAM_SIZE; i++) |
| 1470 | ASSERT0(mg->mg_histogram[i]); |
| 1471 | } |
| 1472 | ASSERT0(vd->vdev_ms_count); |
| 1473 | ASSERT3U(vd->vdev_pending_fastwrite, ==, 0); |
| 1474 | } |
| 1475 | |
| 1476 | typedef struct vdev_probe_stats { |
| 1477 | boolean_t vps_readable; |
no test coverage detected