Skip to contentSkip to conversation

pkg-config and discard support for gluster driver

PATCH Applied Bharata B Rao 2 participants 4 messages Jul 16, 2013 – Jul 17, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

v2 cover pkg-config and discard support for gluster driver

Hi,

This is the v2 of the patchset that changes gluster driver in QEMU to use pkg-config and adds discard support.

Changes in v2
-------------
- Ensure that gluster libraries don't get linked to linux-user targets.

Bharata B Rao (2):
gluster: Use pkg-config to configure GlusterFS block driver
gluster: Add discard support for GlusterFS block driver.

 block/gluster.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 configure       | 25 ++++++++++++++-----------
 2 files changed, 59 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH v2 1/2 gluster: Use pkg-config to configure GlusterFS block driver

Use pkg-config to determine the version and library dependency for GlusterFS block driver.

---
 configure | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
configure +6 -11
index cb0f870..33f943a 100755
@@ -2566,23 +2566,18 @@ fi
 ##########################################
 # glusterfs probe
 if test "$glusterfs" != "no" ; then
-  cat > $TMPC <<EOF
-#include <glusterfs/api/glfs.h>
-int main(void) {
-    (void) glfs_new("volume");
-    return 0;
-}
-EOF
-  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
-  if compile_prog "" "$glusterfs_libs" ; then
-    glusterfs=yes
+  if $pkg_config --atleast-version=3 glusterfs-api >/dev/null 2>&1; then
+    glusterfs="yes"
+    glusterfs_cflags=`$pkg_config --cflags glusterfs-api 2>/dev/null`
+    glusterfs_libs=`$pkg_config --libs glusterfs-api 2>/dev/null`
+    CFLAGS="$CFLAGS $glusterfs_cflags"
     libs_tools="$glusterfs_libs $libs_tools"
     libs_softmmu="$glusterfs_libs $libs_softmmu"
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support"
     fi
-    glusterfs=no
+    glusterfs="no"
   fi
 fi
 
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH v2 2/2 gluster: Add discard support for GlusterFS block driver.

In reply to Bharata B Rao

Implement bdrv_aio_discard for gluster.

---
 block/gluster.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 configure       |  8 ++++++++
 2 files changed, 53 insertions(+)
block/gluster.c +45 -0
index 61424bc..6de418c 100644
@@ -532,6 +532,39 @@ out:
     return NULL;
 }
 
+#ifdef CONFIG_GLUSTERFS_DISCARD
+static BlockDriverAIOCB *qemu_gluster_aio_discard(BlockDriverState *bs,
+        int64_t sector_num, int nb_sectors, BlockDriverCompletionFunc *cb,
+        void *opaque)
+{
+    int ret;
+    GlusterAIOCB *acb;
+    BDRVGlusterState *s = bs->opaque;
+    size_t size;
+    off_t offset;
+
+    offset = sector_num * BDRV_SECTOR_SIZE;
+    size = nb_sectors * BDRV_SECTOR_SIZE;
+
+    acb = qemu_aio_get(&gluster_aiocb_info, bs, cb, opaque);
+    acb->size = 0;
+    acb->ret = 0;
+    acb->finished = NULL;
+    s->qemu_aio_count++;
+
+    ret = glfs_discard_async(s->fd, offset, size, &gluster_finish_aiocb, acb);
+    if (ret < 0) {
+        goto out;
+    }
+    return &acb->common;
+
+out:
+    s->qemu_aio_count--;
+    qemu_aio_release(acb);
+    return NULL;
+}
+#endif
+
 static int64_t qemu_gluster_getlength(BlockDriverState *bs)
 {
     BDRVGlusterState *s = bs->opaque;
@@ -602,6 +635,9 @@ static BlockDriver bdrv_gluster = {
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
+#ifdef CONFIG_GLUSTERFS_DISCARD
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
+#endif
     .create_options               = qemu_gluster_create_options,
 };
 
@@ -618,6 +654,9 @@ static BlockDriver bdrv_gluster_tcp = {
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
+#ifdef CONFIG_GLUSTERFS_DISCARD
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
+#endif
     .create_options               = qemu_gluster_create_options,
 };
 
@@ -634,6 +673,9 @@ static BlockDriver bdrv_gluster_unix = {
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
+#ifdef CONFIG_GLUSTERFS_DISCARD
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
+#endif
     .create_options               = qemu_gluster_create_options,
 };
 
@@ -650,6 +692,9 @@ static BlockDriver bdrv_gluster_rdma = {
     .bdrv_aio_writev              = qemu_gluster_aio_writev,
     .bdrv_aio_flush               = qemu_gluster_aio_flush,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
+#ifdef CONFIG_GLUSTERFS_DISCARD
+    .bdrv_aio_discard             = qemu_gluster_aio_discard,
+#endif
     .create_options               = qemu_gluster_create_options,
 };
 
configure +8 -0
index 33f943a..82022c4 100755
@@ -237,6 +237,7 @@ libiscsi=""
 coroutine=""
 seccomp=""
 glusterfs=""
+glusterfs_discard="no"
 virtio_blk_data_plane=""
 gtk=""
 gtkabi="2.0"
@@ -2573,6 +2574,9 @@ if test "$glusterfs" != "no" ; then
     CFLAGS="$CFLAGS $glusterfs_cflags"
     libs_tools="$glusterfs_libs $libs_tools"
     libs_softmmu="$glusterfs_libs $libs_softmmu"
+    if $pkg_config --atleast-version=5 glusterfs-api >/dev/null 2>&1; then
+      glusterfs_discard="yes"
+    fi
   else
     if test "$glusterfs" = "yes" ; then
       feature_not_found "GlusterFS backend support"
@@ -3960,6 +3964,10 @@ if test "$glusterfs" = "yes" ; then
   echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
 fi
 
+if test "$glusterfs_discard" = "yes" ; then
+  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
+fi
+
 if test "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=y" >> $config_host_mak
 fi
Signature · 1 line
1.7.11.7
#3 lore raw
In reply to Bharata B Rao
Quoted 9 lines · Bharata B Rao

Hi,

This is the v2 of the patchset that changes gluster driver in QEMU to use pkg-config and adds discard support.

Changes in v2
-------------
- Ensure that gluster libraries don't get linked to linux-user targets.

Quoted 11 lines

Bharata B Rao (2):
gluster: Use pkg-config to configure GlusterFS block driver
gluster: Add discard support for GlusterFS block driver.

 block/gluster.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 configure       | 25 ++++++++++++++-----------
 2 files changed, 59 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.11.7

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan