Skip to contentSkip to conversation

block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support

RFC PATCH Superseded Ashish Mittal 4 participants 4 messages Aug 8, 2016 – Aug 11, 2016 Block layer

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support

This patch adds support for a new block device type called "vxhs". Source code for the library that this code loads can be downloaded from:
https://github.com/MittalAshish/libqnio.git

Version 2 patch submission fixes the following issues:
(1) Removed code to dlopen library. We now check if libqnio is installed during configure, and directly link with it.
(2) Changed file headers to mention GPLv2-or-later license.
(3) Removed unnecessary type casts and inlines.
(4) Removed custom tokenize function and modified code to use g_strsplit.
(5) Replaced malloc/free with g_new/g_free and removed code that checks for memory allocation failure conditions.
(6) Removed some block ops implementations that were place-holders only.
(7) Removed all custom debug messages. Added new messages in block/trace-events
(8) Other miscellaneous corrections.

TODO: QAPI changes and (fixes to) review comments from Stefan.

---
 block/Makefile.objs |    2 +
 block/trace-events  |   40 ++
 block/vxhs.c        | 1199 +++++++++++++++++++++++++++++++++++++++++++++++++++
 block/vxhs.h        |  294 +++++++++++++
 configure           |   50 +++
 5 files changed, 1585 insertions(+)
 create mode 100644 block/vxhs.c
 create mode 100644 block/vxhs.h
block/Makefile.objs +2 -0
index 2593a2f..5f83305 100644
@@ -20,6 +20,7 @@ block-obj-$(CONFIG_RBD) += rbd.o
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
 block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
+block-obj-$(CONFIG_VXHS) += vxhs.o
 block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 
@@ -43,3 +44,4 @@ block-obj-m        += dmg.o
 dmg.o-libs         := $(BZIP2_LIBS)
 qcow.o-libs        := -lz
 linux-aio.o-libs   := -laio
+vxhs.o-libs        := $(VXHS_LIBS)
block/trace-events +40 -0
index 978ef4f..8f02725 100644
@@ -114,3 +114,43 @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
 qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
 qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
 qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
+
+# block/vxhs.c
+vxhs_bdrv_init(int version) "Registering VxHS %d AIO driver"
+vxhs_iio_callback(int error, int reason) "ctx is NULL: error %d, reason %d"
+vxhs_setup_qnio(void *s) "Context to HyperScale IO manager = %p"
+vxhs_setup_qnio_nwerror(char c) "Could not initialize the network channel. Bailing out%c"
+vxhs_open_device_cmdline(const char *vxhs_uri) "Original command line : %s"
+vxhs_iio_callback_iofail(int err, int reason, void *acb, int seg) "Read/Write failed: error %d, reason %d, acb %p, segment %d"
+vxhs_iio_callback_retry(char *guid, void *acb) "vDisk %s, added acb %p to retry queue (5)"
+vxhs_iio_callback_chnlfail(int error) "QNIO channel failed, no i/o (%d)"
+vxhs_iio_callback_fail(int r, void *acb, int seg, uint64_t size, int err) " ALERT: reason = %d , acb = %p, acb->segments = %d, acb->size = %lu Error = %d"
+vxhs_fail_aio(char * guid, void *acb) "vDisk %s, failing acb %p"
+vxhs_iio_callback_ready(char *vd, int err) "async vxhs_iio_callback: IRP_VDISK_CHECK_IO_FAILOVER_READY completed for vdisk %s with error %d"
+vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d"
+vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d"
+vxhs_open_device_qnio(char *of_vsa_addr) "Could not open an QNIO connection to: %s"
+vxhs_create(const char *filename) "vxhs_create: came in to open file = %s"
+vxhs_open(const char *filename) "vxhs_vxhs_open: came in to open file = %s"
+vxhs_open_fail(int ret) "Could not open the device. Error = %d"
+vxhs_open_epipe(char c) "Could not create a pipe for device. bailing out%c"
+vxhs_aio_rw(char *guid, int iodir, uint64_t size, uint64_t offset) "vDisk %s, vDisk device is in failed state iodir = %d size = %lu offset = %lu"
+vxhs_aio_rw_retry(char *guid, void *acb, int queue) "vDisk %s, added acb %p to retry queue(%d)"
+vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d"
+vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int seg, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p Segments = %d. Error = %d, errno = %d"
+vxhs_co_flush(char *guid, int ret, int err) "vDisk (%s) Flush ioctl failed ret = %d errno = %d"
+vxhs_co_flush_iocnt(int iocnt) "In the flush the IO count = %d"
+vxhs_get_vdisk_stat(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d"
+vxhs_switch_storage_agent(char *ip, char *guid) "Query host %s for vdisk %s"
+vxhs_switch_storage_agent_failed(char *ip, char *guid, int res, int err) "Query to host %s for vdisk %s failed, res = %d, errno = %d"
+vxhs_failover_ioctl_cb(char *ip, char *guid) "Switched to storage server host-IP %s for vdisk %s"
+vxhs_failover_ioctl_cb_retry(char *guid) "failover_ioctl_cb: keep looking for io target for vdisk %s"
+vxhs_failover_io(char *vdisk) "I/O Failover starting for vDisk %s"
+vxhs_reopen_vdisk(char *ip) "Failed to connect to storage agent on host-ip %s"
+vxhs_reopen_vdisk_openfail(char *fname) "Failed to open vdisk device: %s"
+vxhs_build_io_target_list(int num, char *uri) "About to parse URI %d : %s"
+vxhs_handle_queued_ios(void *acb, int res) "Restarted acb %p res %d"
+vxhs_restart_aio(int dir, int res, int err) "IO ERROR FOR: Read/Write = %d Error = %d, errno = %d"
+vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld"
+vxhs_aio_rw_iofail(char *guid) "vDisk %s, I/O operation failed."
+vxhs_aio_rw_devfail(char *guid, int dir, uint64_t size, uint64_t off) "vDisk %s, vDisk device failed iodir = %d size = %lu offset = %lu"
block/vxhs.c new file +1199 -0

1,199 lines not on this page · raw message

block/vxhs.h new file +294 -0

294 lines not on this page · raw message

configure +50 -0

80 lines not on this page · raw message

Signature · 1 line
2.5.5
#1 lore raw
Quoted 1 line · Ashish Mittal

This patch adds support for a new block device type called "vxhs".

I'd suggest this commit message should include an example of the syntax for using this on the CLI

Quoted 14 lines

Source code for the library that this code loads can be downloaded from:
https://github.com/MittalAshish/libqnio.git

Version 2 patch submission fixes the following issues:
(1) Removed code to dlopen library. We now check if libqnio is installed during configure, and directly link with it.
(2) Changed file headers to mention GPLv2-or-later license.
(3) Removed unnecessary type casts and inlines.
(4) Removed custom tokenize function and modified code to use g_strsplit.
(5) Replaced malloc/free with g_new/g_free and removed code that checks for memory allocation failure conditions.
(6) Removed some block ops implementations that were place-holders only.
(7) Removed all custom debug messages. Added new messages in block/trace-events
(8) Other miscellaneous corrections.

FYI, if you put notes about what changed in between postings below the '---' line, then with your patch is applied, git is intelligent enough to drop these notes.

Quoted 4 lines

TODO: QAPI changes and (fixes to) review comments from Stefan.

---

eg, put your 'Changed in v2' stuff just here.

Quoted 25 lines
 block/Makefile.objs |    2 +
 block/trace-events  |   40 ++
 block/vxhs.c        | 1199 +++++++++++++++++++++++++++++++++++++++++++++++++++
 block/vxhs.h        |  294 +++++++++++++
 configure           |   50 +++
 5 files changed, 1585 insertions(+)
 create mode 100644 block/vxhs.c
 create mode 100644 block/vxhs.h
block/vxhs.c new file +8 -0
new file mode 100644
index 0000000..9a82757
@@ -0,0 +1,1199 @@
+/*
+ * QEMU Block driver for Veritas HyperScale (VxHS)
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+

block/vxhs.c line 18

Quoted 10 lines
block/vxhs.c new file +10 -0
+#include "vxhs.h"
+#include <qnio/qnio_api.h>
+#include "trace.h"
+
+/* qnio client ioapi_ctx */
+static void __attribute__((unused)) *global_qnio_ctx;
+
+/* insure init once */
+static pthread_mutex_t __attribute__((unused))  of_global_ctx_lock =
+    PTHREAD_MUTEX_INITIALIZER;

Not sure why you're adding attribute__(unused) here, since both these vars are clearly used.

BTW, since we're using glib, you should use G_GNUC_UNUSD as the annotation, but since these vars are used, just drop the annotation entirely.

block/vxhs.c line 21

Quoted 3 lines
block/vxhs.c new file +3 -0
+
+/* HyperScale Driver Version */
+static const int __attribute__((unused)) vxhs_drv_version = 8895;

This only seems to be used in a single trace() message, so can probably be just deleted entirely

Quoted 61 lines
configure +32 -0
index f57fcc6..c4f6261 100755
@@ -320,6 +320,7 @@ vhdx=""
 numa=""
 tcmalloc="no"
 jemalloc="no"
+vxhs="yes"
 
 # parse CC options first
 for opt do
@@ -1150,6 +1151,11 @@ for opt do
   ;;
   --enable-jemalloc) jemalloc="yes"
   ;;
+  --disable-vxhs) vxhs="no"
+  ;;
+  --enable-vxhs) vxhs="yes"
+  ;;
+
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -1380,6 +1386,7 @@ disabled with --disable-FEATURE, default is enabled if available:
   numa            libnuma support
   tcmalloc        tcmalloc support
   jemalloc        jemalloc support
+  vxhs            Veritas HyperScale vDisk backend support
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -4543,6 +4550,43 @@ if do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then
 fi
 
 ##########################################
+# Veritas HyperScale block driver VxHS
+# Check if libqnio is installed
+if test "$vxhs" != "no" ; then
+  cat > $TMPC <<EOF
+#include <stdio.h>
+#include <qnio/qnio_api.h>
+
+void vxhs_inc_acb_segment_count(void *acb, int count);
+void vxhs_dec_acb_segment_count(void *acb, int count);
+void vxhs_set_acb_buffer(void *ptr, void *buffer);
+
+void vxhs_inc_acb_segment_count(void *ptr, int count)
+{
+}
+void vxhs_dec_acb_segment_count(void *ptr, int count)
+{
+}
+void vxhs_set_acb_buffer(void *ptr, void *buffer)
+{
+}
+int main(void) {
+    qemu_ck_initialize_lock();
+    return 0;
+}
+EOF

configure if do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then · line 4587

Quoted 10 lines
configure +10 -0
+  vxhs_libs="-lqnioshim -lqnio"
+  if compile_prog "" "$vxhs_libs" ; then
+    vxhs=yes
+  else
+    if test "$vxhs" = "yes" ; then
+      feature_not_found "vxhs block device" "Install libqnio. See github"
+    fi
+    vxhs=no
+  fi
+fi

There's nothing wrong with this code, but it occurs to me that since libqnio is a completely new library you've written yourself, it would be nice if you could add a pkg-config file to the libqio install. That would allow QEMU to detect libqnio using the standard pkg-config mechanism that most libraries uses these days.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
In reply to Ashish Mittal
Quoted 18 lines · Ashish Mittal

This patch adds support for a new block device type called "vxhs". Source code for the library that this code loads can be downloaded from:
https://github.com/MittalAshish/libqnio.git

Version 2 patch submission fixes the following issues:
(1) Removed code to dlopen library. We now check if libqnio is installed during configure, and directly link with it.
(2) Changed file headers to mention GPLv2-or-later license.
(3) Removed unnecessary type casts and inlines.
(4) Removed custom tokenize function and modified code to use g_strsplit.
(5) Replaced malloc/free with g_new/g_free and removed code that checks for memory allocation failure conditions.
(6) Removed some block ops implementations that were place-holders only.
(7) Removed all custom debug messages. Added new messages in block/trace-events
(8) Other miscellaneous corrections.

TODO: QAPI changes and (fixes to) review comments from Stefan.

Quoted 9 lines
---
 block/Makefile.objs |    2 +
 block/trace-events  |   40 ++
 block/vxhs.c        | 1199 +++++++++++++++++++++++++++++++++++++++++++++++++++
 block/vxhs.h        |  294 +++++++++++++
 configure           |   50 +++
 5 files changed, 1585 insertions(+)
 create mode 100644 block/vxhs.c
 create mode 100644 block/vxhs.h

I'll review v3 with the issues I raised addressed.

Please put the patch changelog below the '---' line. This way the changelog is not included in the git history when the patch is merged. The changelog is only useful while the patch is being discussed on the mailing list but shouldn't be included in the git-log(1) output. Typically it looks like this:

---
v2:
* Removed code to dlopen library. We now check if libqnio is installed during configure, and directly link with it.
...

#3 lore raw
In reply to Ashish Mittal

Am 08.08.2016 um 04:01 hat Ashish Mittal geschrieben:

Quoted 16 lines

This patch adds support for a new block device type called "vxhs". Source code for the library that this code loads can be downloaded from:
https://github.com/MittalAshish/libqnio.git

Version 2 patch submission fixes the following issues:
(1) Removed code to dlopen library. We now check if libqnio is installed during configure, and directly link with it.
(2) Changed file headers to mention GPLv2-or-later license.
(3) Removed unnecessary type casts and inlines.
(4) Removed custom tokenize function and modified code to use g_strsplit.
(5) Replaced malloc/free with g_new/g_free and removed code that checks for memory allocation failure conditions.
(6) Removed some block ops implementations that were place-holders only.
(7) Removed all custom debug messages. Added new messages in block/trace-events
(8) Other miscellaneous corrections.

Quoted 2 lines

TODO: QAPI changes and (fixes to) review comments from Stefan.

I just had a very high level look at the driver, and maybe it's better to discuss those general design points first before going to the details of the actual code.

So perhaps the most important thing is that I'm wondering whether we really got the right split between qemu and libqnio yet. Generally a library should be agnostic regarding its users, but libqnio has quite a few functions that contain 'qemu' in their name. To me, this is a sign that they might fit better in the qemu block driver.

The effect of keeping these function in libqnio is that, for example, you're reimplementing qemu's IO vector functions which you could directly use from the block driver, or that you do manual request splitting that the qemu block layer could be doing for you if you told it what the maximum size is.

Another point is that these days it's preferrable to implement .bdrv_co_preadv/pwritev rather than .bdrv_aio_readv/writev. Your native interfaces seem to be already byte based, so this should be a good match.

Kevin