Re: [PATCH 1/2] btree: Fix tree corruption in btree_get_prev()

From: Andrew Morton
Date: Wed Jun 06 2012 - 21:29:14 EST


On Wed, 6 Jun 2012 17:44:20 -0700 Roland Dreier <roland@xxxxxxxxxx> wrote:

> On Wed, Jun 6, 2012 at 4:36 PM, Roland Dreier <roland@xxxxxxxxxx> wrote:
> > On the other hand, your change makes me think we don't
> > even need a separate iterator (and we can avoid the variable
> > length array declaration)
>
> FWIW with that change on top of my patch, I see
>
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-123 (-123)
> function old new delta
> btree_get_prev 646 523 -123
>
> on x86-64, so avoiding the variable length array is definitely
> worth something.
>
> So the issue for me is whether messing with the caller's
> __key storage is OK, or if it's worth having a temporary
> local variable.
>

Sometimes altering the caller's *__key when lookup fails is pretty rude
behavior :(

Perhaps we could add an arg to btree_get_prev(), provide it with
separate input and output key pointers?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/