XLOG_TIC_RESET_RES(tic); 
xlog_regrant_write_log_space(xlog_t	   *log,			     xlog_ticket_t *tic){	SPLDECL(s);	int		free_bytes, need_bytes;	xlog_ticket_t	*ntic;#ifdef DEBUG	xfs_lsn_t	tail_lsn;#endif	tic->t_curr_res = tic->t_unit_res;	if (tic->t_cnt > 0)		return (0);#ifdef DEBUG	if (log->l_flags & XLOG_ACTIVE_RECOVERY)		panic("regrant Recovery problem");#endif	s = GRANT_LOCK(log);	xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: enter");	if (XLOG_FORCED_SHUTDOWN(log))		goto error_return;	/* If there are other waiters on the queue then give them a	 * chance at logspace before us. Wake up the first waiters,	 * if we do not wake up all the waiters then go to sleep waiting	 * for more free space, otherwise try to get some space for	 * this transaction.	 */	if ((ntic = log->l_write_headq)) {		free_bytes = xlog_space_left(log, log->l_grant_write_cycle,					     log->l_grant_write_bytes);		do {			ASSERT(ntic->t_flags & XLOG_TIC_PERM_RESERV);			if (free_bytes < ntic->t_unit_res)				break;			free_bytes -= ntic->t_unit_res;			sv_signal(&ntic->t_sema);			ntic = ntic->t_next;		} while (ntic != log->l_write_headq);		if (ntic != log->l_write_headq) {			if ((tic->t_flags & XLOG_TIC_IN_Q) == 0)				XLOG_INS_TICKETQ(log->l_write_headq, tic);			xlog_trace_loggrant(log, tic,				    "xlog_regrant_write_log_space: sleep 1");			XFS_STATS_INC(xs_sleep_logspace);			sv_wait(&tic->t_sema, PINOD|PLTWAIT,				&log->l_grant_lock, s);			/* If we're shutting down, this tic is already			 * off the queue */			if (XLOG_FORCED_SHUTDOWN(log)) {				s = GRANT_LOCK(log);				goto error_return;			}			xlog_trace_loggrant(log, tic,				    "xlog_regrant_write_log_space: wake 1");			xlog_grant_push_ail(log->l_mp, tic->t_unit_res);			s = GRANT_LOCK(log);		}	}	need_bytes = tic->t_unit_res;redo:	if (XLOG_FORCED_SHUTDOWN(log))		goto error_return;	free_bytes = xlog_space_left(log, log->l_grant_write_cycle,				     log->l_grant_write_bytes);	if (free_bytes < need_bytes) {		if ((tic->t_flags & XLOG_TIC_IN_Q) == 0)			XLOG_INS_TICKETQ(log->l_write_headq, tic);		XFS_STATS_INC(xs_sleep_logspace);		sv_wait(&tic->t_sema, PINOD|PLTWAIT, &log->l_grant_lock, s);		/* If we're shutting down, this tic is already off the queue */		if (XLOG_FORCED_SHUTDOWN(log)) {			s = GRANT_LOCK(log);			goto error_return;		}		xlog_trace_loggrant(log, tic,				    "xlog_regrant_write_log_space: wake 2");		xlog_grant_push_ail(log->l_mp, need_bytes);		s = GRANT_LOCK(log);		goto redo;	} else if (tic->t_flags & XLOG_TIC_IN_Q)		XLOG_DEL_TICKETQ(log->l_write_headq, tic);	XLOG_GRANT_ADD_SPACE(log, need_bytes, 'w'); /* we've got enough space */#ifdef DEBUG	tail_lsn = log->l_tail_lsn;	if (CYCLE_LSN(tail_lsn) != log->l_grant_write_cycle) {		ASSERT(log->l_grant_write_cycle-1 == CYCLE_LSN(tail_lsn));		ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn)));	}#endif	xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit");	xlog_verify_grant_head(log, 1);	GRANT_UNLOCK(log, s);	return (0); error_return:	if (tic->t_flags & XLOG_TIC_IN_Q)		XLOG_DEL_TICKETQ(log->l_reserve_headq, tic);	xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: err_ret");	/*	 * If we are failing, make sure the ticket doesn't have any	 * current reservations. We don't want to add this back when	 * the ticket/transaction gets cancelled.	 */	tic->t_curr_res = 0;	tic->t_cnt = 0; /* ungrant will give back unit_res * t_cnt. */	GRANT_UNLOCK(log, s);	return XFS_ERROR(EIO);}	/* xlog_regrant_write_log_space */
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7e9c63961558092d584936a874cf3fee80002eb6/xfs_log.c/buggy/fs/xfs/xfs_log.c