Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
file: Support zero without ZERO_RANGE
File systems not supporting FALLOC_FL_ZERO_RANGE yet fall back to manual
zeroing.
We can avoid this by combining two fallocate calls:
fallocate(FALLOC_FL_PUNCH_HOLE)
fallocate(0)
Based on my tests this is much more efficient compared to manual
zeroing. The idea came from this qemu patch:
qemu/qemu@1cdc3239f1bb
Here is an example run with NFS 4.2 without this change, converting
fedora 27 image created with virt-builder:
$ export SOCK=/tmp/nbd.sock
$ export FILE=/nfs-mount/fedora-27.img
$ src/nbdkit plugins/file/.libs/nbdkit-file-plugin.so file=$FILE -U $SOCK
$ time qemu-img convert -n -f raw -O raw /var/tmp/fedora-27.img nbd:unix:/tmp/nbd.sock
real 0m17.481s
user 0m0.199s
sys 0m0.691s
$ time qemu-img convert -n -f raw -O raw -W /var/tmp/fedora-27.img nbd:unix:/tmp/nbd.sock
real 0m17.072s
user 0m0.191s
sys 0m0.738s
With this change:
$ time qemu-img convert -n -f raw -O raw /var/tmp/fedora-27.img nbd:unix:/tmp/nbd.sock
real 0m6.285s
user 0m0.217s
sys 0m0.829s
$ time qemu-img convert -n -f raw -O raw -W /var/tmp/fedora-27.img nbd:unix:/tmp/nbd.sock
real 0m3.967s
user 0m0.193s
sys 0m0.702s
Note: the image is sparse, but nbdkit creates a fully allocated image.
This may be a bug in nbdkit or qemu-img.
Message-Id: <20180819165655.21785-3-nsoffer@redhat.com>- Loading branch information