/* Find the reserved window which includes the goal, or the previous one if the goal is not in any window. Returns NULL if there are no windows or if all windows start after the goal.  */
static struct ext2_reserve_window_node* search_reserve_window(struct rb_root *root, ext2_fsblk_t goal)
/* Find the reserved window which includes the goal, or the previous one if the goal is not in any window. Returns NULL if there are no windows or if all windows start after the goal.  */
static struct ext2_reserve_window_node* search_reserve_window(struct rb_root *root, ext2_fsblk_t goal)
{
	struct rb_node *n = root->rb_node;
	struct ext2_reserve_window_node *rsv;
	if (!n)
		return NULL;
	do {
		rsv = rb_entry(n, struct ext2_reserve_window_node, rsv_node);
		if (goal < rsv->rsv_start)
			n = n->rb_left;
		else if (goal > rsv->rsv_end)
			n = n->rb_right;
		else
			return rsv;
	} while (n);
	if (rsv->rsv_start > goal) {
		n = rb_prev(&rsv->rsv_node);
		rsv = rb_entry(n, struct ext2_reserve_window_node, rsv_node);
	}
	return rsv;
}