if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage) || dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) goto clean_up;	/* No space */ 
if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage)) goto clean_up; if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { DQUOT_FREE_BLOCK(ip, sbi->nbperpage); goto clean_up; } 
static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot){	struct super_block *sb = ip->i_sb;	struct jfs_sb_info *sbi = JFS_SBI(sb);	struct jfs_inode_info *jfs_ip = JFS_IP(ip);	u64 blkno;	struct dir_table_slot *dirtab_slot;	u32 index;	struct linelock *llck;	struct lv *lv;	struct metapage *mp;	s64 offset;	uint page_offset;	struct tlock *tlck;	s64 xaddr;	ASSERT(DO_INDEX(ip));	if (jfs_ip->next_index < 2) {		jfs_warn("add_index: next_index = %d.  Resetting!",			   jfs_ip->next_index);		jfs_ip->next_index = 2;	}	index = jfs_ip->next_index++;	if (index <= MAX_INLINE_DIRTABLE_ENTRY) {		/*		 * i_size reflects size of index table, or 8 bytes per entry.		 */		ip->i_size = (loff_t) (index - 1) << 3;		/*		 * dir table fits inline within inode		 */		dirtab_slot = &jfs_ip->i_dirtable[index-2];		dirtab_slot->flag = DIR_INDEX_VALID;		dirtab_slot->slot = slot;		DTSaddress(dirtab_slot, bn);		set_cflag(COMMIT_Dirtable, ip);		return index;	}	if (index == (MAX_INLINE_DIRTABLE_ENTRY + 1)) {		struct dir_table_slot temp_table[12];		/*		 * It's time to move the inline table to an external		 * page and begin to build the xtree		 */		if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage) ||		    dbAlloc(ip, 0, sbi->nbperpage, &xaddr))			goto clean_up;	/* No space */		/*		 * Save the table, we're going to overwrite it with the		 * xtree root		 */		memcpy(temp_table, &jfs_ip->i_dirtable, sizeof(temp_table));		/*		 * Initialize empty x-tree		 */		xtInitRoot(tid, ip);		/*		 * Allocate the first block & add it to the xtree		 */		if (xtInsert(tid, ip, 0, 0, sbi->nbperpage, &xaddr, 0)) {			/* This really shouldn't fail */			jfs_warn("add_index: xtInsert failed!");			memcpy(&jfs_ip->i_dirtable, temp_table,			       sizeof (temp_table));			goto clean_up;		}		ip->i_size = PSIZE;		if ((mp = get_index_page(ip, 0)) == 0) {			jfs_err("add_index: get_metapage failed!");			xtTruncate(tid, ip, 0, COMMIT_PWMAP);			memcpy(&jfs_ip->i_dirtable, temp_table,			       sizeof (temp_table));			goto clean_up;		}		tlck = txLock(tid, ip, mp, tlckDATA);		llck = (struct linelock *) & tlck->lock;		ASSERT(llck->index == 0);		lv = &llck->lv[0];		lv->offset = 0;		lv->length = 6;	/* tlckDATA slot size is 16 bytes */		llck->index++;		memcpy(mp->data, temp_table, sizeof(temp_table));		mark_metapage_dirty(mp);		release_metapage(mp);		/*		 * Logging is now directed by xtree tlocks		 */		clear_cflag(COMMIT_Dirtable, ip);	}	offset = (index - 2) * sizeof(struct dir_table_slot);	page_offset = offset & (PSIZE - 1);	blkno = ((offset + 1) >> L2PSIZE) << sbi->l2nbperpage;	if (page_offset == 0) {		/*		 * This will be the beginning of a new page		 */		xaddr = 0;		if (xtInsert(tid, ip, 0, blkno, sbi->nbperpage, &xaddr, 0)) {			jfs_warn("add_index: xtInsert failed!");			goto clean_up;		}		ip->i_size += PSIZE;		if ((mp = get_index_page(ip, blkno)))			memset(mp->data, 0, PSIZE);	/* Just looks better */		else			xtTruncate(tid, ip, offset, COMMIT_PWMAP);	} else		mp = read_index_page(ip, blkno);	if (mp == 0) {		jfs_err("add_index: get/read_metapage failed!");		goto clean_up;	}	lock_index(tid, ip, mp, index);	dirtab_slot =	    (struct dir_table_slot *) ((char *) mp->data + page_offset);	dirtab_slot->flag = DIR_INDEX_VALID;	dirtab_slot->slot = slot;	DTSaddress(dirtab_slot, bn);	mark_metapage_dirty(mp);	release_metapage(mp);	return index;      clean_up:	jfs_ip->next_index--;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/18190cc08d70a6ec8ef69f0f6ede021f7cb3f9b8/jfs_dtree.c/buggy/fs/jfs/jfs_dtree.c