glusterfs: update for new API
authorJens Axboe <axboe@kernel.dk>
Thu, 23 May 2019 20:57:03 +0000 (14:57 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 23 May 2019 20:57:52 +0000 (14:57 -0600)
Apparently glusterfs just changes their API as they see fit. Add
a configure check for the newer version, which adds pre/post stat
variables in a few random spots.

This should fix compilation with v6.0 of the API.

Fixes: https://github.com/axboe/fio/issues/781
Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
engines/glusterfs.c
engines/glusterfs_async.c
engines/glusterfs_sync.c

index ee421663f396acfe7b6fa473354baf5103ab2a78..b0052dc1f361b9b78258ee153b0f691cf638a792 100755 (executable)
--- a/configure
+++ b/configure
@@ -1789,6 +1789,24 @@ fi
 print_config "Gluster API use fadvise" "$gf_fadvise"
 fi
 
 print_config "Gluster API use fadvise" "$gf_fadvise"
 fi
 
+##########################################
+# check for newer gfapi
+if test "$gfapi" = "yes" ; then
+gf_new="no"
+cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+int main(int argc, char **argv)
+{
+  return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
+}
+EOF
+if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
+  gf_new="yes"
+fi
+print_config "Gluster new API" "$gf_new"
+fi
+
 ##########################################
 # check for gfapi trim support
 if test "$gf_trim" != "yes" ; then
 ##########################################
 # check for gfapi trim support
 if test "$gf_trim" != "yes" ; then
@@ -2576,6 +2594,9 @@ fi
 if test "$gf_trim" = "yes" ; then
   output_sym "CONFIG_GF_TRIM"
 fi
 if test "$gf_trim" = "yes" ; then
   output_sym "CONFIG_GF_TRIM"
 fi
+if test "$gf_new" = "yes" ; then
+  output_sym "CONFIG_GF_NEW_API"
+fi
 if test "$libhdfs" = "yes" ; then
   output_sym "CONFIG_LIBHDFS"
   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
 if test "$libhdfs" = "yes" ; then
   output_sym "CONFIG_LIBHDFS"
   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
index d0250b70eab0713941a0567c4b23da58ddd82c36..f2b84a2ab70b00013d13aafdbbaa73fc385071bc 100644 (file)
@@ -288,7 +288,11 @@ int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
                    || sb.st_size < f->real_file_size) {
                        dprint(FD_FILE, "fio extend file %s from %jd to %" PRIu64 "\n",
                               f->file_name, (intmax_t) sb.st_size, f->real_file_size);
                    || sb.st_size < f->real_file_size) {
                        dprint(FD_FILE, "fio extend file %s from %jd to %" PRIu64 "\n",
                               f->file_name, (intmax_t) sb.st_size, f->real_file_size);
+#if defined(CONFIG_GF_NEW_API)
+                       ret = glfs_ftruncate(g->fd, f->real_file_size, NULL, NULL);
+#else
                        ret = glfs_ftruncate(g->fd, f->real_file_size);
                        ret = glfs_ftruncate(g->fd, f->real_file_size);
+#endif
                        if (ret) {
                                log_err("failed fio extend file %s to %" PRIu64 "\n",
                                        f->file_name, f->real_file_size);
                        if (ret) {
                                log_err("failed fio extend file %s to %" PRIu64 "\n",
                                        f->file_name, f->real_file_size);
@@ -350,7 +354,11 @@ int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
                                               f->file_name);
                                        glfs_unlink(g->fs, f->file_name);
                                } else if (td->o.create_fsync) {
                                               f->file_name);
                                        glfs_unlink(g->fs, f->file_name);
                                } else if (td->o.create_fsync) {
+#if defined(CONFIG_GF_NEW_API)
+                                       if (glfs_fsync(g->fd, NULL, NULL) < 0) {
+#else
                                        if (glfs_fsync(g->fd) < 0) {
                                        if (glfs_fsync(g->fd) < 0) {
+#endif
                                                dprint(FD_FILE,
                                                       "failed to sync, close %s\n",
                                                       f->file_name);
                                                dprint(FD_FILE,
                                                       "failed to sync, close %s\n",
                                                       f->file_name);
index 9e1c4bf038f3b3ce2fbe27f3ddb19cffbd6f3dd2..0392ad6e3f1315c9f8214272ee2b98e2ebfa7455 100644 (file)
@@ -84,7 +84,12 @@ static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u)
        return 0;
 }
 
        return 0;
 }
 
+#if defined(CONFIG_GF_NEW_API)
+static void gf_async_cb(glfs_fd_t * fd, ssize_t ret, struct glfs_stat *prestat,
+                       struct glfs_stat *poststat, void *data)
+#else
 static void gf_async_cb(glfs_fd_t * fd, ssize_t ret, void *data)
 static void gf_async_cb(glfs_fd_t * fd, ssize_t ret, void *data)
+#endif
 {
        struct io_u *io_u = data;
        struct fio_gf_iou *iou = io_u->engine_data;
 {
        struct io_u *io_u = data;
        struct fio_gf_iou *iou = io_u->engine_data;
index 099a5af10406a4da4f2d7158df2df28881456f6d..de73261f6c88fbc4778d5f2b45e9447b40bcb7d8 100644 (file)
@@ -42,9 +42,17 @@ static enum fio_q_status fio_gf_queue(struct thread_data *td, struct io_u *io_u)
        else if (io_u->ddir == DDIR_WRITE)
                ret = glfs_write(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
        else if (io_u->ddir == DDIR_SYNC)
        else if (io_u->ddir == DDIR_WRITE)
                ret = glfs_write(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
        else if (io_u->ddir == DDIR_SYNC)
+#if defined(CONFIG_GF_NEW_API)
+               ret = glfs_fsync(g->fd, NULL, NULL);
+#else
                ret = glfs_fsync(g->fd);
                ret = glfs_fsync(g->fd);
+#endif
        else if (io_u->ddir == DDIR_DATASYNC)
        else if (io_u->ddir == DDIR_DATASYNC)
+#if defined(CONFIG_GF_NEW_API)
+               ret = glfs_fdatasync(g->fd, NULL, NULL);
+#else
                ret = glfs_fdatasync(g->fd);
                ret = glfs_fdatasync(g->fd);
+#endif
        else {
                log_err("unsupported operation.\n");
                io_u->error = EINVAL;
        else {
                log_err("unsupported operation.\n");
                io_u->error = EINVAL;