cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-gluster-Add-discard-support-for-GlusterFS-block-driv.patch

958e1b
From d4ddb41fc6868d41f38d9a4bec0f4ad7d332add9 Mon Sep 17 00:00:00 2001
958e1b
From: Jeffrey Cody <jcody@redhat.com>
958e1b
Date: Tue, 2 Sep 2014 19:34:06 +0200
958e1b
Subject: [PATCH 3/6] gluster: Add discard support for GlusterFS block driver.
958e1b
958e1b
Message-id: <6b5e10e9b95a3030bb19540324915e0b774bd5bb.1409686386.git.jcody@redhat.com>
958e1b
Patchwork-id: 60815
958e1b
O-Subject: [PATCH qemu-kvm-rhev RHEL7.1] gluster: Add discard support for GlusterFS block driver.
958e1b
Bugzilla: 1136534
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Fam Zheng <famz@redhat.com>
958e1b
958e1b
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
958e1b
958e1b
Implement bdrv_aio_discard for gluster.
958e1b
958e1b
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
958e1b
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
(cherry picked from commit 0c14fb47ece5ef42d7a0a4b3e8e43e022b375720)
958e1b
Signed-off-by: Jeff Cody <jcody@redhat.com>
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 block/gluster.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
958e1b
 configure       |    8 ++++++++
958e1b
 2 files changed, 53 insertions(+), 0 deletions(-)
958e1b
958e1b
diff --git a/block/gluster.c b/block/gluster.c
958e1b
index f43d3a6..da43d0c 100644
958e1b
--- a/block/gluster.c
958e1b
+++ b/block/gluster.c
958e1b
@@ -633,6 +633,39 @@ out:
958e1b
     return NULL;
958e1b
 }
958e1b
 
958e1b
+#ifdef CONFIG_GLUSTERFS_DISCARD
958e1b
+static BlockDriverAIOCB *qemu_gluster_aio_discard(BlockDriverState *bs,
958e1b
+        int64_t sector_num, int nb_sectors, BlockDriverCompletionFunc *cb,
958e1b
+        void *opaque)
958e1b
+{
958e1b
+    int ret;
958e1b
+    GlusterAIOCB *acb;
958e1b
+    BDRVGlusterState *s = bs->opaque;
958e1b
+    size_t size;
958e1b
+    off_t offset;
958e1b
+
958e1b
+    offset = sector_num * BDRV_SECTOR_SIZE;
958e1b
+    size = nb_sectors * BDRV_SECTOR_SIZE;
958e1b
+
958e1b
+    acb = qemu_aio_get(&gluster_aiocb_info, bs, cb, opaque);
958e1b
+    acb->size = 0;
958e1b
+    acb->ret = 0;
958e1b
+    acb->finished = NULL;
958e1b
+    s->qemu_aio_count++;
958e1b
+
958e1b
+    ret = glfs_discard_async(s->fd, offset, size, &gluster_finish_aiocb, acb);
958e1b
+    if (ret < 0) {
958e1b
+        goto out;
958e1b
+    }
958e1b
+    return &acb->common;
958e1b
+
958e1b
+out:
958e1b
+    s->qemu_aio_count--;
958e1b
+    qemu_aio_release(acb);
958e1b
+    return NULL;
958e1b
+}
958e1b
+#endif
958e1b
+
958e1b
 static int64_t qemu_gluster_getlength(BlockDriverState *bs)
958e1b
 {
958e1b
     BDRVGlusterState *s = bs->opaque;
958e1b
@@ -707,6 +740,9 @@ static BlockDriver bdrv_gluster = {
958e1b
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
958e1b
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
958e1b
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
958e1b
+#ifdef CONFIG_GLUSTERFS_DISCARD
958e1b
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
958e1b
+#endif
958e1b
     .create_options               = qemu_gluster_create_options,
958e1b
 };
958e1b
 
958e1b
@@ -727,6 +763,9 @@ static BlockDriver bdrv_gluster_tcp = {
958e1b
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
958e1b
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
958e1b
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
958e1b
+#ifdef CONFIG_GLUSTERFS_DISCARD
958e1b
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
958e1b
+#endif
958e1b
     .create_options               = qemu_gluster_create_options,
958e1b
 };
958e1b
 
958e1b
@@ -747,6 +786,9 @@ static BlockDriver bdrv_gluster_unix = {
958e1b
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
958e1b
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
958e1b
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
958e1b
+#ifdef CONFIG_GLUSTERFS_DISCARD
958e1b
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
958e1b
+#endif
958e1b
     .create_options               = qemu_gluster_create_options,
958e1b
 };
958e1b
 
958e1b
@@ -767,6 +809,9 @@ static BlockDriver bdrv_gluster_rdma = {
958e1b
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
958e1b
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
958e1b
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
958e1b
+#ifdef CONFIG_GLUSTERFS_DISCARD
958e1b
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
958e1b
+#endif
958e1b
     .create_options               = qemu_gluster_create_options,
958e1b
 };
958e1b
 
958e1b
diff --git a/configure b/configure
958e1b
index 0c666e5..fb0c839 100755
958e1b
--- a/configure
958e1b
+++ b/configure
958e1b
@@ -238,6 +238,7 @@ libiscsi=""
958e1b
 coroutine=""
958e1b
 seccomp=""
958e1b
 glusterfs=""
958e1b
+glusterfs_discard="no"
958e1b
 virtio_blk_data_plane=""
958e1b
 gtk=""
958e1b
 gtkabi="2.0"
958e1b
@@ -2644,6 +2645,9 @@ EOF
958e1b
   glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
958e1b
   if compile_prog "" "$glusterfs_libs" ; then
958e1b
     glusterfs=yes
958e1b
+    if $pkg_config --atleast-version=5 glusterfs-api >/dev/null 2>&1; then
958e1b
+      glusterfs_discard="yes"
958e1b
+    fi
958e1b
   else
958e1b
     if test "$glusterfs" = "yes" ; then
958e1b
       feature_not_found "GlusterFS backend support"
958e1b
@@ -4025,6 +4029,10 @@ if test "$glusterfs" = "yes" ; then
958e1b
   echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
958e1b
 fi
958e1b
 
958e1b
+if test "$glusterfs_discard" = "yes" ; then
958e1b
+  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
958e1b
+fi
958e1b
+
958e1b
 if test "$libssh2" = "yes" ; then
958e1b
   echo "CONFIG_LIBSSH2=y" >> $config_host_mak
958e1b
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
958e1b
-- 
958e1b
1.7.1
958e1b