glusterfs api fadvise support
diff --git a/Makefile b/Makefile
index cef82d9..59fae9c 100644
--- a/Makefile
+++ b/Makefile
@@ -95,6 +95,9 @@
   SOURCE += engines/glusterfs.c
   SOURCE += engines/glusterfs_sync.c
   SOURCE += engines/glusterfs_async.c
+  ifdef CONFIG_GF_FADVISE
+    CFLAGS += "-DGFAPI_USE_FADVISE"
+  endif
 endif
 
 ifeq ($(CONFIG_TARGET_OS), Linux)
diff --git a/configure b/configure
index e371767..be63eb1 100755
--- a/configure
+++ b/configure
@@ -1165,8 +1165,27 @@
   LIBS="-lgfapi -lglusterfs $LIBS"
   gfapi="yes"
 fi
-echo "Gluster API engine            $gfapi"
+ echo "Gluster API engine            $gfapi"
 
+##########################################
+# check for gfapi fadvise support
+gf_fadvise="no"
+cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+int main(int argc, char **argv)
+{
+  struct glfs_fd *fd;
+  int ret = glfs_fadvise(fd, 0, 0, 1);
+
+  return 0;
+}
+EOF
+
+if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
+  gf_fadvise="yes"
+fi
+echo "Gluster API use fadvise       $gf_fadvise"
 
 ##########################################
 # Check if we support stckf on s390
@@ -1332,6 +1351,9 @@
 if test "$gfapi" = "yes" ; then
   output_sym "CONFIG_GFAPI"
 fi
+if test "$gf_fadvise" = "yes" ; then
+  output_sym "CONFIG_GF_FADVISE"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
diff --git a/engines/glusterfs.c b/engines/glusterfs.c
index e9132b7..230274a 100644
--- a/engines/glusterfs.c
+++ b/engines/glusterfs.c
@@ -223,6 +223,19 @@
             }
         }
     }
+#if defined(GFAPI_USE_FADVISE)
+    {
+        int r = 0; 
+        if (td_random(td)){
+            r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_RANDOM);
+        }else{
+            r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_SEQUENTIAL);
+        }
+        if (r){
+            dprint(FD_FILE, "fio %p fadvise %s status %d\n", g->fs, f->file_name, r);
+        }
+    }
+#endif
     dprint(FD_FILE, "fio %p created %s\n", g->fs, f->file_name);
     f->fd = -1;
     f->shadow_fd = -1;    
diff --git a/engines/glusterfs_async.c b/engines/glusterfs_async.c
index e2c76dc..bea9549 100644
--- a/engines/glusterfs_async.c
+++ b/engines/glusterfs_async.c
@@ -10,6 +10,7 @@
 	struct io_u *io_u;
 	int io_complete;
 };
+static ulong cb_count = 0, issued = 0;
 
 static struct io_u *fio_gf_event(struct thread_data *td, int event)
 {
@@ -46,7 +47,7 @@
 
 		}
 		if (events < min)
-			usleep(10);
+			usleep(100);
 		else
 			break;
 
@@ -66,6 +67,7 @@
 		io_u->engine_data = NULL;
 		free(io);
 	}
+    fprintf(stderr, "issued %lu finished %lu\n", issued, cb_count);
 }
 
 static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u)
@@ -95,6 +97,7 @@
 
     dprint(FD_IO, "%s ret %lu\n", __FUNCTION__, ret);    
     iou->io_complete = 1;
+    cb_count ++;
 }
 
 static int fio_gf_async_queue(struct thread_data fio_unused *td, struct io_u *io_u)
@@ -125,7 +128,7 @@
         io_u->error = r;
         goto failed;
     }
-
+    issued ++;
 	return FIO_Q_QUEUED;
 
 failed:
@@ -145,6 +148,7 @@
     if (r){
         return r;
     }
+	td->o.use_thread = 1;
     g = td->io_ops->data;
     g->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
 	if (!g->aio_events){