DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks); 
int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results){	int rc, agno;	struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;	struct bmap *bmp;	struct metapage *mp;	s64 lblkno, blkno;	struct dmap *dp;	int l2nb;	s64 mapSize;	int writers;	/* assert that nblocks is valid */	assert(nblocks > 0);#ifdef _STILL_TO_PORT	/* DASD limit check                                     F226941 */	if (OVER_LIMIT(ip, nblocks))		return -ENOSPC;#endif				/* _STILL_TO_PORT */	/* get the log2 number of blocks to be allocated.	 * if the number of blocks is not a log2 multiple, 	 * it will be rounded up to the next log2 multiple.	 */	l2nb = BLKSTOL2(nblocks);	bmp = JFS_SBI(ip->i_sb)->bmap;//retry:        /* serialize w.r.t.extendfs() */	mapSize = bmp->db_mapsize;	/* the hint should be within the map */	if (hint >= mapSize) {		jfs_error(ip->i_sb, "dbAlloc: the hint is outside the map");		return -EIO;	}	/* if the number of blocks to be allocated is greater than the	 * allocation group size, try to allocate anywhere.	 */	if (l2nb > bmp->db_agl2size) {		IWRITE_LOCK(ipbmap);		rc = dbAllocAny(bmp, nblocks, l2nb, results);		if (rc == 0) {			DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results,				nblocks);		}		goto write_unlock;	}	/*	 * If no hint, let dbNextAG recommend an allocation group	 */	if (hint == 0)		goto pref_ag;	/* we would like to allocate close to the hint.  adjust the	 * hint to the block following the hint since the allocators	 * will start looking for free space starting at this point.	 */	blkno = hint + 1;	if (blkno >= bmp->db_mapsize)		goto pref_ag;	agno = blkno >> bmp->db_agl2size;	/* check if blkno crosses over into a new allocation group.	 * if so, check if we should allow allocations within this	 * allocation group.	 */	if ((blkno & (bmp->db_agsize - 1)) == 0)		/* check if the AG is currenly being written to.		 * if so, call dbNextAG() to find a non-busy		 * AG with sufficient free space.		 */		if (atomic_read(&bmp->db_active[agno]))			goto pref_ag;	/* check if the allocation request size can be satisfied from a	 * single dmap.  if so, try to allocate from the dmap containing	 * the hint using a tiered strategy.	 */	if (nblocks <= BPERDMAP) {		IREAD_LOCK(ipbmap);		/* get the buffer for the dmap containing the hint.		 */		rc = -EIO;		lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);		mp = read_metapage(ipbmap, lblkno, PSIZE, 0);		if (mp == NULL)			goto read_unlock;		dp = (struct dmap *) mp->data;		/* first, try to satisfy the allocation request with the		 * blocks beginning at the hint.		 */		if ((rc = dbAllocNext(bmp, dp, blkno, (int) nblocks))		    != -ENOSPC) {			if (rc == 0) {				*results = blkno;				DBALLOC(bmp->db_DBmap, bmp->db_mapsize,					*results, nblocks);				mark_metapage_dirty(mp);			}			release_metapage(mp);			goto read_unlock;		}		writers = atomic_read(&bmp->db_active[agno]);		if ((writers > 1) ||		    ((writers == 1) && (JFS_IP(ip)->active_ag != agno))) {			/*			 * Someone else is writing in this allocation			 * group.  To avoid fragmenting, try another ag			 */			release_metapage(mp);			IREAD_UNLOCK(ipbmap);			goto pref_ag;		}		/* next, try to satisfy the allocation request with blocks		 * near the hint.		 */		if ((rc =		     dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results))		    != -ENOSPC) {			if (rc == 0) {				DBALLOC(bmp->db_DBmap, bmp->db_mapsize,					*results, nblocks);				mark_metapage_dirty(mp);			}			release_metapage(mp);			goto read_unlock;		}		/* try to satisfy the allocation request with blocks within		 * the same dmap as the hint.		 */		if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results))		    != -ENOSPC) {			if (rc == 0) {				DBALLOC(bmp->db_DBmap, bmp->db_mapsize,					*results, nblocks);				mark_metapage_dirty(mp);			}			release_metapage(mp);			goto read_unlock;		}		release_metapage(mp);		IREAD_UNLOCK(ipbmap);	}	/* try to satisfy the allocation request with blocks within	 * the same allocation group as the hint.	 */	IWRITE_LOCK(ipbmap);	if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results))	    != -ENOSPC) {		if (rc == 0)			DBALLOC(bmp->db_DBmap, bmp->db_mapsize,				*results, nblocks);		goto write_unlock;	}	IWRITE_UNLOCK(ipbmap);      pref_ag:	/*	 * Let dbNextAG recommend a preferred allocation group	 */	agno = dbNextAG(ipbmap);	IWRITE_LOCK(ipbmap);	/* Try to allocate within this allocation group.  if that fails, try to	 * allocate anywhere in the map.	 */	if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC)		rc = dbAllocAny(bmp, nblocks, l2nb, results);	if (rc == 0) {		DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks);	}      write_unlock:	IWRITE_UNLOCK(ipbmap);	return (rc);      read_unlock:	IREAD_UNLOCK(ipbmap);	return (rc);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b38a3ab3d1bb0dc3288f73903d4dc4672b5cd2d0/jfs_dmap.c/buggy/fs/jfs/jfs_dmap.c