[Gllug] Filesystem Holes

Jim Cheetham jim at gonzul.net
Mon Oct 8 11:18:30 UTC 2001


On Mon, Oct 08, 2001 at 11:33:35AM +0100, t.clarke wrote:
> Re further comments on filesystem holes;
> 
> not sure I can make sense of the explanations given !

Well, my understanding of a hole'd data file is slightly different :-)
I've not heard the term before, but suspect that they are a synonym
for sparse files ...
I don't think that the file system will automagically decide not to
store "0" characters by effectively compressing them down ... if you
write data to a file, that data is definately written. Zeros are just
as significant as any other bit pattern ... :-)

However, if you open/creat a data file, and then seek a long 
way (a few blocks down the file should suffice), and THEN write
some data (think, database storage files), the system has the
opportunity to not populate the earlier blocks in your file, because
they are undefined/have never contained data. Your data file is
now a "sparse" file, and occupies less blocks on the disk than
the directory entry (for length) indicates. A read() for any of
these sparse areas in the file will return zeros ... although no
actual disk access occurs.

I'm not sure I appreciate sparse files ... they can cause some
interesting problems. Your file system is healthly empty, and
you decide to cp(1) a sparse file ... all of a sudden, the fs is
overfull! How did that happen? Well ... cp() reads all these
sparse "blocks" and gets handed a load of "000000000"s for it's
trouble ... which it then merrily writes back to the new file,
thus turning sparse blocks into real blocks ... and filling
your disk ...

> 
> Just out of interest i catted /dev/zero to a file and took note of
> the before and after filesystem 'df' statistics:
> 
> Before:  used 208792  free 263335
> file size created 73310208
> After:   used 280667  free 191460
> 
> Can't obviously say whether anything was physically written to the disc,
> but the space certainly appears to have been allocated !
> 
>             Tim
> 
> -- 
> Gllug mailing list  -  Gllug at linux.co.uk
> http://list.ftech.net/mailman/listinfo/gllug

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list