Skip to content

Commit

Permalink
Rename range_tree_verify to range_tree_verify_not_present
Browse files Browse the repository at this point in the history
The range_tree_verify function looks for a segment in a
range tree and panics if the segment is present on the
tree. This patch gives the function a more descriptive
name.

Reviewed-by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes openzfs#8327
  • Loading branch information
sdimitro authored and behlendorf committed Jan 25, 2019
1 parent 107dd2b commit df72b8b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4858,7 +4858,8 @@ verify_checkpoint_sm_entry_cb(space_map_entry_t *sme, void *arg)
* their respective ms_allocateable trees should not contain them.
*/
mutex_enter(&ms->ms_lock);
range_tree_verify(ms->ms_allocatable, sme->sme_offset, sme->sme_run);
range_tree_verify_not_present(ms->ms_allocatable,
sme->sme_offset, sme->sme_run);
mutex_exit(&ms->ms_lock);

return (0);
Expand Down Expand Up @@ -5009,7 +5010,7 @@ verify_checkpoint_ms_spacemaps(spa_t *checkpoint, spa_t *current)
* are part of the checkpoint were freed by mistake.
*/
range_tree_walk(ckpoint_msp->ms_allocatable,
(range_tree_func_t *)range_tree_verify,
(range_tree_func_t *)range_tree_verify_not_present,
current_msp->ms_allocatable);
}
}
Expand Down
3 changes: 2 additions & 1 deletion include/sys/range_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ range_tree_t *range_tree_create_impl(range_tree_ops_t *ops, void *arg,
range_tree_t *range_tree_create(range_tree_ops_t *ops, void *arg);
void range_tree_destroy(range_tree_t *rt);
boolean_t range_tree_contains(range_tree_t *rt, uint64_t start, uint64_t size);
void range_tree_verify_not_present(range_tree_t *rt,
uint64_t start, uint64_t size);
range_seg_t *range_tree_find(range_tree_t *rt, uint64_t start, uint64_t size);
void range_tree_resize_segment(range_tree_t *rt, range_seg_t *rs,
uint64_t newstart, uint64_t newsize);
uint64_t range_tree_space(range_tree_t *rt);
boolean_t range_tree_is_empty(range_tree_t *rt);
void range_tree_verify(range_tree_t *rt, uint64_t start, uint64_t size);
void range_tree_swap(range_tree_t **rtsrc, range_tree_t **rtdst);
void range_tree_stat_verify(range_tree_t *rt);
uint64_t range_tree_min(range_tree_t *rt);
Expand Down
14 changes: 8 additions & 6 deletions module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -4256,14 +4256,16 @@ metaslab_check_free_impl(vdev_t *vd, uint64_t offset, uint64_t size)
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];

mutex_enter(&msp->ms_lock);
if (msp->ms_loaded)
range_tree_verify(msp->ms_allocatable, offset, size);
if (msp->ms_loaded) {
range_tree_verify_not_present(msp->ms_allocatable,
offset, size);
}

range_tree_verify(msp->ms_freeing, offset, size);
range_tree_verify(msp->ms_checkpointing, offset, size);
range_tree_verify(msp->ms_freed, offset, size);
range_tree_verify_not_present(msp->ms_freeing, offset, size);
range_tree_verify_not_present(msp->ms_checkpointing, offset, size);
range_tree_verify_not_present(msp->ms_freed, offset, size);
for (int j = 0; j < TXG_DEFER_SIZE; j++)
range_tree_verify(msp->ms_defer[j], offset, size);
range_tree_verify_not_present(msp->ms_defer[j], offset, size);
mutex_exit(&msp->ms_lock);
}

Expand Down
8 changes: 3 additions & 5 deletions module/zfs/range_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,11 @@ range_tree_find(range_tree_t *rt, uint64_t start, uint64_t size)
}

void
range_tree_verify(range_tree_t *rt, uint64_t off, uint64_t size)
range_tree_verify_not_present(range_tree_t *rt, uint64_t off, uint64_t size)
{
range_seg_t *rs;

rs = range_tree_find(rt, off, size);
range_seg_t *rs = range_tree_find(rt, off, size);
if (rs != NULL)
panic("freeing free block; rs=%p", (void *)rs);
panic("segment already in tree; rs=%p", (void *)rs);
}

boolean_t
Expand Down

0 comments on commit df72b8b

Please sign in to comment.