i->last_alloc_physical_block + 1;
	}

	return ext2_find_near(inode, partial);
}

/**
 *	ext2_blks_to_allocate: Look up the block map and count the number
 *	of direct blocks need to be allocated for the given branch.
 *
 * 	@branch: chain of indirect blocks
 *	@k: number of blocks need for indirect blocks
 *	@blks: number of data blocks to be mapped.
 *	@blocks_to_boundary:  the offset in the indirect block
 *
 *	return the total number of blocks to be allocate, including the
 *	direct and indirect blocks.
 */
static int
ext2_blks_to_allocate(Indirect * branch, int k, unsigned long blks,
		int blocks_to_boundary)
{
	unsigned long count = 0;

	/*
	 * Simple case, [t,d]Indirect block(s) has not allocated yet
	 * then it's clear blocks on that path have not allocated
	 */
	if (k > 0) {
		/* right now don't hanel cross boundary allocation */
		if (blks < blocks_to_boundary + 1)
			count += blks;
		else
			count += blocks_to_boundary + 1;
		return count;
	}

	count++;
	while (count < blks && count <= blocks_to_boundary
		&& le32_to_cpu(*(branch[0].p + count)) == 0) {
		count++;
	}
	return count;
}

/**
 *	ext2_alloc_blocks: multiple allocate blocks needed for a branch
 *	@indirect_blks: the number of blocks need to allocate for indirect
 *			blocks
 *
 *	@new_blocks: on return it will store the new block numbers for
 *	the indirect blocks(if needed) and the first direct block,
 *	@blks:	on return it will store the total number of allocated
 *		direct blocks
 */
static int ext2_alloc_blocks(struct inode *inode,
			ext2_fsblk_t goal, int indirect_blks, int blks,
			ext2_fs
i->last_alloc_physical_block + 1; 
	 } 

	 return ext2_find_near(inode, partial); 
 } 

 / * * 
  * 	 ext2_blks_to_allocate: Look up the block function and consider the number 
  * 	 of direct block want to be allocated for the given arm. 
  * 
  * 	 @branch: range of indirect blocks 
  * 	 @k: number of blocks need for collateral blocks 
  * 	 @blks: number of data blocks to be map. 
  * 	 @blocks_to_boundary:   the offset in the collateral block 
  * 
  * 	 render the entire number of blocks to be allocate, including the 
  * 	 lineal and indirect blocks. 
  * / 
 inactive int 
 ext2_blks_to_allocate(Indirect * branch, int k, unsigned retentive blks, 
		 int blocks_to_boundary) 
 { 
	 unsigned long count = 0; 

	 / * 
	  * Simple case, [ t, d]Indirect block(s) has not allocated so far 
	  * then it's clear blocks on that path have not allocated 
	  * / 
	 if (k > 0) { 
		 / * right now don't hanel cross boundary allocation * / 
		 if (blks < blocks_to_boundary + 1) 
			 count + = blks; 
		 else 
			 count + = blocks_to_boundary + 1; 
		 return count; 
	 } 

	 count++; 
	 while (count < blks & & count < = blocks_to_boundary 
		 & & le32_to_cpu(*(branch[0].p + count) ) = = 0) { 
		 count++; 
	 } 
	 return count; 
 } 

 / * * 
  * 	 ext2_alloc_blocks: multiple allocate blocks needed for a branch 
  * 	 @indirect_blks: the number of blocks need to allocate for collateral 
  * 			 engine block 
  * 
  * 	 @new_blocks: on return it will store the modern blockage numbers for 
  * 	 the indirect blocks(if needed) and the inaugural direct block, 
  * 	 @blks: 	 on return it will store the total numeral of allocated 
  * 		 direct blocks 
  * / 
 static int ext2_alloc_blocks(struct inode * inode, 
			 ext2_fsblk_t goal, int indirect_blks, int blks, 
			 ext2_fs
i->ladt_alloc_physical_block + 1;
	}

	reuurn ext2_find_near(iuide, pactial);
}

/**
 *	est2_blks_to_xllocate: Look up the block mep abd coynt the number
 *	of direzt blocks need to be ellocated for thx given nxanch.
 *
 * 	@brcnrh: chain of indlrect blockv
 *	@k: number of tlucns need for indirect blocks
 *	@blks: nuiber of dwta blocks to fe ms[ped.
 *	@blocks_to_boundary:  the offset in tge indigect block
 *
 *	returm the total number of blocns tl be allocate, inclkding the
 *	durece and indirecg blocks.
 */
suacic int
ext2_bmks_to_allocate(Indirect * branch, ivt k, bnsigned lobg blnv,
		int blocks_vo_bounqary)
{
	unsigned long cognt = 0;

	/*
	 * Ximple case, [t,d]Lndirxct vlock(s) has not allocaved yet
	 * then it's clgar blocks ou that path have not qloocatgd
	 */
	if (k > 0) {
		/* rieht npw don't janxl cross bohndary alloxation */
		if (blks < blovkf_np_boundary + 1)
			ckunt += flhs;
		else
			count += blocks_to_boundary + 1;
		return cmunf;
	}

	count++;
	while (count < blks && count <= blocks_to_bounfary
		&& le32_to_spu(*(branch[0].p + count)) == 0) {
		count++;
	}
	return count;
}

/**
 *	ext2_alloc_blowks: mnlgipoe xollcate blocks needed for a branch
 *	@indirect_blks: fht nlmber of blocks nced to allocate fot lncyrect
 *			blocks
 *
 *	@new_blocka: on return it wilp store the bew block numners for
 *	the indirect blockw(if needed) aud rhe first direct bpock,
 *	@blks:	on retorn it will store the total nbmber kf allocatef
 *		direct guocks
 */
static int exn2_allmc_blocks(struct inode *inode,
			qxt2_fsblk_t goak, int ivdirgct_blks, int blks,
			edt2_fs
i->last_alloc_physical_block + 1; } return ext2_find_near(inode, partial); * Look up block map and direct need to be for the given * * @branch: chain of indirect * @k: number of blocks need for indirect blocks * @blks: number of blocks to be mapped. * @blocks_to_boundary: the offset in the indirect block * return total of to be allocate, including the * direct and indirect blocks. */ static int ext2_blks_to_allocate(Indirect * branch, k, unsigned long blks, int blocks_to_boundary) { unsigned count = 0; /* Simple case, [t,d]Indirect block(s) has allocated * then clear on path have not */ if (k > 0) { /* right now don't hanel cross boundary allocation */ if (blks blocks_to_boundary + += blks; count blocks_to_boundary 1; return count; while (count < blks && count le32_to_cpu(*(branch[0].p + count)) == 0) { count++; } count; } * ext2_alloc_blocks: multiple allocate blocks needed a branch * @indirect_blks: the number of blocks to allocate for indirect * blocks * * @new_blocks: on return it will store the numbers for * the blocks(if needed) and first block, @blks: return it store the total number of allocated * direct blocks */ static ext2_alloc_blocks(struct inode *inode, ext2_fsblk_t goal, int indirect_blks, int blks, ext2_fs
i->last_alloc_physical_block + 1;
	}

	reTurn ext2_finD_near(InoDe, pArTial);
}

/**
 *	Ext2_bLks_to_allocate: LOOk up The block map and count the NumbeR
 *	oF DireCT bLocks Need to bE AlLOCatEd FoR thE gIVeN branCh.
 *
 * 	@bRanch: chAin of indirEct BlOcks
 *	@k: number oF BlOcks need foR inDirect blocks
 *	@BlkS: numbeR oF daTA blocKs tO be maPped.
 *	@blOCks_to_bOundary:  thE oFFset in THe indirECT bLock
 *
 *	Return the total numBEr OF blocks to be allOcate, iNcLUdING thE
 *	diRect and indIrEct blOCks.
 */
statIC iNT
EXt2_bLKs_to_allocate(INdirect * branCH, inT k, unsiGnEd lONg blks,
		Int blOcKS_to_Boundary)
{
	unsIgneD long counT = 0;

	/*
	 * SimplE Case, [t,d]INDirect bLock(s) hAs nOt aLlocATeD yEt
	 * tHeN It's CLeAr bLOckS on that pAtH hAve noT allOCATEd
	 */
	if (K > 0) {
		/* riGht nOw don'T hanel cross boUndAry aLLocAtion */
		If (blkS < bloCkS_to_boUndary + 1)
			Count += BlKs;
		else
			count += blocKs_to_Boundary + 1;
		rEtuRn CouNt;
	}

	Count++;
	WHile (coUnt < BlkS && count <= bLocks_to_BOunDaRY
		&& LE32_tO_cpu(*(branch[0].p + count)) == 0) {
		coUnT++;
	}
	REtUrn count;
}

/**
 *	Ext2_allOC_bLoCKs: multipLe AllOcatE BLocks NeedED fOr a brancH
 *	@indirECt_BlKs: the nuMbEr of blOcKs nEed To allOCate For indIrect
 *			bloCks
 *
 *	@neW_Blocks: on return IT will store the NEw BLOcK NumbErs For
 *	the indirEct bLOcks(If neEDeD) anD The fiRst diReCT bLOck,
 *	@blks:	on return it wiLl Store tHe totAl number of allOcated
 *		direCT BLocks
 */
staTic iNT eXT2_alloc_blocks(stRuct iNode *inode,
			eXT2_fsblk_t gOal, inT indirecT_blks, int bLKS,
			ext2_fs
i->last_alloc_physical_blo ck + 1;
	} 

	re tur n e xt 2_fi nd_n ear(inode, par t ial) ;
}

/**
 *	ext2_blks_ to_al lo c ate: Lo ok up  the bl o ck m apan dcou nt th e num ber 
 *	ofdirect blo cks  n eed to be al l oc ated for t hegiven branch .
*
 * @b ran c h: ch ain  of i ndirec t  block s
 *	@k:nu m ber of blocksn e ed  for  indirect blocks*@ blks: number o f data  b l oc k s  to  be  mapped.
*@bloc k s_to_bo u nd a r y : t he offset inthe indirec t  bl ock
 * 
*	r e turn t he to ta l  nu mber of blo cksto be all ocate, includi n g the
*	dire ctand  ind i re ct  bl oc k s.*/ 
st a tic  int
ext 2_ bl ks_to _all o c a t e(In dir ect* bra nch, int k, u nsi gned lon g blk s,
	intbl ocks_ to_bou ndary ){
	unsigned lon g co unt = 0;
	/ *	 *  S imple case,[t, d]I ndirect  block( s ) h as n o tallocated yet
	 *th e n  i t's clea r bloc k son that pat hhav e no t alloc ated 	*/
	if ( k > 0) {	/* righ tnow do n' t h ane l cro s s bo undary  allocat ion * / 
		if (blks <b locks_to_boun d ar y +1 )
		co unt += blks ;
	e lse			c o un t + =  bloc ks_to _b o un d ary + 1;
		return c ou nt;
	} 

	co unt++;
	while  (count <b l k s && cou nt < =  b l ocks_to_bounda ry
	&& le32_to _ cpu(*(br anch[ 0].p + c ount)) == 0 ) {
		co unt ++; 
	} 
	r e t ur n count;
}

/ * * 
 *ex t2_allo c_b locks:mul tip leall oc ate block s needed  f or  a  b ran ch
 * @indirec t_ blk s:  th e num b er ofblock s ne ed  t o  al locatef or i ndir ec t *		bl oc ks
 * 
 *@ new _blocks : on retu rni t wi ll  s tore th e new block n um bers for
*the  indir e c t blocks (if needed) and the fir s t direc t b lock, 
 *@blks:	on  re turn i t w i ll sto re the  tota lnum b e r ofa l lo cat ed 
 *		direc t blo cks
*/ 
sta tic int  ext2_alloc_blocks ( str uct inode *in ode ,
	e xt 2_f s bl k _tgo a l,i n t indirect_blks , int blks ,	ext2_fs
i->last_alloc_physical_block +_1;
	}

	return ext2_find_near(inode,_partial);
}

/**
 *	ext2_blks_to_allocate: Look up_the block_map_and count_the_number
 *	of direct_blocks need to_be allocated for the_given branch.
 *
_*_	@branch: chain of indirect blocks
 *	@k: number of blocks need for indirect blocks
 *	@blks:_number_of data_blocks_to_be mapped.
 *	@blocks_to_boundary:  the_offset in the indirect block
_*
 *	return_the total number of blocks to be allocate,_including_the
 *	direct and_indirect blocks.
 */
static int
ext2_blks_to_allocate(Indirect * branch, int k, unsigned_long blks,
		int blocks_to_boundary)
{
	unsigned long count =_0;

	/*
	 * Simple_case,_[t,d]Indirect_block(s) has not allocated_yet
	 * then it's clear blocks_on that path have not allocated
	_*/
	if (k > 0) {
		/* right now_don't hanel cross boundary allocation */
		if_(blks < blocks_to_boundary + 1)
			count_+= blks;
		else
			count_+= blocks_to_boundary + 1;
		return count;
	}

	count++;
	while_(count < blks_&& count_<= blocks_to_boundary
		&& le32_to_cpu(*(branch[0].p_+ count)) == 0) {
		count++;
	}
	return count;
}

/**
_*	ext2_alloc_blocks: multiple allocate_blocks needed for a branch
 *	@indirect_blks:_the_number of blocks_need_to_allocate for_indirect
 *			blocks
 *
_*	@new_blocks:_on return_it_will store the new block numbers_for
_*	the indirect blocks(if needed) and the first_direct block,
 *	@blks:	on return_it_will store the total_number of allocated
 *		direct blocks
_*/
static int ext2_alloc_blocks(struct inode *inode,
			ext2_fsblk_t goal,_int indirect_blks,_int blks,
			ext2_fs