Skip to contentSkip to conversation

block: Gluster 6 compatibility

PATCH Applied Niels de Vos 3 participants 8 messages Mar 5, 2019 – Mar 11, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

v2 cover block: Gluster 6 compatibility

Gluster 6 is currently available as release candidate. There have been a few changes to libgfapi.so that need to be adapted by consuming projects like QEMU. Fedora Rawhide already contains glusterfs-6.0-RC0, and this prevents rebuilds of QEMU there (https://bugzilla.redhat.com/1684298).

The following two changes should be sufficient to consume Gluster 6 once it is released. These have been tested on CentOS-7 with Gluster 5 and Gluster 6 (minimal manual qemu-img tests only).

This v2 post contains changes suggested by Daniel P. Berrangé and Kevin Wolf. Thanks!

Cheers,
Niels

Niels de Vos (2):
block/gluster: Handle changed glfs_ftruncate signature
gluster: the glfs_io_cbk callback function pointer adds pre/post stat
args

 block/gluster.c | 17 ++++++++++++++---
 configure       | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v5 1/2 block/gluster: Handle changed glfs_ftruncate signature

From: Prasanna Kumar Kalever <[email protected]>

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.

--
v5: pass default NULL arguments through macro (Daniel P. Berrangé)
v4: rebase to current master branch
v3: define old backwards compatible glfs_ftruncate() macro, from Eric Blake
v2: do a compile check as suggested by Eric Blake

---
 block/gluster.c |  4 ++++
 configure       | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)
block/gluster.c +4 -0
index af64330211..f853aa87f4 100644
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
 
+#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT
+# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL)
+#endif
+
 #define GLUSTER_OPT_FILENAME        "filename"
 #define GLUSTER_OPT_VOLUME          "volume"
 #define GLUSTER_OPT_PATH            "path"
configure +18 -0
index cefeb8fcce..bbfe587b88 100755
@@ -456,6 +456,7 @@ glusterfs_xlator_opt="no"
 glusterfs_discard="no"
 glusterfs_fallocate="no"
 glusterfs_zerofill="no"
+glusterfs_ftruncate_has_stat="no"
 gtk=""
 gtk_gl="no"
 tls_priority="NORMAL"
@@ -4083,6 +4084,19 @@ if test "$glusterfs" != "no" ; then
       glusterfs_fallocate="yes"
       glusterfs_zerofill="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" \
@@ -6885,6 +6899,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
   echo "CONFIG_GLUSTERFS_ZEROFILL=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 "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=m" >> $config_host_mak
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
Signature · 1 line
2.20.1
Reviewed-by on v5 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v5 1/2] block/gluster: Handle changed glfs_ftruncate signature

Hi Niels,

Quoted 8 lines · Niels de Vos

From: Prasanna Kumar Kalever <[email protected]>

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.

Quoted 8 lines

--
v5: pass default NULL arguments through macro (Daniel P. Berrangé)
v4: rebase to current master branch
v3: define old backwards compatible glfs_ftruncate() macro, from Eric Blake
v2: do a compile check as suggested by Eric Blake

to avoid to record these information in the commit message, you should use 3 dashes or move these lines after the 3 dashes below.

Quoted 67 lines
---
 block/gluster.c |  4 ++++
 configure       | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)
block/gluster.c +4 -0
index af64330211..f853aa87f4 100644
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
 
+#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT
+# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL)
+#endif
+
 #define GLUSTER_OPT_FILENAME        "filename"
 #define GLUSTER_OPT_VOLUME          "volume"
 #define GLUSTER_OPT_PATH            "path"
configure +18 -0
index cefeb8fcce..bbfe587b88 100755
@@ -456,6 +456,7 @@ glusterfs_xlator_opt="no"
 glusterfs_discard="no"
 glusterfs_fallocate="no"
 glusterfs_zerofill="no"
+glusterfs_ftruncate_has_stat="no"
 gtk=""
 gtk_gl="no"
 tls_priority="NORMAL"
@@ -4083,6 +4084,19 @@ if test "$glusterfs" != "no" ; then
       glusterfs_fallocate="yes"
       glusterfs_zerofill="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" \
@@ -6885,6 +6899,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
   echo "CONFIG_GLUSTERFS_ZEROFILL=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 "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=m" >> $config_host_mak
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
Signature · 1 line
2.20.1

The patch LGTM.

Thanks,
Stefano

#3 lore raw

PATCH v2 2/2 gluster: the glfs_io_cbk callback function pointer adds pre/post stat args

In reply to Niels de Vos

The glfs_*_async() functions do a callback once finished. This callback has changed its arguments, pre- and post-stat structures have been added. This makes it possible to improve caching, which is useful for Samba and NFS-Ganesha, but not so much for QEMU. Gluster 6 is the first release that includes these new arguments.

With an additional detection in ./configure, the new arguments can conditionally get included in the glfs_io_cbk handler.

--
v2: correct typo in commit message (Kevin Wolf)

---
 block/gluster.c |  6 +++++-
 configure       | 24 ++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
block/gluster.c +5 -1
index f853aa87f4..51f184cbd8 100644
@@ -729,7 +729,11 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
 /*
  * AIO callback routine called from GlusterFS thread.
  */
-static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
+static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
+#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT
+                                 struct glfs_stat *pre, struct glfs_stat *post,
+#endif
+                                 void *arg)
 {
     GlusterAIOCB *acb = (GlusterAIOCB *)arg;
 
configure +24 -0
index bbfe587b88..db548d9b08 100755
@@ -457,6 +457,7 @@ glusterfs_discard="no"
 glusterfs_fallocate="no"
 glusterfs_zerofill="no"
 glusterfs_ftruncate_has_stat="no"
+glusterfs_iocb_has_stat="no"
 gtk=""
 gtk_gl="no"
 tls_priority="NORMAL"
@@ -4097,6 +4098,25 @@ EOF
     if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
       glusterfs_ftruncate_has_stat="yes"
     fi
+    cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+/* new glfs_io_cbk() passes two additional glfs_stat structs */
+static void
+glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
+{}
+
+int
+main(void)
+{
+	glfs_io_cbk iocb = &glusterfs_iocb;
+	iocb(NULL, 0 , NULL, NULL, NULL);
+	return 0;
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_iocb_has_stat="yes"
+    fi
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support" \
@@ -6903,6 +6923,10 @@ if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
   echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
 fi
 
+if test "$glusterfs_iocb_has_stat" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+fi
+
 if test "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=m" >> $config_host_mak
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
Signature · 1 line
2.20.1
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] gluster: the glfs_io_cbk callback function pointer adds pre/post stat args

Quoted 6 lines · Niels de Vos

The glfs_*_async() functions do a callback once finished. This callback has changed its arguments, pre- and post-stat structures have been added. This makes it possible to improve caching, which is useful for Samba and NFS-Ganesha, but not so much for QEMU. Gluster 6 is the first release that includes these new arguments.

Quoted 7 lines

With an additional detection in ./configure, the new arguments can conditionally get included in the glfs_io_cbk handler.

--
v2: correct typo in commit message (Kevin Wolf)

Also here, please use 3 dashes or move below.

Quoted 10 lines
---
 block/gluster.c |  6 +++++-
 configure       | 24 ++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
block/gluster.c +0 -0
index f853aa87f4..51f184cbd8 100644

block/gluster.c static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf, · line 736

Quoted 9 lines
block/gluster.c +5 -1
@@ -729,7 +729,11 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
 /*
  * AIO callback routine called from GlusterFS thread.
  */
-static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
+static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
+#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT
+                                 struct glfs_stat *pre, struct glfs_stat *post,
+#endif
+                                 void *arg)

I'm note sure that is a good idea put function parameters in the ifdef block.
What do you think to rename gluster_finish_aiocb() in gluster_finish_aiocb_common() or something like that and create two functions for the two cases with the right parameters that call gluster_finish_aiocb_common()?

#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT
static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
struct glfs_stat *pre, struct glfs_stat *post, void *arg)

{
    gluster_finish_aiocb_common(fd, ret, args);
}
#else
static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
{
    gluster_finish_aiocb_common(fd, ret, args);
}

#endif /* CONFIG_GLUSTERFS_IOCB_HAS_STAT */

Thanks,
Stefano

Quoted 56 lines
block/gluster.c +0 -0
 {
     GlusterAIOCB *acb = (GlusterAIOCB *)arg;
 
configure +24 -0
index bbfe587b88..db548d9b08 100755
@@ -457,6 +457,7 @@ glusterfs_discard="no"
 glusterfs_fallocate="no"
 glusterfs_zerofill="no"
 glusterfs_ftruncate_has_stat="no"
+glusterfs_iocb_has_stat="no"
 gtk=""
 gtk_gl="no"
 tls_priority="NORMAL"
@@ -4097,6 +4098,25 @@ EOF
     if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
       glusterfs_ftruncate_has_stat="yes"
     fi
+    cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+/* new glfs_io_cbk() passes two additional glfs_stat structs */
+static void
+glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
+{}
+
+int
+main(void)
+{
+	glfs_io_cbk iocb = &glusterfs_iocb;
+	iocb(NULL, 0 , NULL, NULL, NULL);
+	return 0;
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_iocb_has_stat="yes"
+    fi
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support" \
@@ -6903,6 +6923,10 @@ if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
   echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
 fi
 
+if test "$glusterfs_iocb_has_stat" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
+fi
+
 if test "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=m" >> $config_host_mak
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
Signature · 1 line
2.20.1
Applied
#5 lore raw
In reply to Niels de Vos

Am 05.03.2019 um 16:46 hat Niels de Vos geschrieben:

Quoted 11 lines

Gluster 6 is currently available as release candidate. There have been a few changes to libgfapi.so that need to be adapted by consuming projects like QEMU. Fedora Rawhide already contains glusterfs-6.0-RC0, and this prevents rebuilds of QEMU there (https://bugzilla.redhat.com/1684298).

The following two changes should be sufficient to consume Gluster 6 once it is released. These have been tested on CentOS-7 with Gluster 5 and Gluster 6 (minimal manual qemu-img tests only).

This v2 post contains changes suggested by Daniel P. Berrangé and Kevin Wolf. Thanks!

Thanks, applied to the block branch.

Kevin

#6 lore raw
Quoted 6 lines · Kevin Wolf

Am 05.03.2019 um 16:46 hat Niels de Vos geschrieben:

Quoted 5 lines

Gluster 6 is currently available as release candidate. There have been a few changes to libgfapi.so that need to be adapted by consuming projects like QEMU. Fedora Rawhide already contains glusterfs-6.0-RC0, and this prevents rebuilds of QEMU there (https://bugzilla.redhat.com/1684298).

Quoted 8 lines
Quoted 6 lines

The following two changes should be sufficient to consume Gluster 6 once it is released. These have been tested on CentOS-7 with Gluster 5 and Gluster 6 (minimal manual qemu-img tests only).

This v2 post contains changes suggested by Daniel P. Berrangé and Kevin Wolf. Thanks!

Thanks, applied to the block branch.

Thanks! Stefano Garzarella gave a suggestion for further cleanup. I was planning to address that (no #ifdef for function arguments) next week when I'm back from a trip, Is that something you would also like to see, or do you prefer the change to stay minimal/small as it is now? I'm happy to send a followup if you agree that it is cleaner.

Niels

#7 lore raw

Am 09.03.2019 um 10:40 hat Niels de Vos geschrieben:

Quoted 14 lines · Kevin Wolf
Quoted 13 lines

Am 05.03.2019 um 16:46 hat Niels de Vos geschrieben:

Quoted 11 lines

Gluster 6 is currently available as release candidate. There have been a few changes to libgfapi.so that need to be adapted by consuming projects like QEMU. Fedora Rawhide already contains glusterfs-6.0-RC0, and this prevents rebuilds of QEMU there (https://bugzilla.redhat.com/1684298).

The following two changes should be sufficient to consume Gluster 6 once it is released. These have been tested on CentOS-7 with Gluster 5 and Gluster 6 (minimal manual qemu-img tests only).

This v2 post contains changes suggested by Daniel P. Berrangé and Kevin Wolf. Thanks!

Quoted 7 lines
Quoted 1 line

Thanks, applied to the block branch.

Thanks! Stefano Garzarella gave a suggestion for further cleanup. I was planning to address that (no #ifdef for function arguments) next week when I'm back from a trip, Is that something you would also like to see, or do you prefer the change to stay minimal/small as it is now? I'm happy to send a followup if you agree that it is cleaner.

I don't mind either way.

I'm going to send a pull request tomorrow for soft freeze, but if you tell me that I should wait with this one, I can remove it from my queue for now. It's a bug fix, so we can still apply an updated version during the freeze.

A follow-up works for me, too, so whatever you prefer.

Kevin