@@ -368,6 +368,22 @@ static metaslab_stats_t metaslab_stats = {
368
368
#define METASLABSTAT_BUMP (stat ) \
369
369
atomic_inc_64(&metaslab_stats.stat.value.ui64);
370
370
371
+ static inline char *
372
+ metaslab_range_tree_instance (metaslab_group_t * mg , metaslab_t * ms ,
373
+ const char * rt_name )
374
+ {
375
+ const size_t len = 4 * ZFS_MAX_DATASET_NAME_LEN ;
376
+ char * buf = kmem_zalloc (len , KM_SLEEP );
377
+
378
+ snprintf (buf , len , "{spa=%s vdev_guid=%llu ms_id=%llu %s}" ,
379
+ mg -> mg_vd -> vdev_spa -> spa_name ,
380
+ (u_longlong_t )mg -> mg_vd -> vdev_guid ,
381
+ (u_longlong_t )ms -> ms_id ,
382
+ rt_name );
383
+
384
+ return (buf );
385
+ }
386
+
371
387
372
388
static kstat_t * metaslab_ksp ;
373
389
@@ -2753,30 +2769,53 @@ metaslab_init(metaslab_group_t *mg, uint64_t id, uint64_t object,
2753
2769
zfs_range_seg_type_t type =
2754
2770
metaslab_calculate_range_tree_type (vd , ms , & start , & shift );
2755
2771
2756
- ms -> ms_allocatable = zfs_range_tree_create (NULL , type , NULL , start ,
2757
- shift );
2772
+ ms -> ms_allocatable = zfs_range_tree_create_usecase (
2773
+ NULL , type , NULL , start , shift ,
2774
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2775
+ metaslab_range_tree_instance (mg , ms , "ms_allocatable" ));
2758
2776
for (int t = 0 ; t < TXG_SIZE ; t ++ ) {
2759
- ms -> ms_allocating [t ] = zfs_range_tree_create (NULL , type ,
2760
- NULL , start , shift );
2761
- }
2762
- ms -> ms_freeing = zfs_range_tree_create (NULL , type , NULL , start , shift );
2763
- ms -> ms_freed = zfs_range_tree_create (NULL , type , NULL , start , shift );
2777
+ ms -> ms_allocating [t ] = zfs_range_tree_create_usecase (
2778
+ NULL , type , NULL , start , shift ,
2779
+ ZFS_RANGE_TREE_UC_ALLOCATED_SPACE |
2780
+ ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2781
+ metaslab_range_tree_instance (mg , ms , "ms_allocating" ));
2782
+ }
2783
+ ms -> ms_freeing = zfs_range_tree_create_usecase (
2784
+ NULL , type , NULL , start , shift ,
2785
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2786
+ metaslab_range_tree_instance (mg , ms , "ms_freeing" ));
2787
+ ms -> ms_freed = zfs_range_tree_create_usecase (
2788
+ NULL , type , NULL , start , shift ,
2789
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2790
+ metaslab_range_tree_instance (mg , ms , "ms_freed" ));
2764
2791
for (int t = 0 ; t < TXG_DEFER_SIZE ; t ++ ) {
2765
- ms -> ms_defer [t ] = zfs_range_tree_create (NULL , type , NULL ,
2766
- start , shift );
2767
- }
2768
- ms -> ms_checkpointing =
2769
- zfs_range_tree_create (NULL , type , NULL , start , shift );
2770
- ms -> ms_unflushed_allocs =
2771
- zfs_range_tree_create (NULL , type , NULL , start , shift );
2792
+ ms -> ms_defer [t ] = zfs_range_tree_create_usecase (
2793
+ NULL , type , NULL , start , shift ,
2794
+ ZFS_RANGE_TREE_UC_FREE_SPACE |
2795
+ ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2796
+ metaslab_range_tree_instance (mg , ms , "ms_defer" ));
2797
+ }
2798
+ ms -> ms_checkpointing = zfs_range_tree_create_usecase (
2799
+ NULL , type , NULL , start , shift ,
2800
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2801
+ metaslab_range_tree_instance (mg , ms , "ms_checkpointing" ));
2802
+ ms -> ms_unflushed_allocs = zfs_range_tree_create_usecase (
2803
+ NULL , type , NULL , start , shift ,
2804
+ ZFS_RANGE_TREE_UC_ALLOCATED_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2805
+ metaslab_range_tree_instance (mg , ms , "ms_unflushed_allocs" ));
2772
2806
2773
2807
metaslab_rt_arg_t * mrap = kmem_zalloc (sizeof (* mrap ), KM_SLEEP );
2774
2808
mrap -> mra_bt = & ms -> ms_unflushed_frees_by_size ;
2775
2809
mrap -> mra_floor_shift = metaslab_by_size_min_shift ;
2776
- ms -> ms_unflushed_frees = zfs_range_tree_create (& metaslab_rt_ops ,
2777
- type , mrap , start , shift );
2810
+ ms -> ms_unflushed_frees = zfs_range_tree_create_usecase (
2811
+ & metaslab_rt_ops , type , mrap , start , shift ,
2812
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2813
+ metaslab_range_tree_instance (mg , ms , "ms_unflushed_frees" ));
2778
2814
2779
- ms -> ms_trim = zfs_range_tree_create (NULL , type , NULL , start , shift );
2815
+ ms -> ms_trim = zfs_range_tree_create_usecase (
2816
+ NULL , type , NULL , start , shift ,
2817
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
2818
+ metaslab_range_tree_instance (mg , ms , "ms_trim" ));
2780
2819
2781
2820
metaslab_group_add (mg , ms );
2782
2821
metaslab_set_fragmentation (ms , B_FALSE );
@@ -3750,7 +3789,10 @@ metaslab_condense(metaslab_t *msp, dmu_tx_t *tx)
3750
3789
type = metaslab_calculate_range_tree_type (msp -> ms_group -> mg_vd , msp ,
3751
3790
& start , & shift );
3752
3791
3753
- condense_tree = zfs_range_tree_create (NULL , type , NULL , start , shift );
3792
+ condense_tree = zfs_range_tree_create_usecase (
3793
+ NULL , type , NULL , start , shift ,
3794
+ ZFS_RANGE_TREE_UC_FREE_SPACE | ZFS_RANGE_TREE_UC_DYN_INSTANCE ,
3795
+ metaslab_range_tree_instance (msp -> ms_group , msp , "condense_tree" ));
3754
3796
3755
3797
for (int t = 0 ; t < TXG_DEFER_SIZE ; t ++ ) {
3756
3798
zfs_range_tree_walk (msp -> ms_defer [t ],
0 commit comments