XLOG_TIC_ADD_REGION(ticket, log->l_iclog_hsize, XLOG_REG_TYPE_LRHEADER); 
xlog_state_get_iclog_space(xlog_t	  *log,			   int		  len,			   xlog_in_core_t **iclogp,			   xlog_ticket_t  *ticket,			   int		  *continued_write,			   int		  *logoffsetp){	SPLDECL(s);	int		  log_offset;	xlog_rec_header_t *head;	xlog_in_core_t	  *iclog;	int		  error;restart:	s = LOG_LOCK(log);	if (XLOG_FORCED_SHUTDOWN(log)) {		LOG_UNLOCK(log, s);		return XFS_ERROR(EIO);	}	iclog = log->l_iclog;	if (! (iclog->ic_state == XLOG_STATE_ACTIVE)) {		log->l_flushcnt++;		LOG_UNLOCK(log, s);		xlog_trace_iclog(iclog, XLOG_TRACE_SLEEP_FLUSH);		XFS_STATS_INC(xs_log_noiclogs);		/* Ensure that log writes happen */		psema(&log->l_flushsema, PINOD);		goto restart;	}	ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE);	head = &iclog->ic_header;	iclog->ic_refcnt++;			/* prevents sync */	log_offset = iclog->ic_offset;	/* On the 1st write to an iclog, figure out lsn.  This works	 * if iclogs marked XLOG_STATE_WANT_SYNC always write out what they are	 * committing to.  If the offset is set, that's how many blocks	 * must be written.	 */	if (log_offset == 0) {		ticket->t_curr_res -= log->l_iclog_hsize;		INT_SET(head->h_cycle, ARCH_CONVERT, log->l_curr_cycle);		ASSIGN_LSN(head->h_lsn, log);		ASSERT(log->l_curr_block >= 0);	}	/* If there is enough room to write everything, then do it.  Otherwise,	 * claim the rest of the region and make sure the XLOG_STATE_WANT_SYNC	 * bit is on, so this will get flushed out.  Don't update ic_offset	 * until you know exactly how many bytes get copied.  Therefore, wait	 * until later to update ic_offset.	 *	 * xlog_write() algorithm assumes that at least 2 xlog_op_header_t's	 * can fit into remaining data section.	 */	if (iclog->ic_size - iclog->ic_offset < 2*sizeof(xlog_op_header_t)) {		xlog_state_switch_iclogs(log, iclog, iclog->ic_size);		/* If I'm the only one writing to this iclog, sync it to disk */		if (iclog->ic_refcnt == 1) {			LOG_UNLOCK(log, s);			if ((error = xlog_state_release_iclog(log, iclog)))				return (error);		} else {			iclog->ic_refcnt--;			LOG_UNLOCK(log, s);		}		goto restart;	}	/* Do we have enough room to write the full amount in the remainder	 * of this iclog?  Or must we continue a write on the next iclog and	 * mark this iclog as completely taken?  In the case where we switch	 * iclogs (to mark it taken), this particular iclog will release/sync	 * to disk in xlog_write().	 */	if (len <= iclog->ic_size - iclog->ic_offset) {		*continued_write = 0;		iclog->ic_offset += len;	} else {		*continued_write = 1;		xlog_state_switch_iclogs(log, iclog, iclog->ic_size);	}	*iclogp = iclog;	ASSERT(iclog->ic_offset <= iclog->ic_size);	LOG_UNLOCK(log, s);	*logoffsetp = log_offset;	return 0;}	/* xlog_state_get_iclog_space */
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7e9c63961558092d584936a874cf3fee80002eb6/xfs_log.c/buggy/fs/xfs/xfs_log.c