/* this is called from uncommit in the forced-shutdown path. we need to check to see if the reference count on the log item is going to drop to zero. If so, unpin will free the log item so we need to free the item's descriptor (that points to the item) in the transaction.  */
STATIC void xfs_buf_item_unpin_remove(xfs_buf_log_item_t *bip, xfs_trans_t *tp)
/* this is called from uncommit in the forced-shutdown path. we need to check to see if the reference count on the log item is going to drop to zero. If so, unpin will free the log item so we need to free the item's descriptor (that points to the item) in the transaction.  */
STATIC void xfs_buf_item_unpin_remove(xfs_buf_log_item_t *bip, xfs_trans_t *tp)
{
	xfs_buf_t		*bp;
	xfs_log_item_desc_t	*lidp;
	int			stale = 0;
	bp = bip->bli_buf;
	if ((atomic_read(&bip->bli_refcount) == 1) &&
	    (bip->bli_flags & XFS_BLI_STALE)) {
		ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0);
		trace_xfs_buf_item_unpin_stale(bip);
		lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) bip);
		stale = lidp->lid_flags & XFS_LID_BUF_STALE;
		xfs_trans_free_item(tp, lidp);
		XFS_BUF_SET_FSPRIVATE2(bp, NULL);
	}
	xfs_buf_item_unpin(bip, stale);
	return;
}