On Mon, 10 Sep 2007 23:27:52 +0800
"Yan Zheng" <yanzheng@21cn.com> wrote:
> Hi, Chris
>
> I'm confused by following code fragment in set_extent_bit. the last
> statement 'goto out' in the body of test looks very strange.I think
if
> goto label 'out' there, bits for range [start, state->start]
aren't
> set. Perhaps the order of this test and next one should exchange.
>
> if (state->start <= end && state->end > end) {
> set = state->state & bits;
> if (exclusive && set) {
> *failed_start = start;
> err = -EEXIST;
> goto out;
> }
> err = split_state(tree, state, prealloc, end + 1);
> BUG_ON(err == -EEXIST);
>
> prealloc->state |= bits;
> merge_state(tree, prealloc);
> prealloc = NULL;
> goto out;
^^^^^^^^^^^^
Just to be sure, you mean this goto out?
The comment at the top of this has a little bit of ascii art:
/*
* | ---- desired range ---- |
* | state |
* We need to split the extent, and set the bit
* on the first half
*/
When we split the state, we have two halves. The first half covers
from the start of the range we want to set a bit on and extends to the
end of the range. The second half is entirely outside the range.
We pass prealloc to split_state, and after split_state is called,
prealloc is the part that covers the first half. So, we set the bits
on prealloc and we should be done.
But, this code is definitely complex, so if you see a bug here please
do explain it ;)
-chris