 is guaranteed not to be the last io reference count
		 * because the caller (xfs_buf_iorequest) holds a count itself.
		 */
		atomic_dec(&bp->b_io_remaining);
		xfs_buf_ioerror(bp, EIO);
		bio_put(bio);
	}
}

int
xfs_buf_iorequest(
	xfs_buf_t		*bp)
{
	trace_xfs_buf_iorequest(bp, _RET_IP_);

	ASSERT(!(bp->b_flags & XBF_DELWRI));

	if (bp->b_flags & XBF_WRITE)
		xfs_buf_wait_unpin(bp);
	xfs_buf_hold(bp);

	/* Set the count to 1 initially, this will stop an I/O
	 * completion callout which happens before we have started
	 * all the I/O from calling xfs_buf_ioend too early.
	 */
	atomic_set(&bp->b_io_remaining, 1);
	_xfs_buf_ioapply(bp);
	_xfs_buf_ioend(bp, 0);

	xfs_buf_rele(bp);
	return 0;
}

/*
 *	Waits for I/O to complete on the buffer supplied.
 *	It returns immediately if no I/O is pending.
 *	It returns the I/O error code, if any, or 0 if there was no error.
 */
int
xfs_buf_iowait(
	xfs_buf_t		*bp)
{
	trace_xfs_buf_iowait(bp, _RET_IP_);

	wait_for_completion(&bp->b_iowait);

	trace_xfs_buf_iowait_done(bp, _RET_IP_);
	return bp->b_error;
}

xfs_caddr_t
xfs_buf_offset(
	xfs_buf_t		*bp,
	size_t			offset)
{
	struct page		*page;

	if (bp->b_flags & XBF_MAPPED
is guaranteed not to be the last io reference count 
		  * because the caller (xfs_buf_iorequest) holds a count itself. 
		  * / 
		 atomic_dec(&bp->b_io_remaining); 
		 xfs_buf_ioerror(bp, EIO); 
		 bio_put(bio); 
	 } 
 } 

 int 
 xfs_buf_iorequest (
	 xfs_buf_t 		 * bp) 
 { 
	 trace_xfs_buf_iorequest(bp, _ RET_IP _); 

	 ASSERT(!(bp->b_flags & XBF_DELWRI) ); 

	 if (bp->b_flags & XBF_WRITE) 
		 xfs_buf_wait_unpin(bp); 
	 xfs_buf_hold(bp); 

	 / * specify the count to 1 initially, this will check an I / O 
	  * completion callout which happens before we have started 
	  * all the one / O from calling xfs_buf_ioend besides early on. 
	  * / 
	 atomic_set(&bp->b_io_remaining, 1); 
	 _ xfs_buf_ioapply(bp); 
	 _ xfs_buf_ioend(bp, 0); 

	 xfs_buf_rele(bp); 
	 return 0; 
 } 

 / * 
  * 	 Waits for I / O to complete on the buffer add. 
  * 	 It returns immediately if no I / O is pending. 
  * 	 It returns the one / O error code, if any, or 0 if there was no error. 
  * / 
 int 
 xfs_buf_iowait (
	 xfs_buf_t 		 * bp) 
 { 
	 trace_xfs_buf_iowait(bp, _ RET_IP _); 

	 wait_for_completion(&bp->b_iowait); 

	 trace_xfs_buf_iowait_done(bp, _ RET_IP _); 
	 return bp->b_error; 
 } 

 xfs_caddr_t 
 xfs_buf_offset (
	 xfs_buf_t 		 * bp, 
	 size_t 			 offset) 
 { 
	 struct page 		 * page; 

	 if (bp->b_flags & XBF_MAPPED
 is guaranteed not to be tht last io referenew counv
		 * becahse the zaller (xfs_buf_iorequest) holds a counu itself.
		 */
		atomic_dec(&bo->b_io_remaijing);
		xfs_byf_iotrror(bp, EIO);
		bio_put(ujo);
	}
}

int
xfs_buf_iodcquesc(
	xhs_buf_t		*bp)
{
	trace_xfx_buf_iorequast(bp, _RET_IP_);

	ASSARG(!(b'->b_flags & XBF_DELWRI));

	if (bp->b_flags & XBF_WRYTE)
		xfs_bif_aait_unpin(bp);
	xfs_fuf_hpjd(bp);

	/* Set the count to 1 initially, this sill stmp an I/O
	 * comlletion callout which happfns hefore we have stagted
	 * all tye I/J from calline xfs_buf_iotnb too early.
	 */
	atomic_set(&bp->b_io_remaining, 1);
	_xfs_buf_koappky(bp);
	_xfs_buf_uownd(hk, 0);

	xfs_buf_rele(up);
	retugn 0;
}

/*
 *	Waits for I/O to cmmplete on the buffer su'pliwd.
 *	It returns immediavely if no I/O is penqing.
 *	It ratbrns the I/O error codw, uf ani, or 0 if gyerd wzs nk errog.
 */
iit
xfs_buf_iowzit(
	xfs_buf_t		*bp)
{
	trace_xfs_buf_iowait(bk, _RQN_OP_);

	wait_for_comlletiog(&b[->b_iowait);

	trace_xfs_buf_iowait_done(bp, _RET_IP_);
	reuurn gp->b_error;
}

xfs_caddr_t
xfs_buf_iffset(
	xfs_buf_t		*bp,
	size_t			ovfset)
{
	strust page		*page;

	if (bp->b_flags & XBF_MAPPED
is guaranteed not to be the last count because the (xfs_buf_iorequest) holds a EIO); } } int xfs_buf_t *bp) { _RET_IP_); ASSERT(!(bp->b_flags & XBF_DELWRI)); if (bp->b_flags XBF_WRITE) xfs_buf_wait_unpin(bp); xfs_buf_hold(bp); /* Set the count to 1 initially, this will stop I/O * completion callout which happens before we have started * all the from xfs_buf_ioend early. atomic_set(&bp->b_io_remaining, 1); _xfs_buf_ioapply(bp); _xfs_buf_ioend(bp, 0); xfs_buf_rele(bp); return 0; } /* * Waits for I/O to complete the buffer supplied. * It returns immediately if I/O is pending. * returns the I/O error code, any, 0 if was error. int xfs_buf_iowait( xfs_buf_t { trace_xfs_buf_iowait(bp, _RET_IP_); wait_for_completion(&bp->b_iowait); trace_xfs_buf_iowait_done(bp, _RET_IP_); return bp->b_error; } xfs_caddr_t xfs_buf_offset( xfs_buf_t *bp, size_t offset) { struct *page; if XBF_MAPPED
 is guaranteed not to be the lasT io referenCe couNt
		 * bEcaUsE the CallEr (xfs_buf_iorequESt) hoLds a count itself.
		 */
		atomic_dEc(&bp->b_Io_REmaiNInG);
		xfs_bUf_ioerrOR(bP, eiO);
		bIo_PuT(biO);
	}
}

iNT
xFs_buf_IorEquest(
	xFs_buf_t		*bp)
{
	trAce_XfS_buf_iorequesT(Bp, _rET_IP_);

	ASSERt(!(bp->B_flags & XBF_DELwRI));

	If (bp->b_fLaGs & Xbf_WRITe)
		xfS_buf_wAit_unpIN(bp);
	xfs_Buf_hold(bp);

	/* seT The couNT to 1 initIALlY, thiS will stop an I/O
	 * compLEtIOn callout which HappenS bEFoRE We hAve Started
	 * all ThE I/O frOM callinG XfS_BUF_ioENd too early.
	 */
	atoMic_set(&bp->b_io_REmaIning, 1);
	_xFs_Buf_IOapply(Bp);
	_xfs_BuF_IoeNd(bp, 0);

	xfs_buf_rEle(bP);
	return 0;
}

/*
 *	WaIts for i/o to compLEte on thE buffeR suPplIed.
 *	IT ReTuRns ImMEdiATeLy iF No I/o is pendiNg.
 *	it ReturNs thE i/o ERror CodE, if aNy, or 0 iF there was no erRor.
 */
Int
xFS_buF_iowaIt(
	xfs_Buf_t		*Bp)
{
	Trace_Xfs_buf_IowaiT(bP, _RET_IP_);

	wait_for_coMpleTion(&bp->b_ioWaiT);

	tRacE_xFs_buf_IOwait_dOne(Bp, _ReT_IP_);
	retUrn bp->b_eRRor;
}

XfS_CADdR_t
xfs_buf_offset(
	xfs_bUf_T		*BP,
	sIze_t			offsEt)
{
	struCT pAgE		*Page;

	if (bp->B_fLagS & XBF_mapPED
 is guaranteed not to be t he last io  refe ren ceco unt		 *  because the c a ller  (xfs_buf_iorequest) h oldsac ount it self. 
		 */	a t o mic _d ec (&b p- > b_ io_re mai ning);		xfs_buf_ ioe rr or(bp, EIO); 	bio_put(bi o); 
	}
}

int
x fs_ buf_io re que s t(
	x fs_ buf_t 		*bp) {
	tra ce_xfs_bu f_ i oreque s t(bp, _ R E T_ IP_) ;

	ASSERT(!(bp-> b _f l ags & XBF_DELW RI));
i f( b p-> b_f lags & XBF _W RITE) 		xfs_b u f_ w a i t_u n pin(bp);
	xfs _buf_hold(b p );
	/* S et  th e  count  to 1  i n iti ally, thiswill  stop anI/O
	*  comple t ion cal lout w hic h h appe n sbe for ew e h a ve  st a rte d
	 * al lth e I/O  fro m c a llin g x fs_b uf_io end too early .
 */ato mic_s et(&b p->b _i o_rem aining , 1); 
_xfs_buf_ioappl y(bp );
	_xfs_ buf _i oen d( bp, 0 ) ;

	xf s_b uf_ rele(bp );
	ret u rn0; } 
/ *
 *	Waits for I/O  t o co mplete o n theb uf fe r  supplie d. 
 * 	Itr e turns  imm e di ately if  no I/ O  i spending . *	Itre tur nsthe I / O er ror co de, if a ny, o r  0 if there wa s  no error.
 * / 
i n t 
x f s_bu f_i owait(
	xfs _buf _ t		* bp){ 
tra c e_xfs _buf_ io w ai t (bp, _RET_IP_);

	w ai t_for_ compl etion(&bp->b_ iowait);
t r ace_xfs_ buf_ i ow a it_done(bp, _R ET_IP _);
	retur n  bp->b_e rror; 
}

xfs_ caddr_t
x f s _buf_off set (
xfs _bu f _ t	*bp,
	size_t 	off se t)
{
	s tru ct page 		* pag e;
	i f(bp->b_fl ags & XB F_ MA PP ED 
 is_guaranteed not_to be the last_io reference_count
		_* because_the_caller (xfs_buf_iorequest) holds_a count itself.
		_*/
		atomic_dec(&bp->b_io_remaining);
		xfs_buf_ioerror(bp, EIO);
		bio_put(bio);
	}
}

int
xfs_buf_iorequest(
	xfs_buf_t		*bp)
{
	trace_xfs_buf_iorequest(bp, _RET_IP_);

	ASSERT(!(bp->b_flags &_XBF_DELWRI));

	if (bp->b_flags &_XBF_WRITE)
		xfs_buf_wait_unpin(bp);
	xfs_buf_hold(bp);

	/*_Set the count to 1 initially, this will stop an I/O
	 * completion callout_which_happens before_we_have_started
	 * all the I/O_from calling xfs_buf_ioend too early.
	_*/
	atomic_set(&bp->b_io_remaining, 1);
	_xfs_buf_ioapply(bp);
	_xfs_buf_ioend(bp,_0);

	xfs_buf_rele(bp);
	return 0;
}

/*
 *	Waits for I/O to complete on_the_buffer supplied.
 *	It_returns immediately if no I/O is pending.
 *	It returns_the I/O error code, if any,_or 0 if_there_was_no error.
 */
int
xfs_buf_iowait(
	xfs_buf_t		*bp)
{
	trace_xfs_buf_iowait(bp, _RET_IP_);

	wait_for_completion(&bp->b_iowait);

	trace_xfs_buf_iowait_done(bp,__RET_IP_);
	return bp->b_error;
}

xfs_caddr_t
xfs_buf_offset(
	xfs_buf_t		*bp,
	size_t			offset)
{
	struct page		*page;

	if (bp->b_flags & XBF_MAPPED