seeking advice on sparse files on xfs

Joe Landman joe.landman at gmail.com
Wed Dec 19 19:30:58 CST 2012


On 12/19/2012 05:54 PM, Dave Chinner wrote:
> On Wed, Dec 19, 2012 at 05:17:45PM -0500, Joe Landman wrote:

[...]

>>    Pointers appreciated.  I am looking at the copy routines in
>> coreutils now, looking to see if we can increase its intelligence
>> somewhat w.r.t. sparse files.
>
> Here's a good overview of the state of play:
>
> http://www.linuxplumbersconf.org/2012/wp-content/uploads/2012/08/sparse-improvements-LPC-2012.pdf
>

I git cloned the coreutils to look at current state of the code, and saw 
exactly what is represented on slide 14.

"Brute force – read each sector in full, before
skipping while writing the copy"

There has to be a better way.

> And what you really want is a version of cp that supports these:
>
> $ man lseek
> ....
>     Seeking file data and holes
>         Since version 3.1, Linux supports the following additional
>         values for whence:
>
>         SEEK_DATA
> 	      Adjust  the  file  offset to the next location in the
> 	      file greater than or equal to offset containing data.
> 	      If offset points to data, then the file offset is set
> 	      to offset.
>
>         SEEK_HOLE
> 	      Adjust the file offset to the next hole in the file
> 	      greater than or equal to offset.  If offset points
> 	      into the middle of a hole, then the file offset  is
> 	      set to offset.  If there is no hole past offset, then
> 	      the file offset is adjusted to the end of the file
> 	      (i.e., there is an implicit hole at the end of any
> 	      file).
> .....

Something akin to this.  Actually would like to be able to have it pull 
bmap data so that reading over a file only reads populated extents, so 
that anything that is not populated is nulled out by definition.  I am 
guessing that these are the abstraction above bmap type data?

>
> I'm pretty sure coreutils support is in the pipeline right now....

Hopefully, but it doesn't appear to be in the repository I cloned.  :(

Was thinking of hacking something up at a much higher level (cheating by 
parsing bmap data and stuff like that).

>
> Cheers,
>
> Dave.
>

Thanks for the pointers.  If I come up with anything marginally useful 
prior to the SEEK_{HOLE,DATA} implementation, I'll update.

--
Joe



More information about the xfs mailing list