xfs
[Top] [All Lists]

Re: disable preallocation

To: Iustin Pop <iusty@xxxxxxxxx>
Subject: Re: disable preallocation
From: Ming Zhang <mingz@xxxxxxxxxxx>
Date: Tue, 18 Apr 2006 17:54:45 -0400
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <20060418214252.GA3300@lapi.hq.k1024.org>
References: <1145391567.8601.183.camel@localhost.localdomain> <20060418214252.GA3300@lapi.hq.k1024.org>
Reply-to: mingz@xxxxxxxxxxx
Sender: linux-xfs-bounce@xxxxxxxxxxx
On Tue, 2006-04-18 at 23:42 +0200, Iustin Pop wrote:
> 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.

yes, xfs supports file hole. 

so about ext2, how to understand this in "understanding linux kernel"

"the file system preallocate disk data blocks to regular files before
they are actually used. thus, when the file increase in size, several
blocks are already reserved at physically adjacent positions, reducing
file fragmentation"

and also XFS has a preallocation ioctl control that can pre-allocate
some space for a file. so if that space is allocated, what will happen
on read these space with no previous write happen? it will be
troublesome for xfs to judge that space is preserved, but not used. that
is 2 independent lookup services and overheads.


> 
> > 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:
> 
> #!/usr/bin/python
> 
> f = file("test", "w+")
> f.seek(4096, 0)
> f.write("test")
> f.seek(0, 0)
> data = f.read(4096)
> if data != "\0" * 4096:
>     print "bad!"
> else:
>     print "ok"

i have a c program do this and so far return 0. but test can never mean
100%, right? only from xfs implementation logic can validate this.




> 
> And see what you get.
> 
> Regards,
> Iustin


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