xfs
[Top] [All Lists]

Re: [PATCH] Introduce SEEK_DATA/SEEK_HOLE support to XFS V1

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH] Introduce SEEK_DATA/SEEK_HOLE support to XFS V1
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 21 Nov 2011 09:34:18 +1100
Cc: Jeff Liu <jeff.liu@xxxxxxxxxx>, aelder@xxxxxxx, Chris Mason <chris.mason@xxxxxxxxxx>, xfs@xxxxxxxxxxx
In-reply-to: <20111120153013.GA19199@xxxxxxxxxxxxx>
References: <4E887D7F.2010306@xxxxxxxxxx> <20111114102444.GA27791@xxxxxxxxxxxxx> <4EC10DE8.6030607@xxxxxxxxxx> <20111114125044.GA9802@xxxxxxxxxxxxx> <4EC768F5.4050904@xxxxxxxxxx> <4EC76AB9.9030604@xxxxxxxxxx> <20111120003031.GM7046@dastard> <4EC907C3.7020901@xxxxxxxxxx> <20111120153013.GA19199@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Sun, Nov 20, 2011 at 10:30:13AM -0500, Christoph Hellwig wrote:
> On Sun, Nov 20, 2011 at 09:59:31PM +0800, Jeff Liu wrote:
> > >           fsb = XFS_B_TO_FSBT(mp, start_offset);
> > >           error = xfs_bmap_first_unused(NULL, ip, 1, &fsb,
> > >                                           XFS_DATA_FORK);
> > >           if (error)
> > >                   return -error;
> > > 
> > >           if (fsb <= XFS_B_TO_FSBT(mp, start_offset))
> > >                   return start_offset;
> > >           return XFS_FSB_TO_B(mp, fsb);
> > 
> > Thanks for pointing it out, I even don't know XFS has this convenient 
> > routine at that time. :(
> 
> I didn't remember it either, but Dave has been working the dir code
> which makes use of this funtion lately :)
> 
> Btw, the documentation for the function doesn't mention that it starts
> searching for the hole only after the passed in block number, which
> is something that could be improved.

Definitely. 

A bit of code archeology shows that the location of the hole was
originally the return value of the function, then it got moved to a
function parameter so that the return value could be used for error
status (1995). Then the parameter go changed to be used as the first
block to start searching from when the dir2 code was introduced in
1999. So it's been wrong for quite some time ;)

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>