Skip to contentSkip to conversation

block/gluster: Handle changed glfs_ftruncate signature

PATCH Superseded Niels de Vos 3 participants 12 messages Jul 27, 2018 – Aug 1, 2018 Block layer

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
v2: do a compile check as suggested by Eric Blake
v3: define old backwards compatible glfs_ftruncate() macro, from Eric Blake

---
 block/gluster.c | 11 +++++++++--
 configure       | 18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
block/gluster.c +9 -2
index 4fd55a9cc5..9bd6525b41 100644
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
 
+#ifdef CONFIG_GLUSTERFS_LEGACY_FTRUNCATE
+# define glfs_ftruncate(fd, offset, _u1, _u2) glfs_ftruncate(fd, offset)
+#endif
+
 #define GLUSTER_OPT_FILENAME        "filename"
 #define GLUSTER_OPT_VOLUME          "volume"
 #define GLUSTER_OPT_PATH            "path"
@@ -997,6 +1001,7 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
                                     PreallocMode prealloc, Error **errp)
 {
     int64_t current_length;
+    int ret;
 
     current_length = glfs_lseek(fd, 0, SEEK_END);
     if (current_length < 0) {
@@ -1024,7 +1029,8 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
 #endif /* CONFIG_GLUSTERFS_FALLOCATE */
 #ifdef CONFIG_GLUSTERFS_ZEROFILL
     case PREALLOC_MODE_FULL:
-        if (glfs_ftruncate(fd, offset)) {
+        ret = glfs_ftruncate(fd, offset, NULL, NULL);
+        if (ret) {
             error_setg_errno(errp, errno, "Could not resize file");
             return -errno;
         }
@@ -1035,7 +1041,8 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
         break;
 #endif /* CONFIG_GLUSTERFS_ZEROFILL */
     case PREALLOC_MODE_OFF:
-        if (glfs_ftruncate(fd, offset)) {
+        ret = glfs_ftruncate(fd, offset, NULL, NULL);
+        if (ret) {
             error_setg_errno(errp, errno, "Could not resize file");
             return -errno;
         }
configure +18 -0
index 2a7796ea80..f3c0918d6b 100755
@@ -451,6 +451,7 @@ glusterfs_xlator_opt="no"
 glusterfs_discard="no"
 glusterfs_fallocate="no"
 glusterfs_zerofill="no"
+glusterfs_legacy_ftruncate="no"
 gtk=""
 gtkabi=""
 gtk_gl="no"
@@ -3947,6 +3948,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_legacy_ftruncate="yes"
+    fi
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support" \
@@ -6644,6 +6658,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
   echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
 fi
 
+if test "$glusterfs_legacy_ftruncate" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_LEGACY_FTRUNCATE=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.17.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 3 lines · Niels de Vos

From: Prasanna Kumar Kalever <[email protected]>

New versions of Glusters libgfapi.so have an updated glfs_ftruncate()

s/Glusters/Gluster's/

Quoted 8 lines

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 7 lines

---
v2: do a compile check as suggested by Eric Blake
v3: define old backwards compatible glfs_ftruncate() macro, from Eric Blake

---
  block/gluster.c | 11 +++++++++--
  configure       | 18 ++++++++++++++++++
  2 files changed, 27 insertions(+), 2 deletions(-)

Seems reasonable to get into 3.0 if we still can (for fewer platforms with failed builds); but not the end of the world if it slips into 3.1.

Quoted 9 lines
block/gluster.c +1 -0
@@ -997,6 +1001,7 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
                                      PreallocMode prealloc, Error **errp)
  {
      int64_t current_length;
+    int ret;
 
      current_length = glfs_lseek(fd, 0, SEEK_END);
      if (current_length < 0) {

block/gluster.c static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset, · line 1033

Quoted 6 lines
block/gluster.c +2 -1
@@ -1024,7 +1029,8 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
  #endif /* CONFIG_GLUSTERFS_FALLOCATE */
  #ifdef CONFIG_GLUSTERFS_ZEROFILL
      case PREALLOC_MODE_FULL:
-        if (glfs_ftruncate(fd, offset)) {
+        ret = glfs_ftruncate(fd, offset, NULL, NULL);
+        if (ret) {

Adding 'ret' is not strictly necessary (checking the return directly in the 'if' still works), but doesn't hurt. So,

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
In reply to Niels de Vos
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.

Oh, one other comment.

block/gluster.c line 25

Quoted 8 lines

+++ b/block/gluster.c

block/gluster.c +3 -0
@@ -20,6 +20,10 @@
  #include "qemu/option.h"
  #include "qemu/cutils.h"
 
+#ifdef CONFIG_GLUSTERFS_LEGACY_FTRUNCATE
+# define glfs_ftruncate(fd, offset, _u1, _u2) glfs_ftruncate(fd, offset)
+#endif

Someday, when we can assume new enough gluster everywhere, we can drop this hunk...

configure if test "$glusterfs" != "no" ; then · line 3963

Quoted 9 lines
configure +8 -0
+++ b/configure
 
+	/* new glfs_ftruncate() passes two additional args */
+	return glfs_ftruncate(NULL, 0 /*, NULL, NULL */);
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_legacy_ftruncate="yes"
+    fi

...but it will be easier to remember to do so if this comment in configure calls out the upstream gluster version that no longer requires the legacy workaround, as our hint for when...

configure if test "$glusterfs_zerofill" = "yes" ; then · line 6662

Quoted 9 lines

else
if test "$glusterfs" = "yes" ; then
feature_not_found "GlusterFS backend support" \

configure +2 -0
@@ -6644,6 +6658,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
    echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
  fi
 
+if test "$glusterfs_legacy_ftruncate" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_LEGACY_FTRUNCATE=y" >> $config_host_mak

...this #define is no longer necessary.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw
Quoted 12 lines · Eric Blake
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.

Oh, one other comment.

Quoted 11 lines

block/gluster.c line 24

Quoted 7 lines

+++ b/block/gluster.c

block/gluster.c +3 -0
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
+#ifdef CONFIG_GLUSTERFS_LEGACY_FTRUNCATE
+# define glfs_ftruncate(fd, offset, _u1, _u2) glfs_ftruncate(fd, offset)
+#endif

Someday, when we can assume new enough gluster everywhere, we can drop this hunk...

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Quoted 14 lines

configure if test "$glusterfs" != "no" ; then · line 3963

Quoted 9 lines
configure +8 -0
+++ b/configure
 
+	/* new glfs_ftruncate() passes two additional args */
+	return glfs_ftruncate(NULL, 0 /*, NULL, NULL */);
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_legacy_ftruncate="yes"
+    fi

...but it will be easier to remember to do so if this comment in configure calls out the upstream gluster version that no longer requires the legacy workaround, as our hint for when...

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

Quoted 15 lines

configure if test "$glusterfs_zerofill" = "yes" ; then · line 6661

Quoted 8 lines
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support" \
configure +2 -0
@@ -6644,6 +6658,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
   echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
 fi
+if test "$glusterfs_legacy_ftruncate" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_LEGACY_FTRUNCATE=y" >> $config_host_mak

...this #define is no longer necessary.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 25 lines · Jeff Cody
Quoted 12 lines · Eric Blake
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.

Oh, one other comment.

Quoted 11 lines

block/gluster.c line 24

Quoted 7 lines

+++ b/block/gluster.c

block/gluster.c +3 -0
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
+#ifdef CONFIG_GLUSTERFS_LEGACY_FTRUNCATE
+# define glfs_ftruncate(fd, offset, _u1, _u2) glfs_ftruncate(fd, offset)
+#endif

Someday, when we can assume new enough gluster everywhere, we can drop this hunk...

Quoted 3 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 15 lines
Quoted 14 lines

configure if test "$glusterfs" != "no" ; then · line 3963

Quoted 9 lines
configure +8 -0
+++ b/configure
 
+	/* new glfs_ftruncate() passes two additional args */
+	return glfs_ftruncate(NULL, 0 /*, NULL, NULL */);
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_legacy_ftruncate="yes"
+    fi

...but it will be easier to remember to do so if this comment in configure calls out the upstream gluster version that no longer requires the legacy workaround, as our hint for when...

Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Thanks for correcting the last bits of the patch!
Niels

Quoted 15 lines
Quoted 15 lines

configure if test "$glusterfs_zerofill" = "yes" ; then · line 6661

Quoted 8 lines
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support" \
configure +2 -0
@@ -6644,6 +6658,10 @@ if test "$glusterfs_zerofill" = "yes" ; then
   echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
 fi
+if test "$glusterfs_legacy_ftruncate" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_LEGACY_FTRUNCATE=y" >> $config_host_mak

...this #define is no longer necessary.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#5 lore raw
Quoted 10 lines · Niels de Vos
Quoted 4 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 7 lines
Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Wait - so you're saying gluster has not yet released the incompatible change? Now would be the right time to get rid of the API breakage, before you bake it in, rather than relying solely on the versioned symbols to avoid an ABI breakage but forcing all clients to compensate to the API breakage.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#6 lore raw
Quoted 19 lines · Eric Blake
Quoted 10 lines · Niels de Vos
Quoted 4 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 7 lines
Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Quoted 5 lines

Wait - so you're saying gluster has not yet released the incompatible change? Now would be the right time to get rid of the API breakage, before you bake it in, rather than relying solely on the versioned symbols to avoid an ABI breakage but forcing all clients to compensate to the API breakage.

If this is not yet in a released version of Gluster, I'm not real eager to pollute the QEMU driver codebase with #ifdef's, especially if there is a possibility the API change may not actually materialize.

Is there any reason that this change is being approached in a way that breaks API usage, and is it too late in the Gluster development pipeline to change that?

#7 lore raw
Quoted 26 lines · Jeff Cody
Quoted 19 lines · Eric Blake
Quoted 10 lines · Niels de Vos
Quoted 4 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 7 lines
Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Quoted 5 lines

Wait - so you're saying gluster has not yet released the incompatible change? Now would be the right time to get rid of the API breakage, before you bake it in, rather than relying solely on the versioned symbols to avoid an ABI breakage but forcing all clients to compensate to the API breakage.

Quoted 7 lines

If this is not yet in a released version of Gluster, I'm not real eager to pollute the QEMU driver codebase with #ifdef's, especially if there is a possibility the API change may not actually materialize.

Is there any reason that this change is being approached in a way that breaks API usage, and is it too late in the Gluster development pipeline to change that?

There recently have been a few changes like this in libgfapi. These have been introduced to improve performance in common use-cases where an updated 'struct stat' is needed after an operation. Some functions have been adapted in previous releases, glfs_ftruncate() landed too late for that. I hope we'll get a complete coherent API with glusterfs-5 again.

For QEMU this means additional changes will come related to glfs_fallocate(), glfs_zerofill() and probably more. The current glusterfs-4.1 version will be maintained for one year, after which the detection/#ifdef can be removed as the than maintained versions should all have the updated API. I'm sorry for the inconvenience that this causes.

If you prefer, I can wait with sending patches for QEMU with future Gluster releases until additional changes have landed in libgfapi.

Thanks,
Niels

#8 lore raw
Quoted 35 lines · Niels de Vos
Quoted 26 lines · Jeff Cody
Quoted 19 lines · Eric Blake
Quoted 10 lines · Niels de Vos
Quoted 4 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 7 lines
Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Quoted 5 lines

Wait - so you're saying gluster has not yet released the incompatible change? Now would be the right time to get rid of the API breakage, before you bake it in, rather than relying solely on the versioned symbols to avoid an ABI breakage but forcing all clients to compensate to the API breakage.

Quoted 7 lines

If this is not yet in a released version of Gluster, I'm not real eager to pollute the QEMU driver codebase with #ifdef's, especially if there is a possibility the API change may not actually materialize.

Is there any reason that this change is being approached in a way that breaks API usage, and is it too late in the Gluster development pipeline to change that?

Quoted 6 lines

There recently have been a few changes like this in libgfapi. These have been introduced to improve performance in common use-cases where an updated 'struct stat' is needed after an operation. Some functions have been adapted in previous releases, glfs_ftruncate() landed too late for that. I hope we'll get a complete coherent API with glusterfs-5 again.

Am I correct in assuming the API changes that happened in previous libgfapi release are for APIs that QEMU does not use (i.e. no action needed from us?)

Quoted 7 lines

For QEMU this means additional changes will come related to glfs_fallocate(), glfs_zerofill() and probably more. The current glusterfs-4.1 version will be maintained for one year, after which the detection/#ifdef can be removed as the than maintained versions should all have the updated API. I'm sorry for the inconvenience that this causes.

Understood. I don't want to make a huge deal out of it. I guess my recommendation/request is that API enhancements happen in a way that don't break existing APIs (e.g. use parallel APIs), because QEMU version usage and supported glusterfs usage may not always follow supported versions in the wild. I know versioned symbols helps with this, but it still complicates the code (and couples QEMU's code to gluster support windows).

Quoted 3 lines

If you prefer, I can wait with sending patches for QEMU with future Gluster releases until additional changes have landed in libgfapi.

I think generally, we don't want to start introducing #ifdef's and new APi usage for unreleased versions of libgfapi if possible (as unreleased APIs, it could technically change, and then QEMU releases would have 'dead' API support in it).

If glusterfs-5 releases in October, that may line up with 3.1 or 3.2.

-Jeff

#9 lore raw
Quoted 43 lines · Jeff Cody
Quoted 35 lines · Niels de Vos
Quoted 26 lines · Jeff Cody
Quoted 19 lines · Eric Blake
Quoted 10 lines · Niels de Vos
Quoted 4 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 7 lines
Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Quoted 5 lines

Wait - so you're saying gluster has not yet released the incompatible change? Now would be the right time to get rid of the API breakage, before you bake it in, rather than relying solely on the versioned symbols to avoid an ABI breakage but forcing all clients to compensate to the API breakage.

Quoted 7 lines

If this is not yet in a released version of Gluster, I'm not real eager to pollute the QEMU driver codebase with #ifdef's, especially if there is a possibility the API change may not actually materialize.

Is there any reason that this change is being approached in a way that breaks API usage, and is it too late in the Gluster development pipeline to change that?

Quoted 6 lines

There recently have been a few changes like this in libgfapi. These have been introduced to improve performance in common use-cases where an updated 'struct stat' is needed after an operation. Some functions have been adapted in previous releases, glfs_ftruncate() landed too late for that. I hope we'll get a complete coherent API with glusterfs-5 again.

Quoted 3 lines

Am I correct in assuming the API changes that happened in previous libgfapi release are for APIs that QEMU does not use (i.e. no action needed from us?)

Yes, that is correct.

Quoted 8 lines
Quoted 7 lines

For QEMU this means additional changes will come related to glfs_fallocate(), glfs_zerofill() and probably more. The current glusterfs-4.1 version will be maintained for one year, after which the detection/#ifdef can be removed as the than maintained versions should all have the updated API. I'm sorry for the inconvenience that this causes.

Quoted 6 lines

Understood. I don't want to make a huge deal out of it. I guess my recommendation/request is that API enhancements happen in a way that don't break existing APIs (e.g. use parallel APIs), because QEMU version usage and supported glusterfs usage may not always follow supported versions in the wild. I know versioned symbols helps with this, but it still complicates the code (and couples QEMU's code to gluster support windows).

Once the last Gluster version that has the old API goes out of maintenance, we will remove the legacy functions. At that point, we can also provide a new patch to QEMU (and other projcets) that removes the compatibility #ifdef's.

Quoted 10 lines
Quoted 3 lines

If you prefer, I can wait with sending patches for QEMU with future Gluster releases until additional changes have landed in libgfapi.

I think generally, we don't want to start introducing #ifdef's and new APi usage for unreleased versions of libgfapi if possible (as unreleased APIs, it could technically change, and then QEMU releases would have 'dead' API support in it).

If glusterfs-5 releases in October, that may line up with 3.1 or 3.2.

Ok, I'll keep these kind of patches in my tree as work-in-progress and when the glusterfs-5 gets tagged for alpha/beta send it again.

Even if not optimal, would you accept this as a way going forward?

Thanks,
Niels

#10 lore raw
Quoted 6 lines · Niels de Vos
Quoted 1 line

If glusterfs-5 releases in October, that may line up with 3.1 or 3.2.

Ok, I'll keep these kind of patches in my tree as work-in-progress and when the glusterfs-5 gets tagged for alpha/beta send it again.

Even if not optimal, would you accept this as a way going forward?

It will work. But even better would be getting gluster to the point that it has a stable back-compat API guarantee (no future API removals or signature changes on existing functions - all new functionality is added via new API). The more clients a library gains, the more pain you cause yourself and all your clients when you choose not to maintain a backwards-compatible stable API.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#11 lore raw
In reply to Niels de Vos
Quoted 53 lines · Niels de Vos
Quoted 25 lines · Jeff Cody
Quoted 12 lines · Eric Blake
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.

Oh, one other comment.

Quoted 11 lines

block/gluster.c line 24

Quoted 7 lines

+++ b/block/gluster.c

block/gluster.c +3 -0
@@ -20,6 +20,10 @@
 #include "qemu/option.h"
 #include "qemu/cutils.h"
+#ifdef CONFIG_GLUSTERFS_LEGACY_FTRUNCATE
+# define glfs_ftruncate(fd, offset, _u1, _u2) glfs_ftruncate(fd, offset)
+#endif

Someday, when we can assume new enough gluster everywhere, we can drop this hunk...

Quoted 3 lines

Part of me wishes that libgfapi had just created a new function 'glfs_ftruncate2', so that existing users don't need to handle the api change. But I guess in the grand scheme, not a huge deal either way.

Gluster uses versioned symbols, so older binaries will keep working with new libraries. It is (hopefully) rare that existing symbols get updated. We try to send patches for these kind of changes to the projects we know well in advance, reducing the number of surprises.

Quoted 15 lines
Quoted 14 lines

configure if test "$glusterfs" != "no" ; then · line 3963

Quoted 9 lines
configure +8 -0
+++ b/configure
 
+	/* new glfs_ftruncate() passes two additional args */
+	return glfs_ftruncate(NULL, 0 /*, NULL, NULL */);
+}
+EOF
+    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
+      glusterfs_legacy_ftruncate="yes"
+    fi

...but it will be easier to remember to do so if this comment in configure calls out the upstream gluster version that no longer requires the legacy workaround, as our hint for when...

Quoted 2 lines

I can go ahead and add that to the comment in my branch after applying, if Niels can let me know what that version is/will be (if known).

Quoted 6 lines

The new glfs_ftruncate() will be part of glusterfs-5 (planned for October). We're changing the numbering scheme, it was expected to come in glusterfs-4.2, but that is a version that never will be released.

Thanks for correcting the last bits of the patch!
Niels

So that there is no confusion or miscommunication: I'm not going to pull this patch in through my tree for 3.0 (or 3.1 yet), since the new API isn't part of a released version of gluster yet. (And hopefully we won't ever need it, if the gluster changes can happen without breaking the existing API)

-Jeff