Re: [PATCH 3/5] xfs: fix off-by-one error in rtbitmap cross-reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 11, 2019 at 10:10:54AM -0500, Brian Foster wrote:
> On Tue, Jan 08, 2019 at 12:36:23PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > 
> > Fix an off-by-one error in the realtime bitmap "is used" cross-reference
> > helper function.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > ---
> >  fs/xfs/scrub/rtbitmap.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > 
> > diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
> > index 665d4bbb17cc..5402211f980b 100644
> > --- a/fs/xfs/scrub/rtbitmap.c
> > +++ b/fs/xfs/scrub/rtbitmap.c
> > @@ -143,7 +143,7 @@ xchk_xref_is_used_rt_space(
> >  	do_div(startext, sc->mp->m_sb.sb_rextsize);
> >  	if (do_div(endext, sc->mp->m_sb.sb_rextsize))
> >  		endext++;
> > -	extcount = endext - startext;
> > +	extcount = endext - startext + 1;
> 
> I'm not terribly familiar with rt code, but isn't the above endext++
> also rounding this up in some cases?

Yep.  Sorry for the drain bamage, this ought to be:

	startext = fsbno;
	endext = fsbno + len - 1;
	do_div(startext, sc->mp->m_sb.sb_rextsize);
	do_div(endext, sc->mp->m_sb.sb_rextsize);
	extcount = endext - startext + 1;

--D

> Brian
> 
> >  	xfs_ilock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
> >  	error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, startext, extcount,
> >  			&is_free);
> > 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux