[libvirt] [PATCH v2 1/3] virfile: Refactor safezero, introduce virFileFdPosixFallocate

John Ferlan jferlan at redhat.com
Fri Aug 22 14:56:47 UTC 2014



On 08/22/2014 10:46 AM, Daniel P. Berrange wrote:
> On Mon, Aug 11, 2014 at 04:30:19PM -0400, John Ferlan wrote:
>> Currently the safezero() function uses build conditionals to choose either
>> the posix_fallocate() or mmap() with a fallback to safewrite() in order to
>> preallocate a file.
>>
>> This patch will modify the logic in order to allow fallbacks in the
>> event that posix_fallocate() or the ftruncate()and mmap() doesn't work
>> properly. The fallback will be to use the slow safewrite of zero filled
>> buffers to the file.
> 
> Have you actually encountered failing of posix_fallocate() in the
> real world ?  It is supposed to automatically fallback to the
> equivalent of writing zeros if the filesystem / kernel does not
> support it, so we should not have todo runtime fallback ourselves.
> The existance of fallback is the main distinction between the
> posix_fallocate() and fallocate() system calls.
> 

It wasn't so much as a "failure" as "unexpected results" - the key being
that the resulting created (or resized) file was not sized as expected.

For an NFS target the results are not what was expected.  I've left some
history in the prior set of patches with the following probably having
the most details:

http://www.redhat.com/archives/libvir-list/2014-August/msg00367.html

As for real world - this bug came as a result of a virt-test test which
was going through all the various sizes/options and found this result to
be incorrect - at least in the eyes of the tester.


John




More information about the libvir-list mailing list