752 metaslab_group_t *mg = msp->ms_group;
753
754 vdev_space_update(mg->mg_vd,
755 -msp->ms_smo.smo_alloc, 0, -msp->ms_map.sm_size);
756
757 metaslab_group_remove(mg, msp);
758
759 mutex_enter(&msp->ms_lock);
760
761 space_map_unload(&msp->ms_map);
762 space_map_destroy(&msp->ms_map);
763
764 for (int t = 0; t < TXG_SIZE; t++) {
765 space_map_destroy(&msp->ms_allocmap[t]);
766 space_map_destroy(&msp->ms_freemap[t]);
767 }
768
769 for (int t = 0; t < TXG_DEFER_SIZE; t++)
770 space_map_destroy(&msp->ms_defermap[t]);
771
772 ASSERT3S(msp->ms_deferspace, ==, 0);
773
774 mutex_exit(&msp->ms_lock);
775 mutex_destroy(&msp->ms_lock);
776
777 kmem_free(msp, sizeof (metaslab_t));
778 }
779
780 #define METASLAB_WEIGHT_PRIMARY (1ULL << 63)
781 #define METASLAB_WEIGHT_SECONDARY (1ULL << 62)
782 #define METASLAB_ACTIVE_MASK \
783 (METASLAB_WEIGHT_PRIMARY | METASLAB_WEIGHT_SECONDARY)
784
785 static uint64_t
786 metaslab_weight(metaslab_t *msp)
787 {
788 metaslab_group_t *mg = msp->ms_group;
789 space_map_t *sm = &msp->ms_map;
790 space_map_obj_t *smo = &msp->ms_smo;
791 vdev_t *vd = mg->mg_vd;
792 uint64_t weight, space;
|
752 metaslab_group_t *mg = msp->ms_group;
753
754 vdev_space_update(mg->mg_vd,
755 -msp->ms_smo.smo_alloc, 0, -msp->ms_map.sm_size);
756
757 metaslab_group_remove(mg, msp);
758
759 mutex_enter(&msp->ms_lock);
760
761 space_map_unload(&msp->ms_map);
762 space_map_destroy(&msp->ms_map);
763
764 for (int t = 0; t < TXG_SIZE; t++) {
765 space_map_destroy(&msp->ms_allocmap[t]);
766 space_map_destroy(&msp->ms_freemap[t]);
767 }
768
769 for (int t = 0; t < TXG_DEFER_SIZE; t++)
770 space_map_destroy(&msp->ms_defermap[t]);
771
772 ASSERT0(msp->ms_deferspace);
773
774 mutex_exit(&msp->ms_lock);
775 mutex_destroy(&msp->ms_lock);
776
777 kmem_free(msp, sizeof (metaslab_t));
778 }
779
780 #define METASLAB_WEIGHT_PRIMARY (1ULL << 63)
781 #define METASLAB_WEIGHT_SECONDARY (1ULL << 62)
782 #define METASLAB_ACTIVE_MASK \
783 (METASLAB_WEIGHT_PRIMARY | METASLAB_WEIGHT_SECONDARY)
784
785 static uint64_t
786 metaslab_weight(metaslab_t *msp)
787 {
788 metaslab_group_t *mg = msp->ms_group;
789 space_map_t *sm = &msp->ms_map;
790 space_map_obj_t *smo = &msp->ms_smo;
791 vdev_t *vd = mg->mg_vd;
792 uint64_t weight, space;
|