#649913 Please use posix_fallocate

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
Goswin von Brederlow
Date:
2011-11-25 09:42:13 UTC
Severity:
normal
#649913#5
Date:
2011-11-24 19:18:43 UTC
From:
To:
Hi,

when copying files the size of the resulting file is known (except in
race conditions) beforehand and should be communicated to the
filesystem using posix_fallocate(). This ensures there is enough space
for the file and more importantly allows the filesystem to place the
file better, idealy as on continious chunk, on the filesystem.

Some care must be taken to ftruncate() the file to its smaller size if
the source file has shrunk while copying.

If the file has grown while copying one could posix_fallocate() to the
new size repeadately till the full file is copied but it probably
wouldn't hurt to ignore that case and just copy the remainder of the
grown file without allocating space first.

MfG
	Goswin

#649913#10
Date:
2011-11-24 19:47:50 UTC
From:
To:
Goswin von Brederlow wrote:

In upstream discussion, Pádraig Brady just wrote about precisely that:

http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/23023/focus=23409

#649913#15
Date:
2011-11-25 09:38:13 UTC
From:
To:
Jim Meyering <jim@meyering.net> writes:

As a side note: This also applies to dd and might be much simpler to
handle there since dd never uses sparse files. Dd should use fallocate()
at least whenever it has a "count=xxx".

MfG
        Goswin