Re: How to generate a large file allocating space

Alex Bligh <[email protected]>
Newsgroups gmane.comp.file-systems.ext3.user
Message-ID <[email protected]>
Matija,

--On 31 October 2010 17:19:49 +0100 Matija Nalis <[email protected]> 
wrote:

> Well, some metadata will have to be written, but not data.
> shouldn't posix_fallocate(3) and/or fallocate(2) do that?
>
> I haven't got EXT4 around ATM, but IIRC it should work on it too.
> On XFS it seems to work too:

That's /almost/ perfect:

$ fallocate -l 1073741824 testfile
$ filefrag -v testfile
Filesystem type is: ef53
File size of testfile is 1073741824 (262144 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0 14819328           30720 unwritten
   1   30720 14850048           30720 unwritten
   2   61440 14880768           30720 unwritten
   3   92160 14911488           30720 unwritten
   4  122880 14942208            2048 unwritten
   5  124928 14946304 14944255  30720 unwritten
   6  155648 14977024           30720 unwritten
   7  186368 15007744           30720 unwritten
   8  217088 15038464           30720 unwritten
   9  247808 15069184           14336 unwritten,eof
testfile: 2 extents found

I think all I need do is clear the unwritten flag in each of the extents.
Else I think if I read the file using ext4 later (i.e. after I've
written directly to the sectors concerned) it will appear to be
empty. Any idea how I do that?

-- 
Alex Bligh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.