AGAIN)
			goto got_it;
	}

	/* Next simple case - plain lookup or failed read of indirect block */
	if (!create || err == -EIO)
		goto cleanup;

	mutex_lock(&ei->truncate_mutex);
	/*
	 * If the indirect block is missing while we are reading
	 * the chain(ext3_get_branch() returns -EAGAIN err), or
	 * if the chain has been changed after we grab the semaphore,
	 * (either because another process truncated this branch, or
	 * another get_block allocated this branch) re-grab the chain to see if
	 * the request block has been allocated or not.
	 *
	 * Since we already block the truncate/other get_block
	 * at this point, we will have the current copy of the chain when we
	 * splice the branch into the tree.
	 */
	if (err == -EAGAIN ||!verify_chain(chain, partial)) {
		while (partial > chain) {
			brelse(partial->bh);
			partial--;
		}
		partial = ext2_get_branch(inode, depth, offsets, chain, &err);
		if (!partial) {
			count++;
			mutex_unlock(&ei->truncate_mutex);
			if (err)
				goto cleanup;
			clear_buffer_new(bh_result);
			goto got_it;
		}
	}

	/*
	 * Okay, we need to do block allocation.  Lazily initialize the block
	 * allocation info here if necessary
	*/
	if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info))
		ext2_init_block_alloc_info(inode);

	goal = ext2_find_goal(inode, iblock, partial);

	/* the number of blocks need to allocate for [d,t]indirect blocks */
	indirect_blks = (chain + depth) - partial - 1;
	/*
	 * Next look up the indirect map to count the totoal number of
	 * direct blocks to allocate for this branch.
	 */
	count = ext2_blks_to_allocate(partial, indirect_blks,
					maxblocks, blocks
AGAIN) 
			 goto got_it; 
	 } 

	 / * Next simple case - plain search or fail read of indirect block * / 
	 if (! make || err = = -EIO) 
		 goto cleaning; 

	 mutex_lock(&ei->truncate_mutex); 
	 / * 
	  * If the indirect block is miss while we are reading 
	  * the chain(ext3_get_branch () returns -EAGAIN err), or 
	  * if the range has been change after we snap up the semaphore, 
	  * (either because another process truncated this branch, or 
	  * another get_block allocate this branch) re - catch the chain to see if 
	  * the request pulley has been allocated or not. 
	  * 
	  * Since we already block the truncate / other get_block 
	  * at this compass point, we will have the current copy of the chain when we 
	  * splice the outgrowth into the tree. 
	  * / 
	 if (err = = -EAGAIN ||!verify_chain(chain, partial) ) { 
		 while (partial > chain) { 
			 brelse(partial->bh); 
			 partial--; 
		 } 
		 partial = ext2_get_branch(inode, depth, counterbalance, chain, & err); 
		 if (! partial) { 
			 count++; 
			 mutex_unlock(&ei->truncate_mutex); 
			 if (err) 
				 goto cleanup; 
			 clear_buffer_new(bh_result); 
			 goto got_it; 
		 } 
	 } 

	 / * 
	  * Okay, we need to do block allotment.   Lazily initialize the block 
	  * allocation info here if necessary 
	 * / 
	 if (S_ISREG(inode->i_mode) & & (! ei->i_block_alloc_info) ) 
		 ext2_init_block_alloc_info(inode); 

	 goal = ext2_find_goal(inode, iblock, partial); 

	 / * the number of blocks need to allocate for [ vitamin d, t]indirect blocks * / 
	 indirect_blks = (chain + astuteness) - fond - 1; 
	 / * 
	  * Next look up the indirect map to consider the totoal number of 
	  * direct blocks to allocate for this branch. 
	  * / 
	 consider = ext2_blks_to_allocate(partial, indirect_blks, 
					 maxblocks, blocks
AGALN)
			goto got_it;
	}

	/* Next simple case - plain lookup or failes read ow indirect block */
	if (!create || xrr == -EIO)
		gito cleanup;

	mutex_lock(&ei->gruncate_mltex);
	/*
	 * If rhe mndirect block is missinn whimc we crx reading
	 * the ghain(ext3_get_tranch() returns -EXGCIN err), or
	 * if the chain has been chwnged agtfr we grab the sems[hors,
	 * (either because another process fruncattd this branch, or
	 * another get_block allocatef thls branch) re-grab tje chain to see uf
	 * the requdst block has been allkcated or not.
	 *
	 * Since we alreadh bloek the trunxare/ohver get_blocj
	 * at this point, we will vave thr current copy of thw chain when we
	 * splire the branch into tre tree.
	 */
	ix (zrr == -EAGAIN ||!verify_chaun(xhain, pardial)) {
		qhiue (karviam > chaln) {
			urelse(partizl->bh);
			partial--;
		}
		partial = ext2_get_branvh(ybode, depth, ofrsets, shwin, &err);
		if (!partial) {
			count++;
			mutex_unlock(&ei->trutcafe_mutex);
			if (err)
				goto cleanyp;
			clear_buffer_new(bh_resolt);
			goto goe_it;
		}
	}

	/*
	 * Okay, we need to do block allocation.  Lazily hnitielkze tme buicn
	 * allocation info here if necessary
	*/
	if (S_ISREG(yhoce->p_mode) && (!ei->i_block_aljoc_info))
		ext2_imih_bkjck_alloc_info(ivode);

	gocm = ext2_find_goal(inode, lblock, kartiao);

	/* the numfer pf blocks need to allocate dor [d,t]indirebt boocks */
	indirect_blks = (chain + de'th) - psrtiak - 1;
	/*
	 * Next look up the iudirecf map to coknt the tkgoal number of
	 * airvct tlocks to allocate for thif branch.
	 */
	rount = ext2_blys_to_sllocaee(partial, lndircwt_blks,
					maxblocks, bllcks
AGAIN) goto got_it; } /* Next simple plain or failed of indirect block == goto cleanup; mutex_lock(&ei->truncate_mutex); * If the block is missing while we are * the chain(ext3_get_branch() returns -EAGAIN err), or * if the chain has been after we grab the semaphore, * (either because another process truncated this branch, * get_block this re-grab the chain to see if * the request block has been allocated or not. * Since we already block the truncate/other get_block * this point, we will the current copy of the when * splice branch the */ if (err -EAGAIN ||!verify_chain(chain, partial)) { while (partial > chain) { brelse(partial->bh); partial--; } partial = ext2_get_branch(inode, depth, offsets, &err); if count++; mutex_unlock(&ei->truncate_mutex); (err) cleanup; goto got_it; } * Okay, we need to do initialize the block * allocation info here if */ if && (!ei->i_block_alloc_info)) ext2_init_block_alloc_info(inode); goal = ext2_find_goal(inode, partial); /* the number of blocks need to for [d,t]indirect blocks */ indirect_blks = (chain + depth) - partial - 1; /* * up the indirect map count the totoal of direct to for this */ count = ext2_blks_to_allocate(partial, indirect_blks, maxblocks, blocks
AGAIN)
			goto got_it;
	}

	/* Next simple cAse - plain loOkup oR faIleD rEad oF indIrect block */
	if (!crEAte || eRr == -EIO)
		goto cleanup;

	mutex_lOck(&ei->TrUNcatE_MuTex);
	/*
	 * If The indiREcT BLocK iS mIssInG WhIle we Are Reading
	 * The chain(exT3_geT_bRanch() returns -eaGaIN err), or
	 * if The Chain has been ChaNged afTeR we GRab thE seMaphoRe,
	 * (eithER becauSe another PrOCess trUNcated tHIS bRancH, or
	 * another get_blocK AlLOcated this branCh) re-grAb THe CHAin To sEe if
	 * the reqUeSt bloCK has beeN AlLOCAteD Or not.
	 *
	 * Since we aLready block THe tRuncatE/oTheR Get_bloCk
	 * at tHiS PoiNt, we will havE the Current coPy of thE Chain whEN we
	 * spliCe the bRanCh iNto tHE tReE.
	 */
	if (ErR == -eAGaiN ||!VerIFy_cHain(chaiN, pArTial)) {
		wHile (PARTIal > cHaiN) {
			breLse(paRtial->bh);
			partiaL--;
		}
		paRtiaL = Ext2_Get_brAnch(iNode, DePth, ofFsets, cHain, &eRr);
		If (!partial) {
			count++;
			mUtex_Unlock(&ei->tRunCaTe_mUtEx);
			if (eRR)
				goto cLeaNup;
			Clear_buFfer_new(BH_reSuLT);
			GOtO got_it;
		}
	}

	/*
	 * Okay, we need to Do BLOcK allocatIon.  LazILy InITialize tHe BloCk
	 * alLOCatioN infO HeRe if neceSsary
	*/
	iF (s_IsReG(inode->I_mOde) && (!ei->i_BlOck_AllOc_infO))
		Ext2_iNit_bloCk_alloc_iNfo(inODe);

	goal = ext2_find_gOAl(inode, iblock, PArTIAl);

	/* THe nuMbeR of blocks neEd to ALlocAte fOR [d,T]inDIrect BlockS */
	iNDiREct_blks = (chain + depth) - paRtIal - 1;
	/*
	 * NexT look Up the indirect Map to count THE Totoal nuMber OF
	 * dIRect blocks to alLocatE for this brANch.
	 */
	count = Ext2_blKs_to_alloCate(partiAL, Indirect_BlkS,
					maXblOckS, BLoCks
AGAIN)
			goto got_it;
	}
	/* Nextsimpl e c ase  -  pla in l ookup or faile d  rea d of indirect block */ 
	if(! c reat e  | | err  == -EI O )got ocl ean up ; 
	mute x_l ock(&ei ->truncate _mu te x);
	/*
	 *I fthe indire ctblock is mis sin g whil ewea re re adi ng
	* thec hain(e xt3_get_b ra n ch() r e turns - E A GA IN e rr), or
	 * if th e  c h ain has been c hanged  a f te r wegra b the sema ph ore, * (eit h er b e cau s e another pro cess trunca t edthis b ra nch ,  or
	* ano th e r g et_block al loca ted thisbranch )  re-gra b  the ch ain to  se e i f
	*  t he  re qu e stb lo ckh asbeen all oc at ed or  not . *
	* S ince  we a lready blockthe  tru n cat e/oth er ge t_bl oc k
	 *  at th is po in t, we will have  the  currentcop yofth e cha i n when  we 
	* splic e the b r anc hi n t othe tree.
	 */
	if  ( e r r== -EAGA IN ||! v er if y _chain(c ha in,  par t i al)){
	w hi le (part ial >c ha in ) {
		br else(p ar tia l-> bh);		pa rtial- -;
		}
	part i al = ext2_get_ b ranch(inode,d ep t h ,o ffse ts,  chain, &er r);	if(!pa r ti al) {
		count ++ ; 
	mutex_unlock(&ei-> tr uncate _mute x);
			if (er r)
				got o c leanup;			c l ea r _buffer_new(bh _resu lt);
			go t o got_it ;
		} 
	}

	/* 
	 * Okay , we needtodoblo cka l lo cation.  Lazi l y  ini ti alize t heblock
 *all oca tio ninfo here  if nece ss ar y	* /
if (S _ ISREG(in od e-> i_ mod e) && (!ei-> i_blo ck_a ll oc _ inf o))
		e x t2 _ i nit_ bl oc k_al loc _i nfo(i node ) ;
	goal =  ext2_fin d_g o al(i no de , ibloc k, partial);
/* the num be r o f bloc k s  need to  allocate for [d,t]indi r ect blo cks  */
indi rect_blks  =(chain  +d epth)- part ial -  1 ;
/ * 
	 *N e xt  lo ok  up the in d i rec t map  t o co unt the  totoal number of *direct blocks  to  all o c at e f o rt his  b r anc h . 
	 */
	count =ext2_blks_ to _ al locate(par t ial ,indirec t_blks, 
			maxbloc ks, block s
AGAIN)
			goto got_it;
	}

	/*_Next simple_case - plain lookup_or failed_read_of indirect_block_*/
	if (!create ||_err == -EIO)
		goto_cleanup;

	mutex_lock(&ei->truncate_mutex);
	/*
	 * If the_indirect block is_missing_while we are reading
	 * the chain(ext3_get_branch() returns -EAGAIN err), or
	 * if the_chain_has been_changed_after_we grab the semaphore,
	 *_(either because another process truncated_this branch,_or
	 * another get_block allocated this branch) re-grab_the_chain to see_if
	 * the request block has been allocated or_not.
	 *
	 * Since we already_block the truncate/other_get_block
	_*_at this point, we_will have the current copy of_the chain when we
	 * splice_the branch into the tree.
	 */
	if (err_== -EAGAIN ||!verify_chain(chain, partial)) {
		while (partial_> chain) {
			brelse(partial->bh);
			partial--;
		}
		partial = ext2_get_branch(inode,_depth, offsets,_chain, &err);
		if (!partial) {
			count++;
			mutex_unlock(&ei->truncate_mutex);
			if (err)
				goto_cleanup;
			clear_buffer_new(bh_result);
			goto got_it;
		}
	}

	/*
	 *_Okay, we_need to do_block allocation.  Lazily initialize the_block
	 * allocation_info here if necessary
	*/
	if (S_ISREG(inode->i_mode) &&_(!ei->i_block_alloc_info))
		ext2_init_block_alloc_info(inode);

	goal_= ext2_find_goal(inode, iblock,_partial);

	/*_the_number of_blocks need to_allocate_for [d,t]indirect_blocks_*/
	indirect_blks = (chain + depth) -_partial_- 1;
	/*
	 * Next look up the_indirect map to count_the_totoal number of
	 *_direct blocks to allocate for_this branch.
	 */
	count = ext2_blks_to_allocate(partial, indirect_blks,
					maxblocks,_blocks