engines/glfs_async: add trim support
authorJens Axboe <axboe@fb.com>
Wed, 29 Oct 2014 02:40:21 +0000 (20:40 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 29 Oct 2014 02:40:21 +0000 (20:40 -0600)
If available.

Signed-off-by: Jens Axboe <axboe@fb.com>
configure
engines/glusterfs_async.c

index da637a9733da8b92d54b574efb5c092b21f65045..de0fc893eeefc16f664eb87d3b410c8ba9f24e67 100755 (executable)
--- a/configure
+++ b/configure
@@ -1261,6 +1261,7 @@ fi
 
 ##########################################
 # check for gfapi fadvise support
+if test "$gfapi" = "yes" ; then
 gf_fadvise="no"
 cat > $TMPC << EOF
 #include <glusterfs/api/glfs.h>
@@ -1273,11 +1274,29 @@ int main(int argc, char **argv)
   return 0;
 }
 EOF
-
 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
   gf_fadvise="yes"
 fi
 echo "Gluster API use fadvise       $gf_fadvise"
+fi
+
+##########################################
+# check for gfapi trim support
+gf_trim="no"
+if test "$gfapi" = "yes" ; then
+cat > $TMPC << EOF
+#include <glusterfs/api/glfs.h>
+
+int main(int argc, char **argv)
+{
+  return glfs_discard_async(NULL, 0, 0);
+}
+EOF
+if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
+  gf_trim="yes"
+fi
+echo "Gluster API trim support      $gf_trim"
+fi
 
 ##########################################
 # Check if we support stckf on s390
@@ -1525,6 +1544,9 @@ fi
 if test "$gf_fadvise" = "yes" ; then
   output_sym "CONFIG_GF_FADVISE"
 fi
+if test "$gf_trim" = "yes" ; then
+  output_sym "CONFIG_GF_TRIM"
+fi
 if test "$libhdfs" = "yes" ; then
   output_sym "CONFIG_LIBHDFS"
 fi
index cf6ea709a733f6b1eef4d52719a302d55aee00cd..f2b9818a66634026636170cef0145b81b4c5e991 100644 (file)
@@ -120,6 +120,11 @@ static int fio_gf_async_queue(struct thread_data fio_unused * td,
                r = glfs_pwrite_async(g->fd, io_u->xfer_buf, io_u->xfer_buflen,
                                      io_u->offset, 0, gf_async_cb,
                                      (void *)io_u);
+#if defined(CONFIG_GF_TRIM)
+       else if (io_u->ddir == DDIR_TRIM)
+               r = glfs_discard_async(g->fd, io_u->offset, io_u->xfer_buflen,
+                                      gf_async_cb, io_u);
+#endif
        else if (io_u->ddir == DDIR_SYNC) {
                r = glfs_fsync_async(g->fd, gf_async_cb, (void *)io_u);
        } else {