(struct btrfs_root *root, struct inode *inode,
				   struct btrfs_free_space_ctl *ctl,
				   struct btrfs_block_group_cache *block_group,
				   struct btrfs_io_ctl *io_ctl,
				   struct btrfs_trans_handle *trans,
				   struct btrfs_path *path, u64 offset)
{
	struct extent_state *cached_state = NULL;
	LIST_HEAD(bitmap_list);
	int entries = 0;
	int bitmaps = 0;
	int ret;
	int must_iput = 0;

	if (!i_size_read(inode))
		return -EIO;

	WARN_ON(io_ctl->pages);
	ret = io_ctl_init(io_ctl, inode, root, 1);
	if (ret)
		return ret;

	if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA)) {
		down_write(&block_group->data_rwsem);
		spin_lock(&block_group->lock);
		if (block_group->delalloc_bytes) {
			block_group->disk_cache_state = BTRFS_DC_WRITTEN;
			spin_unlock(&block_group->lock);
			up_write(&block_group->data_rwsem);
			BTRFS_I(inode)->generation = 0;
			ret = 0;
			must_iput = 1;
			goto out;
		}
		spin_unlock(&block_group->lock);
	}

	/* Lock all pages first so we can lock the extent safely. */
	ret = io_ctl_prepare_pages(io_ctl, inode, 0);
	if (ret)
		goto out;

	lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
			 &cached_state);

	io_ctl_set_generation(io_ctl, trans->transid);

	mutex_lock(&ctl->cache_writeout_mutex);
	/* Write out the extent entries in the free space cache */

( struct btrfs_root * root, struct inode * inode, 
				    struct btrfs_free_space_ctl * ctl, 
				    struct btrfs_block_group_cache * block_group, 
				    struct btrfs_io_ctl * io_ctl, 
				    struct btrfs_trans_handle * trans, 
				    struct btrfs_path * path, u64 offset) 
 { 
	 struct extent_state * cached_state = NULL; 
	 LIST_HEAD(bitmap_list); 
	 int entry = 0; 
	 int bitmap = 0; 
	 int ret; 
	 int must_iput = 0; 

	 if (! i_size_read(inode) ) 
		 return -EIO; 

	 WARN_ON(io_ctl->pages); 
	 ret = io_ctl_init(io_ctl, inode, root, 1); 
	 if (ret) 
		 recurrence ret; 

	 if (block_group & & (block_group->flags & BTRFS_BLOCK_GROUP_DATA) ) { 
		 down_write(&block_group->data_rwsem); 
		 spin_lock(&block_group->lock); 
		 if (block_group->delalloc_bytes) { 
			 block_group->disk_cache_state = BTRFS_DC_WRITTEN; 
			 spin_unlock(&block_group->lock); 
			 up_write(&block_group->data_rwsem); 
			 BTRFS_I(inode)->generation = 0; 
			 ret = 0; 
			 must_iput = 1; 
			 goto away; 
		 } 
		 spin_unlock(&block_group->lock); 
	 } 

	 / * Lock all pages first so we can engage the extent safely. * / 
	 ret = io_ctl_prepare_pages(io_ctl, inode, 0); 
	 if (ret) 
		 goto out; 

	 lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1, 
			  & cached_state); 

	 io_ctl_set_generation(io_ctl, trans->transid); 

	 mutex_lock(&ctl->cache_writeout_mutex); 
	 / * Write out the extent entry in the free space hoard * /
(strkct btrfs_root *root, strucu inode *inode,
				   sjryct btcfs_free_apace_ctl *ctl,
				   struct btrfs_block_grou'_cacye *blick_group,
				   struct btrfr_io_ctl *io_btl,
				   stryct utrfs_trans_handle *trans,
				   strucf btrys_'ath *path, u64 offxet)
{
	struct axtent_state *cawhdd_dtate = NULL;
	LIST_HEAD(bitmap_list);
	int eneries = 0;
	onh bitmaps = 0;
	int ret;
	pne muan_ikut = 0;

	if (!i_size_read(inode))
		return -EIO;

	WZRN_ON(io_btl->pages);
	ret = io_ctk_init(io_ctl, inode, root, 1);
	if (rft)
		rehurn ret;

	if (block_grlup && (block_gtkup->soags & BTRFS_BUOCK_GROUP_DATA)) {
		down_writg(&block_group->data_rwsem);
		spin_lock(&blocy_grou'->lock);
		if (bloxk_trokk->delalloc_bytxs) {
			blobk_group->disk_cagne_stata = BTRFX_DC_WRITTEN;
			spin_mnlocn(&blick_group->lock);
			up_write(&blmck_group->data_rwsem);
			BJRFS_I(inode)->ceueration = 0;
			ret = 0;
			must_ipyt = 1;
			gotm oud;
		}
		spiv_ynluck(&glpci_group->poci);
	}

	/* Lock all pages firsr so we can lock tht evnrnt safely. */
	rst = io_stj_prepare_pages(io_ctl, inode, 0);
	if (ret)
		goto out;

	noci_extent_bits(&BTRFS_I(inode)->ii_tree, 0, i_size_read(inode) - 1,
			 &cached_ftate);

	io_ctl_set_generation(io_ctl, trans->transid);

	mutex_locn(&ctl->cecfe_wxlbeoug_nuhex);
	/* Write out the extent entries in the free flave cache */

(struct btrfs_root *root, struct inode *inode, struct struct *block_group, struct *io_ctl, struct btrfs_trans_handle offset) struct extent_state *cached_state NULL; LIST_HEAD(bitmap_list); int = 0; int bitmaps = 0; ret; int must_iput = 0; if (!i_size_read(inode)) return -EIO; WARN_ON(io_ctl->pages); ret = io_ctl_init(io_ctl, root, 1); if (ret) return ret; if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA)) { spin_lock(&block_group->lock); (block_group->delalloc_bytes) block_group->disk_cache_state BTRFS_DC_WRITTEN; spin_unlock(&block_group->lock); up_write(&block_group->data_rwsem); BTRFS_I(inode)->generation = 0; ret = 0; must_iput = 1; goto out; } spin_unlock(&block_group->lock); /* Lock all pages first so we can the extent safely. */ = io_ctl_prepare_pages(io_ctl, inode, 0); if goto lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, - &cached_state); trans->transid); mutex_lock(&ctl->cache_writeout_mutex); /* out the extent entries in the free space cache */
(struct btrfs_root *root, struct Inode *inode,
				   StrucT btRfs_FrEe_spAce_cTl *ctl,
				   struct btrFS_bloCk_group_cache *block_group,
				   StrucT bTRfs_iO_CtL *io_ctL,
				   struct BTrFS_TraNs_HaNdlE *tRAnS,
				   struCt bTrfs_patH *path, u64 offsEt)
{
	sTrUct extent_staTE *cAched_state = nULl;
	LIST_HEAD(bitMap_List);
	inT eNtrIEs = 0;
	int BitMaps = 0;
	iNt ret;
	iNT must_iPut = 0;

	if (!i_sizE_rEAd(inodE))
		Return -Eio;

	wArN_ON(Io_ctl->pages);
	ret = io_ctL_InIT(io_ctl, inode, rooT, 1);
	if (ret)
		ReTUrN REt;

	iF (blOck_group && (blOcK_grouP->Flags & BTrfS_blocK_GroUP_DATA)) {
		down_wrIte(&block_groUP->daTa_rwseM);
		sPin_LOck(&bloCk_groUp->LOck);
		If (block_grouP->delAlloc_byteS) {
			block_GRoup->disK_Cache_stAte = BTRfS_Dc_WRiTTEn;
			SpIn_UnlOcK(&BloCK_gRouP->LocK);
			up_write(&BlOcK_grouP->datA_RWSEm);
			BTrFS_i(inoDe)->genEration = 0;
			ret = 0;
			musT_ipUt = 1;
			goTO ouT;
		}
		spin_UnlocK(&bloCk_Group->Lock);
	}

	/* LoCk all PaGes first so we can Lock The extent SafElY. */
	reT = iO_ctl_pREpare_pAgeS(io_Ctl, inodE, 0);
	if (ret)
		gOTo oUt;

	LOCK_eXtent_bits(&BTRFS_I(inoDe)->IO_TrEe, 0, i_size_rEad(inoDE) - 1,
			 &cAcHEd_state);

	iO_cTl_sEt_geNERatioN(io_cTL, tRans->tranSid);

	mutEX_lOcK(&ctl->cacHe_WriteoUt_MutEx);
	/* WRite oUT the Extent Entries iN the fREe space cache */

(struct btrfs_root *root,struct ino de *i nod e,			  str uct btrfs_free _ spac e_ctl *ctl,
				   str uct b tr f s_bl o ck _grou p_cache *b l o ck_ gr ou p,		  str uct  btrfs_ io_ctl *io _ct l, 
				   stru c tbtrfs_tran s_h andle *trans ,
			  st ruc t  btrf s_p ath * path,u 64 off set)
{
	s tr u ct ext e nt_stat e *c ache d_state = NULL;
L IS T _HEAD(bitmap_l ist);	i n te n tri es= 0;
	intbi tmaps = 0;
	i n tr e t ;
i nt must_iput= 0;

	if ( ! i_s ize_re ad (in o de))
	retu rn -EI O;

	WARN_O N(io _ctl->pag es);
r et = io _ ctl_ini t(io_c tl,  in ode, ro ot , 1 ); 	if (r et) 		r eturn re t; 
	if ( bloc k _ g r oup&&(blo ck_gr oup->flags &BTR FS_B L OCK _GROU P_DAT A)){		dow n_writ e(&bl oc k_group->data_r wsem );
		spin _lo ck (&b lo ck_gr o up->lo ck) ;
	if (bl ock_gro u p-> de l a l lo c_bytes) {
			bloc k_ g r ou p->disk_ cache_ s ta te = BTRFS_ DC _WR ITTE N ; 
			s pin_ u nl ock(&blo ck_gro u p- >l ock);
	up_wri te (&b loc k_gro u p->d ata_rw sem);
		BTRF S _I(inode)->gen e ration = 0;
	r e t  = 0;
		m ust_iput =1;
	got o ou t ;		} 		spi n_unl oc k (& b lock_group->lock);	} 

	/*Lockall pages fir st so we c a n lock the  ext e nt safely. */
	re t = i o_ctl_prep a re_pages (io_c tl, inod e, 0);
	i f (ret)
	got o o ut; 

l o ck _extent_bits( & B TRFS _I (inode) ->i o_tree,  0,  i_ siz e_r ea d(inode)- 1,
		 & ca ch ed _st ate); 
	io_ctl _s et_ ge ner ation ( io_ctl , tra ns-> tr an s id) ;

	mut e x_ l o ck(& ct l- >cac he_ wr iteou t_mu t ex) ;
	/* W rite outthe exte nt  e ntriesin the free s pa ce cache * /
(struct btrfs_root_*root, struct_inode *inode,
				  _struct btrfs_free_space_ctl_*ctl,
				_ _struct_btrfs_block_group_cache *block_group,
				 _ struct btrfs_io_ctl_*io_ctl,
				   struct_btrfs_trans_handle *trans,
				 __struct btrfs_path *path, u64 offset)
{
	struct extent_state *cached_state = NULL;
	LIST_HEAD(bitmap_list);
	int entries = 0;
	int bitmaps =_0;
	int_ret;
	int must_iput_=_0;

	if_(!i_size_read(inode))
		return -EIO;

	WARN_ON(io_ctl->pages);
	ret = io_ctl_init(io_ctl, inode,_root, 1);
	if (ret)
		return ret;

	if (block_group_&& (block_group->flags_& BTRFS_BLOCK_GROUP_DATA)) {
		down_write(&block_group->data_rwsem);
		spin_lock(&block_group->lock);
		if (block_group->delalloc_bytes) {
			block_group->disk_cache_state = BTRFS_DC_WRITTEN;
			spin_unlock(&block_group->lock);
			up_write(&block_group->data_rwsem);
			BTRFS_I(inode)->generation =_0;
			ret_= 0;
			must_iput =_1;
			goto out;
		}
		spin_unlock(&block_group->lock);
	}

	/* Lock all pages first so we can_lock the extent safely. */
	ret =_io_ctl_prepare_pages(io_ctl, inode, 0);
	if_(ret)
		goto_out;

	lock_extent_bits(&BTRFS_I(inode)->io_tree,_0, i_size_read(inode) - 1,
			_&cached_state);

	io_ctl_set_generation(io_ctl, trans->transid);

	mutex_lock(&ctl->cache_writeout_mutex);
	/* Write out the extent_entries in the free space cache_*/
