qemu-img: Truncate before full preallocation
commit5a1dad9d5a5777c4883de78d9f35bd8141175798
authorNir Soffer <nirsof@gmail.com>
Fri, 17 Feb 2017 00:51:26 +0000 (17 02:51 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 24 Feb 2017 15:09:23 +0000 (24 16:09 +0100)
treea11964dfe24dbc4c7ef5fdc6c34abc4de325b187
parent6f993f3fca4763a6b494ff587d4400b6e8a5ef31
qemu-img: Truncate before full preallocation

In a previous commit (qemu-img: Do not truncate before preallocation) we
moved truncate to the PREALLOC_MODE_OFF branch to avoid slowdown in
posix_fallocate().

However this change is not optimal when using PREALLOC_MODE_FULL, since
knowing the final size from the beginning could allow the file system
driver to do less allocations and possibly avoid fragmentation of the
file.

Now we truncate also before doing full preallocation.

Signed-off-by: Nir Soffer <nirsof@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/file-posix.c