[libvirt] [PATCH v2 3/3] virstoragefile: Refactor virStorageFileResize
John Ferlan
jferlan at redhat.com
Fri Aug 22 14:41:09 UTC 2014
On 08/22/2014 10:32 AM, Ján Tomko wrote:
> On 08/21/2014 06:51 PM, John Ferlan wrote:
>>
>>
<...snip...>
>> Hmm.. Perhaps a better way to do this would be to modify safezero() to
>> add a 4th boolean parameter "resize" and make the "safezero_mmap()" be
>> the false side and the check/call to SYS_fallocate() be the true side.
>> That way all the logic resides in virfile.c
>
> How about 'fallback_to_mmap' instead of resize?
>
> Or even simpler, we don't really need a different set of fallbacks for resize
> than the other uses. It seems the patch adding the preallocation to FileResize
> should have used safezero instead of reimplementing it.
>
> (I also wonder if there are systems without posix_fallocate, but having the
> syscall...)
>
> 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);
> }
OK - I'll do this (although since virFileFdPosixFallocate only needs to
be local now, I'll rename it to safezero_posix_fallocate() and make it
static to the module as well as removing it from libvirt_private.syms).
John
More information about the libvir-list
mailing list