There is a 'finish_wait', but no 'prepare_to_wait' . So I think that
the 'prepare_to_wait' is missing. The second change is  according to
the name of variable.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
                        if (state->state & EXTENT_LOCKED) {
                                DEFINE_WAIT(wait);
                                atomic_inc(&state->refs);
+                               prepare_to_wait(&state->wq, &wait,
+                                               TASK_UNINTERRUPTIBLE);
                                write_unlock_irq(&tree->lock);
                                schedule();
                                write_lock_irq(&tree->lock);
                node = rb_next(node);
                if (!node)
                        break;
-               total_bytes = state->end - state->start + 1;
+               total_bytes += state->end - state->start + 1;
                if (total_bytes >= max_bytes)
                        break;
        }