Re: [patch 3/9] radix-tree: gang slot lookups

Peter Zijlstra
2007-06-01T10:31:18Z

On Thu, 2007-04-12 at 14:45 +0200, Nick Piggin wrote:

> @@ -825,13 +889,21 @@ radix_tree_gang_lookup_tag(struct radix_
>
> ret = 0;
> while (ret < max_items) {
> - unsigned int nr_found;
> + unsigned int slots_found, nr_found, i;
> unsigned long next_index; /* Index of next search */
>
> if (cur_index > max_index)
> break;
> - nr_found = __lookup_tag(node, results + ret, cur_index,
> - max_items - ret, &next_index, tag);
> + slots_found = __lookup_tag(node, (void ***)results + ret,
> + cur_index, max_items - ret, &next_index, tag);
> + nr_found = 0;
> + for (i = 0; i < slots_found; i++) {
> + node = *((void ***)results)[ret + i];
> + if (!node)
> + continue;
> + results[ret + nr_found] = rcu_dereference(node);

I think this should read (as you correctly did in
radix_tree_gang_lookup):

struct radix_tree_node *slot;
slot = *((void ***)results)[ret + i];
if (!slot)
continue;
results[ret + nr_found] = rcu_dereference(slot);

by overwriting node, a subsequent __lookup_tag() will do the darnest
things.

> + nr_found++;
> + }
> ret += nr_found;
> if (next_index == 0)
> break;