On Tue, Apr 18, 2006 at 04:19:27PM -0400, Ming Zhang wrote:
> Hi folks,
> I checked the archive and found some discussion about how to do
> pre-allocation. Interestingly, my questions is how to disable the
> pre-allocation. What I want is no matter how much data I write to XFS,
> as long as the size are multiple of file system block size, the fs will
> not preallocate some blocks for me. Because if fs does not do
> pre-allocation, later I read the block that no previous written data, it
> can give me all 0, otherwise it might be some strange data.
> I am dumping many huge sparse martrix to disk and if that whole block is
> full of 0, i will not write it to disk at all, so have a hole there.
if you have a hole (i.e. you seek-ed over the block), any filesystem
that supports holes will not allocate the block on disk, and will return
0 on read. if the filesystem does not support holes, it will write a
block full of 0, I think.
> later when read back, i want to get all 0 as well. if fs do
> preallocation, then i probably will get some random data.
No, as far as I know XFS will never return random data. Try it and see.
> I found that ext2/3 will do pre-allocation. will xfs do it or not?
Yes, but it will not return random data from disk, but 0.
If you have python installed, try this simple program:
f = file("test", "w+")
data = f.read(4096)
if data != "\0" * 4096:
And see what you get.