]> xenbits.xensource.com Git - libvirt.git/commit
virstoragefile: Have virStorageFileResize use safezero
authorJohn Ferlan <jferlan@redhat.com>
Mon, 8 Dec 2014 13:06:57 +0000 (08:06 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 16 Dec 2014 18:11:35 +0000 (13:11 -0500)
commit18f03166fd8a7864f18b329e237f26b132f6e0e2
tree89bba31ad7bd625b119f1ef6bc1578bb95a5885d
parent214c687b978d876e40dd962c48c90f8f0e45009f
virstoragefile: Have virStorageFileResize use safezero

Currently virStorageFileResize() function uses build conditionals to
choose either the posix_fallocate() or syscall(SYS_fallocate) with no
fallback in order to preallocate the space in the newly resized file.

Since the safezero code has a similar set of conditionals modify the
resize and safezero code in order to allow the resize logic to make use
of safezero to unify the look/feel of the code paths.

Add a new boolean (resize) to safezero() to make the optional decision
whether to try syscall(SYS_fallocate) if the posix_fallocate fails because
HAVE_POSIX_FALLOCATE is not defined (eg, return -1 and errno == 0).

Create a local safezero_sys_fallocate in order to handle the resize
code paths that support that.  If not present, the set errno = ENOSYS
in order to allow the caller to handle the failure scenarios.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/locking/lock_driver_sanlock.c
src/storage/storage_backend.c
src/util/virfile.c
src/util/virfile.h
src/util/virstoragefile.c