/* Insert the given log item into the AIL. We almost always insert at the end of the list, so on inserts we search from the end of the list to find where the new item belongs.  */
STATIC void xfs_ail_insert(struct xfs_ail *, xfs_log_item_t *)
/* Insert the given log item into the AIL. We almost always insert at the end of the list, so on inserts we search from the end of the list to find where the new item belongs.  */
STATIC void xfs_ail_insert(struct xfs_ail *, xfs_log_item_t *)
{
	xfs_log_item_t	*next_lip;
	if (list_empty(&ailp->xa_ail)) {
		list_add(&lip->li_ail, &ailp->xa_ail);
		return;
	}
	list_for_each_entry_reverse(next_lip, &ailp->xa_ail, li_ail) {
		if (XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) <= 0)
			break;
	}
	ASSERT((&next_lip->li_ail == &ailp->xa_ail) ||
	       (XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) <= 0));
	list_add(&lip->li_ail, &next_lip->li_ail);
	xfs_ail_check(ailp, lip);
	return;
}