/* like unpin only we have to also clear the xaction descriptor pointing the log item if we free the item. This routine duplicates unpin because efi_flags is protected by the AIL lock. Freeing the descriptor and then calling unpin would force us to drop the AIL lock which would open up a race condition.  */
STATIC void xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
/* like unpin only we have to also clear the xaction descriptor pointing the log item if we free the item. This routine duplicates unpin because efi_flags is protected by the AIL lock. Freeing the descriptor and then calling unpin would force us to drop the AIL lock which would open up a race condition.  */
STATIC void xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
{
	struct xfs_ail		*ailp = efip->efi_item.li_ailp;
	xfs_log_item_desc_t	*lidp;
	spin_lock(&ailp->xa_lock);
	if (efip->efi_flags & XFS_EFI_CANCELED) {
		lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) efip);
		xfs_trans_free_item(tp, lidp);
		xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip);
		xfs_efi_item_free(efip);
	} else {
		efip->efi_flags |= XFS_EFI_COMMITTED;
		spin_unlock(&ailp->xa_lock);
	}
}