/* Attaches a new iclog I/O completion callback routine during transaction commit. If the log is in error state, a non-zero return code is handed back and the caller is responsible for executing the callback at an appropriate time.  */
int xfs_log_notify(xfs_mount_t *mp, void *iclog_hndl, xfs_log_callback_t *cb)
/* Attaches a new iclog I/O completion callback routine during transaction commit. If the log is in error state, a non-zero return code is handed back and the caller is responsible for executing the callback at an appropriate time.  */
int xfs_log_notify(xfs_mount_t *mp, void *iclog_hndl, xfs_log_callback_t *cb)
{
	xlog_in_core_t	  *iclog = (xlog_in_core_t *)iclog_hndl;
	int	abortflg;
	spin_lock(&iclog->ic_callback_lock);
	abortflg = (iclog->ic_state & XLOG_STATE_IOERROR);
	if (!abortflg) {
		ASSERT_ALWAYS((iclog->ic_state == XLOG_STATE_ACTIVE) ||
			      (iclog->ic_state == XLOG_STATE_WANT_SYNC));
		cb->cb_next = NULL;
		*(iclog->ic_callback_tail) = cb;
		iclog->ic_callback_tail = &(cb->cb_next);
	}
	spin_unlock(&iclog->ic_callback_lock);
	return abortflg;
}