XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK); 
xfs_buf_item_format(	xfs_buf_log_item_t	*bip,	xfs_log_iovec_t		*log_vector){	uint		base_size;	uint		nvecs;	xfs_log_iovec_t	*vecp;	xfs_buf_t	*bp;	int		first_bit;	int		last_bit;	int		next_bit;	uint		nbits;	uint		buffer_offset;	ASSERT(atomic_read(&bip->bli_refcount) > 0);	ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||	       (bip->bli_flags & XFS_BLI_STALE));	bp = bip->bli_buf;	ASSERT(XFS_BUF_BP_ISMAPPED(bp));	vecp = log_vector;	/*	 * The size of the base structure is the size of the	 * declared structure plus the space for the extra words	 * of the bitmap.  We subtract one from the map size, because	 * the first element of the bitmap is accounted for in the	 * size of the base structure.	 */	base_size =		(uint)(sizeof(xfs_buf_log_format_t) +		       ((bip->bli_format.blf_map_size - 1) * sizeof(uint)));	vecp->i_addr = (xfs_caddr_t)&bip->bli_format;	vecp->i_len = base_size;	vecp++;	nvecs = 1;	if (bip->bli_flags & XFS_BLI_STALE) {		/*		 * The buffer is stale, so all we need to log		 * is the buf log format structure with the		 * cancel flag in it.		 */		xfs_buf_item_trace("FORMAT STALE", bip);		ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);		bip->bli_format.blf_size = nvecs;		return;	}	/*	 * Fill in an iovec for each set of contiguous chunks.	 */	first_bit = xfs_next_bit(bip->bli_format.blf_data_map,					 bip->bli_format.blf_map_size, 0);	ASSERT(first_bit != -1);	last_bit = first_bit;	nbits = 1;	for (;;) {		/*		 * This takes the bit number to start looking from and		 * returns the next set bit from there.  It returns -1		 * if there are no more bits set or the start bit is		 * beyond the end of the bitmap.		 */		next_bit = xfs_next_bit(bip->bli_format.blf_data_map,						 bip->bli_format.blf_map_size,						 (uint)last_bit + 1);		/*		 * If we run out of bits fill in the last iovec and get		 * out of the loop.		 * Else if we start a new set of bits then fill in the		 * iovec for the series we were looking at and start		 * counting the bits in the new one.		 * Else we're still in the same set of bits so just		 * keep counting and scanning.		 */		if (next_bit == -1) {			buffer_offset = first_bit * XFS_BLI_CHUNK;			vecp->i_addr = xfs_buf_offset(bp, buffer_offset);			vecp->i_len = nbits * XFS_BLI_CHUNK;			nvecs++;			break;		} else if (next_bit != last_bit + 1) {			buffer_offset = first_bit * XFS_BLI_CHUNK;			vecp->i_addr = xfs_buf_offset(bp, buffer_offset);			vecp->i_len = nbits * XFS_BLI_CHUNK;			nvecs++;			vecp++;			first_bit = next_bit;			last_bit = next_bit;			nbits = 1;		} else if (xfs_buf_offset(bp, next_bit << XFS_BLI_SHIFT) !=			   (xfs_buf_offset(bp, last_bit << XFS_BLI_SHIFT) +			    XFS_BLI_CHUNK)) {			buffer_offset = first_bit * XFS_BLI_CHUNK;			vecp->i_addr = xfs_buf_offset(bp, buffer_offset);			vecp->i_len = nbits * XFS_BLI_CHUNK;/* You would think we need to bump the nvecs here too, but we do not * this number is used by recovery, and it gets confused by the boundary * split here *			nvecs++; */			vecp++;			first_bit = next_bit;			last_bit = next_bit;			nbits = 1;		} else {			last_bit++;			nbits++;		}	}	bip->bli_format.blf_size = nvecs;	/*	 * Check to make sure everything is consistent.	 */	xfs_buf_item_trace("FORMAT NORM", bip);	xfs_buf_item_log_check(bip);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7e9c63961558092d584936a874cf3fee80002eb6/xfs_buf_item.c/buggy/fs/xfs/xfs_buf_item.c