/* Since ext3_try_to_allocate() will always allocate blocks within the reservation window range, if the window size is too small, multiple blocks allocation has to stop at the end of the reservation window. To make this more efficient, given the total number of blocks needed and the current size of the window, we try to expand the reservation window size if necessary on a best-effort basis before ext3_new_blocks() tries to allocate blocks,  */
static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv, struct super_block *sb, int size)
/* Since ext3_try_to_allocate() will always allocate blocks within the reservation window range, if the window size is too small, multiple blocks allocation has to stop at the end of the reservation window. To make this more efficient, given the total number of blocks needed and the current size of the window, we try to expand the reservation window size if necessary on a best-effort basis before ext3_new_blocks() tries to allocate blocks,  */
static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv, struct super_block *sb, int size)
{
	struct ext3_reserve_window_node *next_rsv;
	struct rb_node *next;
	spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock;
	if (!spin_trylock(rsv_lock))
		return;
	next = rb_next(&my_rsv->rsv_node);
	if (!next)
		my_rsv->rsv_end += size;
	else {
		next_rsv = rb_entry(next, struct ext3_reserve_window_node, rsv_node);
		if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
			my_rsv->rsv_end += size;
		else
			my_rsv->rsv_end = next_rsv->rsv_start - 1;
	}
	spin_unlock(rsv_lock);
}