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