How to destroy one radix tree in linux kernel

924 Views Asked by At

I'm trying to use radix tree to maintain one internal data for the driver. So what's the proper way to destroy the whole tree?

One thought is to traverse the tree with the method mentioned at: 1

For each node, free the item and delete its key from the tree.

The other question is, is radix_tree_for_each_slot() safe with delete item inside the loop? Will delete trigger internal shrink and cause iteration failure?

1

There are 1 best solutions below

3
On BEST ANSWER

Check out cgwb_bdi_unregister.

It seems to be doing pretty much what you need - it iterates over the radix tree with radix_tree_for_each_slot() and while doing so it does also radix_tree_delete (from cgwb_kill).

So I guess nothing should blow up if you're keeping things properly synchronized.