]> xenbits.xensource.com Git - libvirt.git/commit
virfile: Refactor safezero
authorJohn Ferlan <jferlan@redhat.com>
Fri, 5 Dec 2014 21:18:29 +0000 (16:18 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 16 Dec 2014 18:11:35 +0000 (13:11 -0500)
commit214c687b978d876e40dd962c48c90f8f0e45009f
tree6499b8bdeede4202d2c59e5465769df8ac0f824f
parentfeb1a4d792e1c35b1009e69c00bf351b39fe666b
virfile: Refactor safezero

Currently build conditionals decide which of two safezero() functions
should be built - either the posix_fallocate() or mmap() with a fallback
to a slower safewrite() algorithm in order to preallocate space in a raw file.

This patch will refactor safezero to utilize static functions for either
posix_fallocate or mmap/safewrite. The build conditional still exist, but
are only for shorter sections of code.

The posix_fallocate path will make use of the ret/errno setting to contain
the logic for safezero to decide whether it needs to fallback to other
algorithms. A return of -1 with errno not changed will indicate the conditional
is not present; otherwise, a return of -1 with errno change indicates the
call was made and it failed (no functional difference to current algorithm).

The mmap/safewrite option changes only slightly to handle the ftruncate
failure for mmap. That is, previously if the ftruncate failed, there was
no fallback to the slow safewrite option.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virfile.c