/* Freeing the efi item requires that we remove it from the AIL. We'll use the AIL lock to protect our counters as well as the removal from the AIL.  */
void xfs_efi_release(xfs_efi_log_item_t *efip, uint nextents)
/* Freeing the efi item requires that we remove it from the AIL. We'll use the AIL lock to protect our counters as well as the removal from the AIL.  */
void xfs_efi_release(xfs_efi_log_item_t *efip, uint nextents)
{
	struct xfs_ail		*ailp = efip->efi_item.li_ailp;
	int			extents_left;
	ASSERT(efip->efi_next_extent > 0);
	ASSERT(efip->efi_flags & XFS_EFI_COMMITTED);
	spin_lock(&ailp->xa_lock);
	ASSERT(efip->efi_next_extent >= nextents);
	efip->efi_next_extent -= nextents;
	extents_left = efip->efi_next_extent;
	if (extents_left == 0) {
		xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip);
		xfs_efi_item_free(efip);
	} else {
		spin_unlock(&ailp->xa_lock);
	}
}