[libvirt] [PATCH option 1] Use fallocate directly if possible

Jiri Denemark jdenemar at redhat.com
Wed Mar 3 07:44:35 UTC 2010

> If fallocate() is present, use it directly instead of posix_allocate().
> If it is not support by the kernel or filesystem, emulate it using
> mmap() or write().
> This change is to work around slow fallocate emulation done by glibc's
> posix_allocate() when used on files opened with O_DSYNC.

Hmm, there is a dark side of this patch. Since fallocate is not portable, we
use posix_fallocate in case fallocate is not available. Although this could
happen because another system call with similar semantics exists, it can also
happen on older linux distributions where there is no equivalent of fallocate
call. And in such distributions (RHEL5 being one example), this patch will
make no functional change. So either we could sacrifice portability by not
using posix_fallocate at all or come up with something else. Or use the patch
from option 2.


More information about the libvir-list mailing list