[libvirt] [PATCH v2 3/3] virstoragefile: Refactor virStorageFileResize

Daniel P. Berrange berrange at redhat.com
Fri Aug 22 14:41:28 UTC 2014


On Fri, Aug 22, 2014 at 04:32:09PM +0200, Ján Tomko wrote:
> On 08/21/2014 06:51 PM, John Ferlan wrote:
> ACK to safezero implementation with all four methods:
> 
> int
> safezero(int fd, off_t offset, off_t len)
> {
>     if (virFileFdPosixFallocate(fd, offset, len) == 0)
>         return 0;
>     if (safezero_sys_fallocate(fd, offset, len) == 0)
>         return 0;
>     if (safezero_mmap(fd, offset, len) == 0)
>         return 0;
>     return safezero_slow(fd, offset, len);
> }

Huh, why would we want todo that ?  safezero() will always use the
posix_fallocate() function if it exists at build time, otherwise it
will be built for mmap, or even write(). If posix_fallocate() is used,
it will try the fast allocation strategy and fallback to manually
filling with zeros if not available without libvirt needing todo the
fallback itself. So we don't need to do any of this dynamically
fallback at runtime - just use safezero() as it exists today.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list