aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/vdev_trim.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/vdev_trim.c')
-rw-r--r--module/zfs/vdev_trim.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/module/zfs/vdev_trim.c b/module/zfs/vdev_trim.c
index 771e7a159..c7c429cbd 100644
--- a/module/zfs/vdev_trim.c
+++ b/module/zfs/vdev_trim.c
@@ -523,7 +523,8 @@ static int
vdev_trim_ranges(trim_args_t *ta)
{
vdev_t *vd = ta->trim_vdev;
- avl_tree_t *rt = &ta->trim_tree->rt_root;
+ zfs_btree_t *t = &ta->trim_tree->rt_root;
+ zfs_btree_index_t idx;
uint64_t extent_bytes_max = ta->trim_extent_bytes_max;
uint64_t extent_bytes_min = ta->trim_extent_bytes_min;
spa_t *spa = vd->vdev_spa;
@@ -531,9 +532,10 @@ vdev_trim_ranges(trim_args_t *ta)
ta->trim_start_time = gethrtime();
ta->trim_bytes_done = 0;
- for (range_seg_t *rs = avl_first(rt); rs != NULL;
- rs = AVL_NEXT(rt, rs)) {
- uint64_t size = rs->rs_end - rs->rs_start;
+ for (range_seg_t *rs = zfs_btree_first(t, &idx); rs != NULL;
+ rs = zfs_btree_next(t, &idx, &idx)) {
+ uint64_t size = rs_get_end(rs, ta->trim_tree) - rs_get_start(rs,
+ ta->trim_tree);
if (extent_bytes_min && size < extent_bytes_min) {
spa_iostats_trim_add(spa, ta->trim_type,
@@ -548,9 +550,9 @@ vdev_trim_ranges(trim_args_t *ta)
int error;
error = vdev_trim_range(ta, VDEV_LABEL_START_SIZE +
- rs->rs_start + (w * extent_bytes_max),
- MIN(size - (w * extent_bytes_max),
- extent_bytes_max));
+ rs_get_start(rs, ta->trim_tree) +
+ (w *extent_bytes_max), MIN(size -
+ (w * extent_bytes_max), extent_bytes_max));
if (error != 0) {
return (error);
}
@@ -588,7 +590,7 @@ vdev_trim_calculate_progress(vdev_t *vd)
* on our vdev. We use this to determine if we are
* in the middle of this metaslab range.
*/
- range_seg_t logical_rs, physical_rs;
+ range_seg64_t logical_rs, physical_rs;
logical_rs.rs_start = msp->ms_start;
logical_rs.rs_end = msp->ms_start + msp->ms_size;
vdev_xlate(vd, &logical_rs, &physical_rs);
@@ -611,10 +613,13 @@ vdev_trim_calculate_progress(vdev_t *vd)
*/
VERIFY0(metaslab_load(msp));
- for (range_seg_t *rs = avl_first(&msp->ms_allocatable->rt_root);
- rs; rs = AVL_NEXT(&msp->ms_allocatable->rt_root, rs)) {
- logical_rs.rs_start = rs->rs_start;
- logical_rs.rs_end = rs->rs_end;
+ range_tree_t *rt = msp->ms_allocatable;
+ zfs_btree_t *bt = &rt->rt_root;
+ zfs_btree_index_t idx;
+ for (range_seg_t *rs = zfs_btree_first(bt, &idx);
+ rs != NULL; rs = zfs_btree_next(bt, &idx, &idx)) {
+ logical_rs.rs_start = rs_get_start(rs, rt);
+ logical_rs.rs_end = rs_get_end(rs, rt);
vdev_xlate(vd, &logical_rs, &physical_rs);
uint64_t size = physical_rs.rs_end -
@@ -706,7 +711,7 @@ vdev_trim_range_add(void *arg, uint64_t start, uint64_t size)
{
trim_args_t *ta = arg;
vdev_t *vd = ta->trim_vdev;
- range_seg_t logical_rs, physical_rs;
+ range_seg64_t logical_rs, physical_rs;
logical_rs.rs_start = start;
logical_rs.rs_end = start + size;
@@ -719,7 +724,7 @@ vdev_trim_range_add(void *arg, uint64_t start, uint64_t size)
metaslab_t *msp = ta->trim_msp;
VERIFY0(metaslab_load(msp));
VERIFY3B(msp->ms_loaded, ==, B_TRUE);
- VERIFY(range_tree_find(msp->ms_allocatable, start, size));
+ VERIFY(range_tree_contains(msp->ms_allocatable, start, size));
}
ASSERT(vd->vdev_ops->vdev_op_leaf);
@@ -798,7 +803,7 @@ vdev_trim_thread(void *arg)
ta.trim_vdev = vd;
ta.trim_extent_bytes_max = zfs_trim_extent_bytes_max;
ta.trim_extent_bytes_min = zfs_trim_extent_bytes_min;
- ta.trim_tree = range_tree_create(NULL, NULL);
+ ta.trim_tree = range_tree_create(NULL, RANGE_SEG64, NULL, 0, 0);
ta.trim_type = TRIM_TYPE_MANUAL;
ta.trim_flags = 0;
@@ -1080,7 +1085,7 @@ vdev_trim_range_verify(void *arg, uint64_t start, uint64_t size)
VERIFY3B(msp->ms_loaded, ==, B_TRUE);
VERIFY3U(msp->ms_disabled, >, 0);
- VERIFY(range_tree_find(msp->ms_allocatable, start, size) != NULL);
+ VERIFY(range_tree_contains(msp->ms_allocatable, start, size));
}
/*
@@ -1178,7 +1183,8 @@ vdev_autotrim_thread(void *arg)
* Allocate an empty range tree which is swapped in
* for the existing ms_trim tree while it is processed.
*/
- trim_tree = range_tree_create(NULL, NULL);
+ trim_tree = range_tree_create(NULL, RANGE_SEG64, NULL,
+ 0, 0);
range_tree_swap(&msp->ms_trim, &trim_tree);
ASSERT(range_tree_is_empty(msp->ms_trim));
@@ -1232,7 +1238,8 @@ vdev_autotrim_thread(void *arg)
if (!cvd->vdev_ops->vdev_op_leaf)
continue;
- ta->trim_tree = range_tree_create(NULL, NULL);
+ ta->trim_tree = range_tree_create(NULL,
+ RANGE_SEG64, NULL, 0, 0);
range_tree_walk(trim_tree,
vdev_trim_range_add, ta);
}