@@ -0,0 +1,95 @@
1+diff --git a/block/gluster.c b/block/gluster.c
2+index 01b479fbb9..29552e1186 100644
3+--- a/block/gluster.c
4++++ b/block/gluster.c
5+@@ -15,6 +15,10 @@
6+ #include "qemu/uri.h"
7+ #include "qemu/error-report.h"
8+
9++#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT
10++# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL)
11++#endif
12++
13+ #define GLUSTER_OPT_FILENAME "filename"
14+ #define GLUSTER_OPT_VOLUME "volume"
15+ #define GLUSTER_OPT_PATH "path"
16+@@ -613,7 +617,11 @@ static void qemu_gluster_complete_aio(void *opaque)
17+ /*
18+ * AIO callback routine called from GlusterFS thread.
19+ */
20+-static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
21++static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
22++#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT
23++ struct glfs_stat *pre, struct glfs_stat *post,
24++#endif
25++ void *arg)
26+ {
27+ GlusterAIOCB *acb = (GlusterAIOCB *)arg;
28+
29+diff --git a/configure b/configure
30+index 4b808f9d17..89fb27fd0d 100755
31+--- a/configure
32++++ b/configure
33+@@ -301,6 +301,8 @@ glusterfs=""
34+ glusterfs_xlator_opt="no"
35+ glusterfs_discard="no"
36+ glusterfs_zerofill="no"
37++glusterfs_ftruncate_has_stat="no"
38++glusterfs_iocb_has_stat="no"
39+ archipelago="no"
40+ gtk=""
41+ gtkabi=""
42+@@ -3444,6 +3446,38 @@ if test "$glusterfs" != "no" ; then
43+ if $pkg_config --atleast-version=6 glusterfs-api; then
44+ glusterfs_zerofill="yes"
45+ fi
46++ cat > $TMPC << EOF
47++#include <glusterfs/api/glfs.h>
48++
49++int
50++main(void)
51++{
52++ /* new glfs_ftruncate() passes two additional args */
53++ return glfs_ftruncate(NULL, 0, NULL, NULL);
54++}
55++EOF
56++ if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
57++ glusterfs_ftruncate_has_stat="yes"
58++ fi
59++ cat > $TMPC << EOF
60++#include <glusterfs/api/glfs.h>
61++
62++/* new glfs_io_cbk() passes two additional glfs_stat structs */
63++static void
64++glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
65++{}
66++
67++int
68++main(void)
69++{
70++ glfs_io_cbk iocb = &glusterfs_iocb;
71++ iocb(NULL, 0 , NULL, NULL, NULL);
72++ return 0;
73++}
74++EOF
75++ if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
76++ glusterfs_iocb_has_stat="yes"
77++ fi
78+ else
79+ if test "$glusterfs" = "yes" ; then
80+ feature_not_found "GlusterFS backend support" \
81+@@ -5415,6 +5449,14 @@ if test "$archipelago" = "yes" ; then
82+ echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
83+ fi
84+
85++if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
86++ echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
87++fi
88++
89++if test "$glusterfs_iocb_has_stat" = "yes" ; then
90++ echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
91++fi
92++
93+ if test "$libssh2" = "yes" ; then
94+ echo "CONFIG_LIBSSH2=m" >> $config_host_mak
95+ echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak