Blob Blame History Raw
From b5c74112b314c185335de246c465d14ef68509a3 Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <mlevitsk@redhat.com>
Date: Sun, 16 Feb 2020 16:02:24 +0100
Subject: [PATCH 4/6] gluster: Handle changed glfs_ftruncate signature

Message-id: <20200216160225.22498-2-mlevitsk@redhat.com>
Patchwork-id: 93881
O-Subject: [RHEL-7.9 qemu-kvm PATCH 1/2] gluster: Handle changed glfs_ftruncate signature
Bugzilla: 1802215
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>

From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>

New versions of Glusters libgfapi.so have an updated glfs_ftruncate()
function that returns additional 'struct stat' structures to enable
advanced caching of attributes. This is useful for file servers, not so
much for QEMU. Nevertheless, the API has changed and needs to be
adopted.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit e014dbe74e0484188164c61ff6843f8a04a8cb9d)
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

RHEL: fixed conflicts
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 block/gluster.c |  5 +++++
 configure       | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/block/gluster.c b/block/gluster.c
index 86e136d..d6160af 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -20,6 +20,11 @@
 #include "qemu/sockets.h"
 #include "qemu/uri.h"
 
+#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT
+# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL)
+#endif
+
+
 typedef struct GlusterAIOCB {
     BlockDriverAIOCB common;
     int64_t size;
diff --git a/configure b/configure
index 5877e82..70fd06f 100755
--- a/configure
+++ b/configure
@@ -243,6 +243,7 @@ seccomp=""
 glusterfs=""
 glusterfs_discard="no"
 virtio_blk_data_plane=""
+glusterfs_ftruncate_has_stat="no"
 gtk=""
 gtkabi="2.0"
 tpm="no"
@@ -2748,6 +2749,19 @@ EOF
     if $pkg_config --atleast-version=5 glusterfs-api >/dev/null 2>&1; then
       glusterfs_discard="yes"
     fi
+    cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+int
+main(void)
+{
+	/* new glfs_ftruncate() passes two additional args */
+	return glfs_ftruncate(NULL, 0, NULL, NULL);
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_ftruncate_has_stat="yes"
+    fi
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support"
@@ -4178,6 +4192,10 @@ if test "$live_block_ops" = "yes" ; then
   echo "CONFIG_LIVE_BLOCK_OPS=y" >> $config_host_mak
 fi
 
+if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
+fi
+
 if test "$live_block_migration" = "yes" ; then
   echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
 fi
-- 
1.8.3.1