static u32 current_log_avail(struct ntfs_log *log)
{
	u32 oldest_off, next_free_off, free_bytes;

	if (log->l_flags & NTFSLOG_NO_LAST_LSN) {
		/* The entire file is available. */
		return log->max_current_avail;
	}

	/*
	 * If there is a last lsn the restart area then we know that we will
	 * have to compute the free range.
	 * If there is no oldest lsn then start at the first page of the file.
	 */
	oldest_off = (log->l_flags & NTFSLOG_NO_OLDEST_LSN)
			     ? log->first_page
			     : (log->oldest_lsn_off & ~log->sys_page_mask);

	/*
	 * We will use the next log page offset to compute the next free page.
	 * If we are going to reuse this page go to the next page.
	 * If we are at the first page then use the end of the file.
	 */
	next_free_off = (log->l_flags & NTFSLOG_REUSE_TAIL)
				? log->next_page + log->page_size
				: log->next_page == log->first_page
					  ? log->l_size
					  : log->next_page;

	/* If the two offsets are the same then there is no available space. */
	if (oldest_off == next_free_off)
		return 0;
	/*
	 * If the free offset follows the oldest offset then subtract
	 * this range from the total available pages.
	 */
	free_bytes =
		oldest_off < next_free_off
			? log->total_avail_pages - (next_free_off - oldest_off)
			: oldest_off - next_free_off;

	free_bytes >>= log->page_bits;
	return free_bytes * log->reserved;
}
static u32 current_log_avail(struct ntfs_log *log)
{
	u32 oldest_off, next_free_off, free_bytes;

	if (log->l_flags & NTFSLOG_NO_LAST_LSN) {
		 
		return log->max_current_avail;
	}

	 
	oldest_off = (log->l_flags & NTFSLOG_NO_OLDEST_LSN)
			     ? log->first_page
			     : (log->oldest_lsn_off & ~log->sys_page_mask);

	 
	next_free_off = (log->l_flags & NTFSLOG_REUSE_TAIL)
				? log->next_page + log->page_size
				: log->next_page == log->first_page
					  ? log->l_size
					  : log->next_page;

	 
	if (oldest_off == next_free_off)
		return 0;
	 
	free_bytes =
		oldest_off < next_free_off
			? log->total_avail_pages - (next_free_off - oldest_off)
			: oldest_off - next_free_off;

	free_bytes >>= log->page_bits;
	return free_bytes * log->reserved;
}