if ((error = xfs_qm_dqalloc(tp, mp, dqp, quotip, 
if ((error = xfs_qm_dqalloc(tpp, mp, dqp, quotip, 
xfs_qm_dqtobp(	xfs_trans_t		*tp,	xfs_dquot_t		*dqp,	xfs_disk_dquot_t	**O_ddpp,	xfs_buf_t		**O_bpp,	uint			flags){	xfs_bmbt_irec_t map;	int		nmaps, error;	xfs_buf_t	*bp;	xfs_inode_t	*quotip;	xfs_mount_t	*mp;	xfs_disk_dquot_t *ddq;	xfs_dqid_t	id;	boolean_t	newdquot;	mp = dqp->q_mount;	id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT);	nmaps = 1;	newdquot = B_FALSE;	/*	 * If we don't know where the dquot lives, find out.	 */	if (dqp->q_blkno == (xfs_daddr_t) 0) {		/* We use the id as an index */		dqp->q_fileoffset = (xfs_fileoff_t) ((uint)id /						     XFS_QM_DQPERBLK(mp));		nmaps = 1;		quotip = XFS_DQ_TO_QIP(dqp);		xfs_ilock(quotip, XFS_ILOCK_SHARED);		/*		 * Return if this type of quotas is turned off while we didn't		 * have an inode lock		 */		if (XFS_IS_THIS_QUOTA_OFF(dqp)) {			xfs_iunlock(quotip, XFS_ILOCK_SHARED);			return (ESRCH);		}		/*		 * Find the block map; no allocations yet		 */		error = xfs_bmapi(NULL, quotip, dqp->q_fileoffset,				  XFS_DQUOT_CLUSTER_SIZE_FSB,				  XFS_BMAPI_METADATA,				  NULL, 0, &map, &nmaps, NULL);		xfs_iunlock(quotip, XFS_ILOCK_SHARED);		if (error)			return (error);		ASSERT(nmaps == 1);		ASSERT(map.br_blockcount == 1);		/*		 * offset of dquot in the (fixed sized) dquot chunk.		 */		dqp->q_bufoffset = (id % XFS_QM_DQPERBLK(mp)) *			sizeof(xfs_dqblk_t);		if (map.br_startblock == HOLESTARTBLOCK) {			/*			 * We don't allocate unless we're asked to			 */			if (!(flags & XFS_QMOPT_DQALLOC))				return (ENOENT);			ASSERT(tp);			if ((error = xfs_qm_dqalloc(tp, mp, dqp, quotip,						dqp->q_fileoffset, &bp)))				return (error);			newdquot = B_TRUE;		} else {			/*			 * store the blkno etc so that we don't have to do the			 * mapping all the time			 */			dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);		}	}	ASSERT(dqp->q_blkno != DELAYSTARTBLOCK);	ASSERT(dqp->q_blkno != HOLESTARTBLOCK);	/*	 * Read in the buffer, unless we've just done the allocation	 * (in which case we already have the buf).	 */	if (! newdquot) {		xfs_dqtrace_entry(dqp, "DQTOBP READBUF");		if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,					       dqp->q_blkno,					       XFS_QI_DQCHUNKLEN(mp),					       0, &bp))) {			return (error);		}		if (error || !bp)			return XFS_ERROR(error);	}	ASSERT(XFS_BUF_ISBUSY(bp));	ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);	/*	 * calculate the location of the dquot inside the buffer.	 */	ddq = (xfs_disk_dquot_t *)((char *)XFS_BUF_PTR(bp) + dqp->q_bufoffset);	/*	 * A simple sanity check in case we got a corrupted dquot...	 */	if (xfs_qm_dqcheck(ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES,			   flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN),			   "dqtobp")) {		if (!(flags & XFS_QMOPT_DQREPAIR)) {			xfs_trans_brelse(tp, bp);			return XFS_ERROR(EIO);		}		XFS_BUF_BUSY(bp); /* We dirtied this */	}	*O_bpp = bp;	*O_ddpp = ddq;	return (0);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/efa092f3d4c60be7e81de515db9f06e5f8426afc/xfs_dquot.c/clean/fs/xfs/quota/xfs_dquot.c