XFS_WRITE_LOG_RES(mp), numrtextents, 
XFS_WRITE_LOG_RES(mp), resrtextents, 
xfs_iomap_write_direct(	xfs_inode_t	*ip,	xfs_off_t	offset,	size_t		count,	int		flags,	xfs_bmbt_irec_t *ret_imap,	int		*nmaps,	int		found){	xfs_mount_t	*mp = ip->i_mount;	xfs_iocore_t	*io = &ip->i_iocore;	xfs_fileoff_t	offset_fsb;	xfs_fileoff_t	last_fsb;	xfs_filblks_t	count_fsb;	xfs_fsize_t	isize;	xfs_fsblock_t	firstfsb;	int		nimaps, maps;	int		error;	int		bmapi_flag;	int		quota_flag;	int		rt;	xfs_trans_t	*tp;	xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS], *imapp;	xfs_bmap_free_t free_list;	int		aeof;	xfs_filblks_t	datablocks, qblocks, resblks;	int		committed;	int		numrtextents;	/*	 * Make sure that the dquots are there. This doesn't hold	 * the ilock across a disk read.	 */	error = XFS_QM_DQATTACH(ip->i_mount, ip, XFS_QMOPT_ILOCKED);	if (error)		return XFS_ERROR(error);	maps = min(XFS_WRITE_IMAPS, *nmaps);	nimaps = maps;	isize = ip->i_d.di_size;	aeof = (offset + count) > isize;	if (io->io_new_size > isize)		isize = io->io_new_size;	offset_fsb = XFS_B_TO_FSBT(mp, offset);	last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));	count_fsb = last_fsb - offset_fsb;	if (found && (ret_imap->br_startblock == HOLESTARTBLOCK)) {		xfs_fileoff_t	map_last_fsb;		map_last_fsb = ret_imap->br_blockcount + ret_imap->br_startoff;		if (map_last_fsb < last_fsb) {			last_fsb = map_last_fsb;			count_fsb = last_fsb - offset_fsb;		}		ASSERT(count_fsb > 0);	}	/*	 * Determine if reserving space on the data or realtime partition.	 */	if ((rt = XFS_IS_REALTIME_INODE(ip))) {		xfs_extlen_t	extsz;		if (!(extsz = ip->i_d.di_extsize))			extsz = mp->m_sb.sb_rextsize;		numrtextents = qblocks = (count_fsb + extsz - 1);		do_div(numrtextents, mp->m_sb.sb_rextsize);		quota_flag = XFS_QMOPT_RES_RTBLKS;		datablocks = 0;	} else {		datablocks = qblocks = count_fsb;		quota_flag = XFS_QMOPT_RES_REGBLKS;		numrtextents = 0;	}	/*	 * Allocate and setup the transaction	 */	xfs_iunlock(ip, XFS_ILOCK_EXCL);	tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);	resblks = XFS_DIOSTRAT_SPACE_RES(mp, datablocks);	error = xfs_trans_reserve(tp, resblks,			XFS_WRITE_LOG_RES(mp), numrtextents,			XFS_TRANS_PERM_LOG_RES,			XFS_WRITE_LOG_COUNT);	/*	 * Check for running out of space, note: need lock to return	 */	if (error)		xfs_trans_cancel(tp, 0);	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (error)		goto error_out;	if (XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag)) {		error = (EDQUOT);		goto error1;	}	bmapi_flag = XFS_BMAPI_WRITE;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_ihold(tp, ip);	if (!(flags & BMAPI_MMAP) && (offset < ip->i_d.di_size || rt))		bmapi_flag |= XFS_BMAPI_PREALLOC;	/*	 * Issue the bmapi() call to allocate the blocks	 */	XFS_BMAP_INIT(&free_list, &firstfsb);	nimaps = 1;	imapp = &imap[0];	error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,		bmapi_flag, &firstfsb, 0, imapp, &nimaps, &free_list);	if (error)		goto error0;	/*	 * Complete the transaction	 */	error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed);	if (error)		goto error0;	error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);	if (error)		goto error_out;	/*	 * Copy any maps to caller's array and return any error.	 */	if (nimaps == 0) {		error = (ENOSPC);		goto error_out;	}	*ret_imap = imap[0];	*nmaps = 1;	if ( !(io->io_flags & XFS_IOCORE_RT)  && !ret_imap->br_startblock) {                cmn_err(CE_PANIC,"Access to block zero:  fs <%s> inode: %lld "                        "start_block : %llx start_off : %llx blkcnt : %llx "                        "extent-state : %x \n",                        (ip->i_mount)->m_fsname,                        (long long)ip->i_ino,                        ret_imap->br_startblock, ret_imap->br_startoff,                        ret_imap->br_blockcount,ret_imap->br_state);        }	return 0;error0:	/* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */	xfs_bmap_cancel(&free_list);	XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag);error1:	/* Just cancel transaction */	xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);	*nmaps = 0;	/* nothing set-up here */error_out:	return XFS_ERROR(error);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/d52b44d07a43b723ac2fbf1bf4053031f723676c/xfs_iomap.c/clean/fs/xfs/xfs_iomap.c