aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-02-15 22:43:01 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-16 11:45:50 -0500
commit90f9dd8f72773152b69042debd6b9ed6d224703a (patch)
tree36a122a5672e0bb5f8f77e19619954f6073985b3 /lib
parentd89b8f40fca43cab829fea5c0e7d3951db2fb4bd (diff)
[PATCH] Fix over-zealous tag clearing in radix_tree_delete
If a tag is set for a node being deleted from a radix_tree, then that tag gets cleared from the parent of the node, even if it is set for some siblings of the node begin deleted. This patch changes the logic to include a test for any_tag_set similar to the logic a little futher down. Care is taken to ensure that 'nr_cleared_tags' remains equals to the number of entries in the 'tags' array which are set to '0' (which means that this tag is not set in the tree below pathp->node, and should be cleared at pathp->node and possibly above. [ Nick says: "Linus FYI, I was able to modify the radix tree test harness to catch the bug and can no longer trigger it after the fix. Resulting code passes all other harness tests as well of course." ] Signed-off-by: Neil Brown <neilb@suse.de> Acked-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/radix-tree.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index c0bd4a91480..1e5b17dc7e3 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -752,12 +752,14 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
752 */ 752 */
753 nr_cleared_tags = 0; 753 nr_cleared_tags = 0;
754 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) { 754 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
755 tags[tag] = 1;
755 if (tag_get(pathp->node, tag, pathp->offset)) { 756 if (tag_get(pathp->node, tag, pathp->offset)) {
756 tag_clear(pathp->node, tag, pathp->offset); 757 tag_clear(pathp->node, tag, pathp->offset);
757 tags[tag] = 0; 758 if (!any_tag_set(pathp->node, tag)) {
758 nr_cleared_tags++; 759 tags[tag] = 0;
759 } else 760 nr_cleared_tags++;
760 tags[tag] = 1; 761 }
762 }
761 } 763 }
762 764
763 for (pathp--; nr_cleared_tags && pathp->node; pathp--) { 765 for (pathp--; nr_cleared_tags && pathp->node; pathp--) {