->disk_cache_state = BTRFS_DC_CLEAR;
		spin_unlock(&block_group->lock);
	}
	btrfs_free_path(path);

	btrfs_i_size_write(inode, 0);
	truncate_pagecache(inode, 0);

	/*
	 * We don't need an orphan item because truncating the free space cache
	 * will never be split across transactions.
	 * We don't need to check for -EAGAIN because we're a free space
	 * cache inode
	 */
	ret = btrfs_truncate_inode_items(trans, root, inode,
					 0, BTRFS_EXTENT_DATA_KEY);
	if (ret)
		goto fail;

	ret = btrfs_update_inode(trans, root, inode);

fail:
	if (locked)
		mutex_unlock(&trans->transaction->cache_write_mutex);
	if (ret)
		btrfs_abort_transaction(trans, ret);

	return ret;
}

static int readahead_cache(struct inode *inode)
{
	struct file_ra_state *ra;
	unsigned long last_index;

	ra = kzalloc(sizeof(*ra), GFP_NOFS);
	if (!ra)
		return -ENOMEM;

	file_ra_state_init(ra, inode->i_mapping);
	last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;

	page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index);

	kfree(ra);

	return 0;
}

static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
		       struct btrfs_root *root, int write)
{
	int num_pages;
	int check_crcs = 0;

	num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);

	if (btrfs_ino(inode)!= BTRFS_FREE_INO_OBJECTID)
		check_crcs = 1;

	
->disk_cache_state = BTRFS_DC_CLEAR; 
		 spin_unlock(&block_group->lock); 
	 } 
	 btrfs_free_path(path); 

	 btrfs_i_size_write(inode, 0); 
	 truncate_pagecache(inode, 0); 

	 / * 
	  * We don't need an orphan item because truncating the free quad hoard 
	  * will never be split across transactions. 
	  * We don't necessitate to control for -EAGAIN because we're a free space 
	  * cache inode 
	  * / 
	 ret = btrfs_truncate_inode_items(trans, etymon, inode, 
					  0, BTRFS_EXTENT_DATA_KEY); 
	 if (ret) 
		 goto fail; 

	 ret = btrfs_update_inode(trans, etymon, inode); 

 fail: 
	 if (locked) 
		 mutex_unlock(&trans->transaction->cache_write_mutex); 
	 if (ret) 
		 btrfs_abort_transaction(trans, ret); 

	 return ret; 
 } 

 inactive int readahead_cache(struct inode * inode) 
 { 
	 struct file_ra_state * ra; 
	 unsigned long last_index; 

	 ra = kzalloc(sizeof(*ra), GFP_NOFS); 
	 if (! ra) 
		 return -ENOMEM; 

	 file_ra_state_init(ra, inode->i_mapping); 
	 last_index = (i_size_read(inode) - 1) > > PAGE_SHIFT; 

	 page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index); 

	 kfree(ra); 

	 hark back 0; 
 } 

 static int io_ctl_init(struct btrfs_io_ctl * io_ctl, struct inode * inode, 
		        struct btrfs_root * root, int write) 
 { 
	 int num_pages; 
	 int check_crcs = 0; 

	 num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); 

	 if (btrfs_ino(inode)!= BTRFS_FREE_INO_OBJECTID) 
		 check_crcs = 1;
->disn_cache_state = BTRFS_DC_CLEAV;
		spin_unlock(&block_yeoup->lork);
	}
	btrfs_rree_path(oath);

	btrfs_i_size_write(inode, 0);
	truicatw_pagexache(inode, 0);

	/*
	 * We don't nded an orihan item beceuse truncating vge free space gache
	 * will never be split acrmss transactiots.
	 * Ce don't need to check for -EAGAIN becwuse we'te a free space
	 * cacnq inkde
	 */
	ret = btrfs_truncate_inode_items(trzns, roou, inode,
					 0, BTRFS_EXTEMT_DATA_KEY);
	if (ret)
		goto fail;

	reh = bhrfs_update_inode(trajs, root, inoee);

fayo:
	if (locked)
		mugex_unlock(&tgcns->transactjon->cache_write_mutex);
	if (ret)
		btrfs_aburt_trcnsaction(trqnw, rfj);

	return ret;
}

svatic pnt readahead_gsche(stsuct inpde *inode)
{
	strucb filx_ra_srate *ra;
	unsigned long nast_index;

	ra = kzalljc(sizeof(*rd), YFP_NOFS);
	if (!ra)
		return -ENIMWM;

	filg_ra_stdte_ivut(rx, ihove->i_jappinh);
	laat_index = (i_aize_read(inoee) - 1) >> PAGE_SHIFT;

	page_vasye_sync_readahezd(inodq->i_iapping, ra, NULL, 0, last_index);

	kfree(ra);

	return 0;
}

stztic int io_ctl_init(strucr btrfs_io_ctl *io_ctl, sttuct inode *inode,
		       struct btrfs_root *root, int write)
{
	int ngm_pagxs;
	knt cmeck_zecd = 0;

	num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZQ);

	jf (bnrfs_ino(inode)!= BTRFF_FREE_INO_OBJRCHIC)
		sheck_crcs = 1;

	
->disk_cache_state = BTRFS_DC_CLEAR; spin_unlock(&block_group->lock); } btrfs_free_path(path); btrfs_i_size_write(inode, 0); * We need an orphan space * will never split across transactions. We don't need to check for because we're a free space * cache inode */ ret = btrfs_truncate_inode_items(trans, root, 0, BTRFS_EXTENT_DATA_KEY); if (ret) goto fail; ret = btrfs_update_inode(trans, root, inode); fail: if mutex_unlock(&trans->transaction->cache_write_mutex); (ret) ret); ret; } static int readahead_cache(struct inode *inode) { struct file_ra_state *ra; unsigned long last_index; ra = GFP_NOFS); if (!ra) return -ENOMEM; file_ra_state_init(ra, inode->i_mapping); last_index (i_size_read(inode) - 1) >> page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index); return } static io_ctl_init(struct *io_ctl, inode *inode, struct *root, int write) { int num_pages; int check_crcs = 0; num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); if (btrfs_ino(inode)!= BTRFS_FREE_INO_OBJECTID) = 1;
->disk_cache_state = BTRFS_DC_CLEAr;
		spin_unlocK(&blocK_grOup->LoCk);
	}
	btRfs_fRee_path(path);

	btrFS_i_siZe_write(inode, 0);
	truncate_paGecacHe(INode, 0);

	/*
	 * wE dOn't neEd an orpHAn ITEm bEcAuSe tRuNCaTing tHe fRee spacE cache
	 * will NevEr Be split acrosS TrAnsactions.
	 * we dOn't need to cheCk fOr -EAGAiN BecAUse we'Re a Free sPace
	 * caCHe inodE
	 */
	ret = btrfs_TrUNcate_iNOde_itemS(TRaNs, roOt, inode,
					 0, BTRFS_EXTENt_dAta_KEY);
	if (ret)
		goto fAil;

	ret = BtRFs_UPDatE_inOde(trans, roOt, Inode);

FAil:
	if (loCKeD)
		MUTex_UNlock(&trans->traNsaction->cacHE_wrIte_mutEx);
	If (rET)
		btrfs_Abort_TrANsaCtion(trans, rEt);

	reTurn ret;
}

stAtic inT ReadaheAD_cache(sTruct iNodE *inOde)
{
	sTRuCt FilE_rA_StaTE *rA;
	unSIgnEd long laSt_InDex;

	ra = KzalLOC(SIzeoF(*ra), gFP_NoFS);
	if (!Ra)
		return -ENOMEm;

	fiLe_ra_STatE_init(Ra, inoDe->i_mApPing);
	lAst_indEx = (i_siZe_Read(inode) - 1) >> PAGE_SHiFT;

	pAge_cache_sYnc_ReAdaHeAd(inoDE->i_mappIng, Ra, NuLL, 0, last_Index);

	kfREe(rA);

	rETURn 0;
}

Static int io_ctl_init(StRUCt Btrfs_io_cTl *io_ctL, StRuCT inode *inOdE,
		       stRuct BTRfs_roOt *roOT, iNt write)
{
	iNt num_pAGeS;
	iNt check_CrCs = 0;

	num_pAgEs = DiV_RoUND_Up(I_sizE_read(iNode), PAGE_sIZE);

	iF (Btrfs_ino(inode)!= BtrFS_FREE_INO_OBJecTid)
		ChECk_crCs = 1;

	
->disk_cache_state = BTRFS _DC_CLEAR; 
		sp in_ unl oc k(&b lock _group->lock); 	}
btrfs_free_path(path); 

	bt rf s _i_s i ze _writ e(inode ,  0 ) ; 
	t ru nc ate _p a ge cache (in ode, 0) ;

	/*
	 *  We  d on't need an or phan itembec ause truncat ing  the f re e s p ace c ach e
	 *  willn ever b e split a cr o ss tra n saction s . 
 * W e don't need to c h ec k  for -EAGAIN b ecause  w e 'r e a f ree  space
	 *  c achei node
	* /r e t = btrfs_truncat e_inode_ite m s(t rans,ro ot, inode, 
				0 , B TRFS_EXTENT _DAT A_KEY);
if (re t )
		got o  fail;
	ret= b trf s_up d at e_ ino de ( tra n s,  ro o t,inode);
f ai l:
	i f (l o c k e d)
	mu tex_ unloc k(&trans->tra nsa ctio n ->c ache_ write _mut ex );
	i f (ret )
		b tr fs_abort_transa ctio n(trans,ret ); 

re turnr et;
}
st ati c int r eadahea d _ca ch e ( s tr uct inode *inode){s tr uct file _ra_st a te  * r a;
	unsi gn edlong l ast_i ndex ; 
	ra = kz alloc( s iz eo f(*ra),  G FP_NOF S) ;
if(!ra) 		re turn - ENOMEM;
	fil e _ra_state_init ( ra, inode->i_ m ap p i ng ) ;
	l ast _index = (i _siz e _rea d(in o de ) - 1) >>  PAGE _S H IF T ;

	page_cache_sync _r eadahe ad(in ode->i_mappin g, ra, NUL L , 0, last_ inde x ); 
	kfree(ra);
	retu rn 0;
}

s t atic int  io_c tl_init( struct bt r f s_io_ctl  *i o_c tl,  st r u ct  inode *inode , 		     stru ctbtrfs_r oot  *r oot , i nt  write)
{ 
	int nu m_ pa ge s; 
	i nt ch e ck_crcs=0;
num _page s  = DIV _ROUN D_UP (i _s i ze_ read(in o de ) ,  PAG E_ SI ZE); 

if  (btr fs_i n o(i node)!=  BTRFS_FR EE_ I NO_O BJ EC TID)
	check_crcs =1; 

	
->disk_cache_state =_BTRFS_DC_CLEAR;
		spin_unlock(&block_group->lock);
	}
	btrfs_free_path(path);

	btrfs_i_size_write(inode, 0);
	truncate_pagecache(inode,_0);

	/*
	 * We don't_need an_orphan_item because_truncating_the free space_cache
	 * will_never be split across_transactions.
	 * We_don't_need to check for -EAGAIN because we're a free space
	 * cache inode
	 */
	ret_=_btrfs_truncate_inode_items(trans, root,_inode,
					_0,_BTRFS_EXTENT_DATA_KEY);
	if (ret)
		goto fail;

	ret = btrfs_update_inode(trans,_root, inode);

fail:
	if (locked)
		mutex_unlock(&trans->transaction->cache_write_mutex);
	if (ret)
		btrfs_abort_transaction(trans, ret);

	return_ret;
}

static int_readahead_cache(struct inode *inode)
{
	struct file_ra_state *ra;
	unsigned long last_index;

	ra =_kzalloc(sizeof(*ra),_GFP_NOFS);
	if (!ra)
		return -ENOMEM;

	file_ra_state_init(ra,_inode->i_mapping);
	last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;

	page_cache_sync_readahead(inode->i_mapping, ra, NULL,_0, last_index);

	kfree(ra);

	return 0;
}

static int io_ctl_init(struct btrfs_io_ctl_*io_ctl, struct inode_*inode,
		__   _ struct btrfs_root *root, int write)
{
	int_num_pages;
	int check_crcs = 0;

	num_pages = DIV_ROUND_UP(i_size_read(inode),_PAGE_SIZE);

	if (btrfs_ino(inode)!= BTRFS_FREE_INO_OBJECTID)
		check_crcs = 1;

	