On RHEL 7.5 we need to include <linux/falloc.h> for FALLOC_FL_* macros.
Without the macros, fallocate is never used and we fall back to manual
zeroing.
Here are examples runs with this change with a local file on ext4:
$ export SOCK=/tmp/nbd.sock
$ export FILE=/var/tmp/nbd.img
$ export BLOCK=/dev/loop2
$ src/nbdkit -f 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:$SOCK
real 0m13.361s
user 0m0.127s
sys 0m0.668s
$ src/nbdkit -f plugins/file/.libs/nbdkit-file-plugin.so file=$BLOCK -U $SOCK
$ time qemu-img convert -n -f raw -O raw /var/tmp/fedora-27.img nbd:unix:$SOCK
real 0m13.491s
user 0m0.129s
sys 0m0.612s
---
plugins/file/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/file/file.c b/plugins/file/file.c
index 4210adb..fb20622 100644
--- a/plugins/file/file.c
+++ b/plugins/file/file.c
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
+#include <linux/falloc.h> /* For FALLOC_FL_* on RHEL, glibc < 2.18 */
#include <nbdkit-plugin.h>
--
2.17.1