 if (next) xlen = min(xlen, (int)(next - xoff)); 
int xtAppend(tid_t tid,		/* transaction id */	     struct inode *ip, int xflag, s64 xoff, s32 maxblocks,		     s32 * xlenp,	/* (in/out) */	     s64 * xaddrp,	/* (in/out) */	     int flag){	int rc = 0;	struct metapage *mp;	/* meta-page buffer */	xtpage_t *p;		/* base B+-tree index page */	s64 bn, xaddr;	int index, nextindex;	struct btstack btstack;	/* traverse stack */	struct xtsplit split;	/* split information */	xad_t *xad;	int cmp;	struct tlock *tlck;	struct xtlock *xtlck;	int nsplit, nblocks, xlen;	struct pxdlist pxdlist;	pxd_t *pxd;	xaddr = *xaddrp;	xlen = *xlenp;	jfs_info("xtAppend: xoff:0x%lx maxblocks:%d xlen:%d xaddr:0x%lx",		 (ulong) xoff, maxblocks, xlen, (ulong) xaddr);	/*	 *      search for the entry location at which to insert:	 *	 * xtFastSearch() and xtSearch() both returns (leaf page	 * pinned, index at which to insert).	 * n.b. xtSearch() may return index of maxentry of	 * the full page.	 */	if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT)))		return rc;	/* retrieve search result */	XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);	if (cmp == 0) {		rc = -EEXIST;		goto out;	}//insert:	/*	 *      insert entry for new extent	 */	xflag |= XAD_NEW;	/*	 *      if the leaf page is full, split the page and	 *      propagate up the router entry for the new page from split	 *	 * The xtSplitUp() will insert the entry and unpin the leaf page.	 */	nextindex = le16_to_cpu(p->header.nextindex);	if (nextindex < le16_to_cpu(p->header.maxentry))		goto insertLeaf;	/*	 * allocate new index blocks to cover index page split(s)	 */	nsplit = btstack.nsplit;	split.pxdlist = &pxdlist;	pxdlist.maxnpxd = pxdlist.npxd = 0;	pxd = &pxdlist.pxd[0];	nblocks = JFS_SBI(ip->i_sb)->nbperpage;	for (; nsplit > 0; nsplit--, pxd++, xaddr += nblocks, maxblocks -= nblocks) {			if ((rc = dbAllocBottomUp(ip, xaddr, (s64) nblocks)) == 0) {			PXDaddress(pxd, xaddr);			PXDlength(pxd, nblocks);			pxdlist.maxnpxd++;			continue;		}		/* undo allocation */		goto out;	}	xlen = min(xlen, maxblocks);		/*	 * allocate data extent requested	 */	if ((rc = dbAllocBottomUp(ip, xaddr, (s64) xlen)))		goto out;	split.mp = mp;	split.index = index;	split.flag = xflag;	split.off = xoff;	split.len = xlen;	split.addr = xaddr;	if ((rc = xtSplitUp(tid, ip, &split, &btstack))) {		/* undo data extent allocation */		dbFree(ip, *xaddrp, (s64) * xlenp);		return rc;	}	*xaddrp = xaddr;	*xlenp = xlen;	return 0;	/*	 *      insert the new entry into the leaf page	 */      insertLeaf:	/*	 * allocate data extent requested	 */	if ((rc = dbAllocBottomUp(ip, xaddr, (s64) xlen)))		goto out;	BT_MARK_DIRTY(mp, ip);	/*	 * acquire a transaction lock on the leaf page;	 *	 * action: xad insertion/extension;	 */	tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);	xtlck = (struct xtlock *) & tlck->lock;	/* insert the new entry: mark the entry NEW */	xad = &p->xad[index];	XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);	/* advance next available entry index */	p->header.nextindex =	    cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);	xtlck->lwm.offset =	    (xtlck->lwm.offset) ? min(index,(int) xtlck->lwm.offset) : index;	xtlck->lwm.length = le16_to_cpu(p->header.nextindex) -	    xtlck->lwm.offset;	*xaddrp = xaddr;	*xlenp = xlen;      out:	/* unpin the leaf page */	XT_PUTPAGE(mp);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/6628465e33ca694bd8fd5c3cf4eb7ff9177bc694/jfs_xtree.c/clean/fs/jfs/jfs_xtree.c