]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Fix over-zealous tag clearing in radix_tree_delete
authorNeilBrown <neilb@suse.de>
Thu, 16 Feb 2006 03:43:01 +0000 (14:43 +1100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 16 Feb 2006 16:45:50 +0000 (08:45 -0800)
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>
lib/radix-tree.c

index c0bd4a91480387e0c22d43b65d7f75fc2a522188..1e5b17dc7e3d5c6da19bdb2376e7a0a120cbc722 100644 (file)
@@ -752,12 +752,14 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
         */
        nr_cleared_tags = 0;
        for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+               tags[tag] = 1;
                if (tag_get(pathp->node, tag, pathp->offset)) {
                        tag_clear(pathp->node, tag, pathp->offset);
-                       tags[tag] = 0;
-                       nr_cleared_tags++;
-               } else
-                       tags[tag] = 1;
+                       if (!any_tag_set(pathp->node, tag)) {
+                               tags[tag] = 0;
+                               nr_cleared_tags++;
+                       }
+               }
        }
 
        for (pathp--; nr_cleared_tags && pathp->node; pathp--) {