aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorPaul Dagnelie <[email protected]>2020-10-14 08:59:54 -0700
committerBrian Behlendorf <[email protected]>2020-10-16 13:05:23 -0700
commitd8091c929488ba9ba4113ac1b5e00e018c92f39f (patch)
tree728345931db1fe25e6292a390b8e1f235c84d324 /module
parent05613fa7a379a60076d8795518396fa82da00aea (diff)
Fix incorrect deletion order in range_tree_add_impl gap case
After a side-effectful call like add or remove, references to range segs stored in btrees can no longer be used safely. We move the remove call to just before the reinsertion call so that the seg remains valid for as long as we need it. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #11044 Closes #11056
Diffstat (limited to 'module')
-rw-r--r--module/zfs/range_tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/module/zfs/range_tree.c b/module/zfs/range_tree.c
index 2ce0139c9..5219fd079 100644
--- a/module/zfs/range_tree.c
+++ b/module/zfs/range_tree.c
@@ -314,7 +314,6 @@ range_tree_add_impl(void *arg, uint64_t start, uint64_t size, uint64_t fill)
return;
}
- zfs_btree_remove(&rt->rt_root, rs);
if (rt->rt_ops != NULL && rt->rt_ops->rtop_remove != NULL)
rt->rt_ops->rtop_remove(rt, rs, rt->rt_arg);
@@ -326,6 +325,7 @@ range_tree_add_impl(void *arg, uint64_t start, uint64_t size, uint64_t fill)
end = MAX(end, rend);
size = end - start;
+ zfs_btree_remove(&rt->rt_root, rs);
range_tree_add_impl(rt, start, size, fill);
return;
}