Subject: Re: hexdumping large sparce files
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 01/25/2003 08:41:33
On Sat, Jan 25, 2003 at 02:47:18PM +0900, Curt Sampson wrote:
> On Fri, 24 Jan 2003, Bill Studenmund wrote:
>
> > On Fri, 24 Jan 2003, David Laight wrote:
> >
> > > For instance I would like to be able to verify the non-zero parts of
> > > the following [large] file...
> > > without actually transferring 14Gb of data from kernel to user.
> > > (and maybe without filling all of physical memory with 0 bytes).
> >
> > No. Our (and I believe POSIX) file semantics don't permit it.
I had a feeling I'd never seen anything to do it!
There could be something done with ioctl/fcntl a bit like the way of
making a file sparse (I can't remember the command off hand).
> What does mmap do with holes in files? I've got this weird idea that you
> might be able to map all of the holes that cover complete pages to a
> single physical page filled with zeros that's marked copy-on-write, so
> you could read it for only the cost of the memory access. (And even that
> could be dirt, dirt cheap if you happen to have a physically-addressed
> cache.)
That certainly ought to be possible, but the figures from 'systat vmstat'
seemed to imply it wasn't happening. mmap of /dev/zero probably does
just up the ref count on a single page though.
In this case you wold need page loaning on file read though...
> Or did I take one too many hits from the crack pipe before coming up
> with this? :-)
All the best ides come that way.
David
--
David Laight: david@l8s.co.uk