Skip to contentSkip to conversation

rbd: add an asynchronous flush

PATCH Superseded Josh Durgin 8 participants 24 messages Mar 29, 2013 – Jun 21, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rbd: add an asynchronous flush

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

Implement this as bdrv_aio_flush, since it matches other aio functions in the rbd block driver, and leave out bdrv_co_flush_to_disk when the asynchronous version is available.

---
 block/rbd.c |   34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
block/rbd.c +32 -2
index 1a8ea6d..568b279 100644
@@ -63,7 +63,8 @@
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
-    RBD_AIO_DISCARD
+    RBD_AIO_DISCARD,
+    RBD_AIO_FLUSH
 } RBDAIOCmd;
 
 typedef struct RBDAIOCB {
@@ -659,6 +660,16 @@ static int rbd_aio_discard_wrapper(rbd_image_t image,
 #endif
 }
 
+static int rbd_aio_flush_wrapper(rbd_image_t image,
+                                 rbd_completion_t comp)
+{
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+    return rbd_aio_flush(image, comp);
+#else
+    return -ENOTSUP;
+#endif
+}
+
 static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
                                        int64_t sector_num,
                                        QEMUIOVector *qiov,
@@ -679,7 +690,7 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb = qemu_aio_get(&rbd_aiocb_info, bs, cb, opaque);
     acb->cmd = cmd;
     acb->qiov = qiov;
-    if (cmd == RBD_AIO_DISCARD) {
+    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
         acb->bounce = NULL;
     } else {
         acb->bounce = qemu_blockalign(bs, qiov->size);
@@ -723,6 +734,9 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
         break;
+    case RBD_AIO_FLUSH:
+        r = rbd_aio_flush_wrapper(s->image, c);
+        break;
     default:
         r = -EINVAL;
     }
@@ -762,6 +776,16 @@ static BlockDriverAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs,
                          RBD_AIO_WRITE);
 }
 
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+static BlockDriverAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
+                                            BlockDriverCompletionFunc *cb,
+                                            void *opaque)
+{
+    return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH);
+}
+
+#else
+
 static int qemu_rbd_co_flush(BlockDriverState *bs)
 {
 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
@@ -772,6 +796,7 @@ static int qemu_rbd_co_flush(BlockDriverState *bs)
     return 0;
 #endif
 }
+#endif
 
 static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi)
 {
@@ -949,7 +974,12 @@ static BlockDriver bdrv_rbd = {
 
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
+
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+    .bdrv_aio_flush         = qemu_rbd_aio_flush,
+#else
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
+#endif
 
 #ifdef LIBRBD_SUPPORTS_DISCARD
     .bdrv_aio_discard       = qemu_rbd_aio_discard,
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 rbd: add an asynchronous flush

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

Implement this as bdrv_aio_flush, since it matches other aio functions in the rbd block driver, and leave out bdrv_co_flush_to_disk when the asynchronous version is available.

---

v2:
* include hunk treating write, discard, and flush completions the same, since they have no result data

 block/rbd.c |   37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)
block/rbd.c +33 -4
index 1a8ea6d..141b488 100644
@@ -63,7 +63,8 @@
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
-    RBD_AIO_DISCARD
+    RBD_AIO_DISCARD,
+    RBD_AIO_FLUSH
 } RBDAIOCmd;
 
 typedef struct RBDAIOCB {
@@ -379,8 +380,7 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
 
     r = rcb->ret;
 
-    if (acb->cmd == RBD_AIO_WRITE ||
-        acb->cmd == RBD_AIO_DISCARD) {
+    if (acb->cmd != RBD_AIO_READ) {
         if (r < 0) {
             acb->ret = r;
             acb->error = 1;
@@ -659,6 +659,16 @@ static int rbd_aio_discard_wrapper(rbd_image_t image,
 #endif
 }
 
+static int rbd_aio_flush_wrapper(rbd_image_t image,
+                                 rbd_completion_t comp)
+{
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+    return rbd_aio_flush(image, comp);
+#else
+    return -ENOTSUP;
+#endif
+}
+
 static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
                                        int64_t sector_num,
                                        QEMUIOVector *qiov,
@@ -679,7 +689,7 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb = qemu_aio_get(&rbd_aiocb_info, bs, cb, opaque);
     acb->cmd = cmd;
     acb->qiov = qiov;
-    if (cmd == RBD_AIO_DISCARD) {
+    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
         acb->bounce = NULL;
     } else {
         acb->bounce = qemu_blockalign(bs, qiov->size);
@@ -723,6 +733,9 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
         break;
+    case RBD_AIO_FLUSH:
+        r = rbd_aio_flush_wrapper(s->image, c);
+        break;
     default:
         r = -EINVAL;
     }
@@ -762,6 +775,16 @@ static BlockDriverAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs,
                          RBD_AIO_WRITE);
 }
 
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+static BlockDriverAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
+                                            BlockDriverCompletionFunc *cb,
+                                            void *opaque)
+{
+    return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH);
+}
+
+#else
+
 static int qemu_rbd_co_flush(BlockDriverState *bs)
 {
 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
@@ -772,6 +795,7 @@ static int qemu_rbd_co_flush(BlockDriverState *bs)
     return 0;
 #endif
 }
+#endif
 
 static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi)
 {
@@ -949,7 +973,12 @@ static BlockDriver bdrv_rbd = {
 
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
+
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+    .bdrv_aio_flush         = qemu_rbd_aio_flush,
+#else
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
+#endif
 
 #ifdef LIBRBD_SUPPORTS_DISCARD
     .bdrv_aio_discard       = qemu_rbd_aio_discard,
Signature · 1 line
1.7.9.5
#2 lore raw

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 9 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

Quoted 6 lines

Implement this as bdrv_aio_flush, since it matches other aio functions in the rbd block driver, and leave out bdrv_co_flush_to_disk when the asynchronous version is available.

Looks good otherwise.

Kevin

#3 lore raw

PATCH v3 1/2 rbd: add an asynchronous flush

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

Implement this as bdrv_aio_flush, since it matches other aio functions in the rbd block driver, and leave out bdrv_co_flush_to_disk when the asynchronous version is available.

---

Since v2:
* remove #ifdefs around bdrv_aio_flush and qemu_rbd_aio_flush, since they are dealt with at runtime in the next patch

 block/rbd.c |   30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
block/rbd.c +26 -4
index 1a8ea6d..037d82b 100644
@@ -63,7 +63,8 @@
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
-    RBD_AIO_DISCARD
+    RBD_AIO_DISCARD,
+    RBD_AIO_FLUSH
 } RBDAIOCmd;
 
 typedef struct RBDAIOCB {
@@ -379,8 +380,7 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
 
     r = rcb->ret;
 
-    if (acb->cmd == RBD_AIO_WRITE ||
-        acb->cmd == RBD_AIO_DISCARD) {
+    if (acb->cmd != RBD_AIO_READ) {
         if (r < 0) {
             acb->ret = r;
             acb->error = 1;
@@ -659,6 +659,16 @@ static int rbd_aio_discard_wrapper(rbd_image_t image,
 #endif
 }
 
+static int rbd_aio_flush_wrapper(rbd_image_t image,
+                                 rbd_completion_t comp)
+{
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
+    return rbd_aio_flush(image, comp);
+#else
+    return -ENOTSUP;
+#endif
+}
+
 static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
                                        int64_t sector_num,
                                        QEMUIOVector *qiov,
@@ -679,7 +689,7 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb = qemu_aio_get(&rbd_aiocb_info, bs, cb, opaque);
     acb->cmd = cmd;
     acb->qiov = qiov;
-    if (cmd == RBD_AIO_DISCARD) {
+    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
         acb->bounce = NULL;
     } else {
         acb->bounce = qemu_blockalign(bs, qiov->size);
@@ -723,6 +733,9 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
         break;
+    case RBD_AIO_FLUSH:
+        r = rbd_aio_flush_wrapper(s->image, c);
+        break;
     default:
         r = -EINVAL;
     }
@@ -762,6 +775,13 @@ static BlockDriverAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs,
                          RBD_AIO_WRITE);
 }
 
+static BlockDriverAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
+                                            BlockDriverCompletionFunc *cb,
+                                            void *opaque)
+{
+    return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH);
+}
+
 static int qemu_rbd_co_flush(BlockDriverState *bs)
 {
 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
@@ -949,6 +969,8 @@ static BlockDriver bdrv_rbd = {
 
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
+
+    .bdrv_aio_flush         = qemu_rbd_aio_flush,
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
 
 #ifdef LIBRBD_SUPPORTS_DISCARD
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 2/2 rbd: disable unsupported librbd functions at runtime

QEMU may be compiled against a newer version of librbd, but run and dynamically linked with an older version that does not support these functions. Declare them as weak symbols so they can be checked for existence at runtime.

Only rbd_aio_discard, rbd_aio_flush, and rbd_flush were added after the initial version of librbd, so only they need to be checked.

---
 block/rbd.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
block/rbd.c +19 -0
index 037d82b..69a339a 100644
@@ -44,6 +44,15 @@
  * leading "\".
  */
 
+/*
+ * Treat newer librbd functions as weak symbols so we can detect
+ * whether they're supported at runtime, and disable their use
+ * if they aren't available.
+ */
+#pragma weak rbd_aio_discard
+#pragma weak rbd_aio_flush
+#pragma weak rbd_flush
+
 /* rbd_aio_discard added in 0.1.2 */
 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
 #define LIBRBD_SUPPORTS_DISCARD
@@ -970,6 +979,7 @@ static BlockDriver bdrv_rbd = {
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
 
+    /* select which of these to use at runtime in bdrv_rbd_init */
     .bdrv_aio_flush         = qemu_rbd_aio_flush,
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
 
@@ -985,6 +995,15 @@ static BlockDriver bdrv_rbd = {
 
 static void bdrv_rbd_init(void)
 {
+    if (!rbd_flush || rbd_aio_flush) {
+        bdrv_rbd.bdrv_co_flush_to_disk = NULL;
+    }
+    if (!rbd_aio_flush) {
+        bdrv_rbd.bdrv_aio_flush = NULL;
+    }
+    if (!rbd_aio_discard) {
+        bdrv_rbd.bdrv_aio_discard = NULL;
+    }
     bdrv_register(&bdrv_rbd);
 }
 
Signature · 1 line
1.7.9.5
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] rbd: disable unsupported librbd functions at runtime

Am 04.04.2013 um 10:35 hat Josh Durgin geschrieben:

Quoted 46 lines

QEMU may be compiled against a newer version of librbd, but run and dynamically linked with an older version that does not support these functions. Declare them as weak symbols so they can be checked for existence at runtime.

Only rbd_aio_discard, rbd_aio_flush, and rbd_flush were added after the initial version of librbd, so only they need to be checked.

---
 block/rbd.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
block/rbd.c +11 -0
index 037d82b..69a339a 100644
@@ -44,6 +44,15 @@
  * leading "\".
  */
 
+/*
+ * Treat newer librbd functions as weak symbols so we can detect
+ * whether they're supported at runtime, and disable their use
+ * if they aren't available.
+ */
+#pragma weak rbd_aio_discard
+#pragma weak rbd_aio_flush
+#pragma weak rbd_flush
+
 /* rbd_aio_discard added in 0.1.2 */
 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
 #define LIBRBD_SUPPORTS_DISCARD
@@ -970,6 +979,7 @@ static BlockDriver bdrv_rbd = {
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
 
+    /* select which of these to use at runtime in bdrv_rbd_init */
     .bdrv_aio_flush         = qemu_rbd_aio_flush,
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
 
@@ -985,6 +995,15 @@ static BlockDriver bdrv_rbd = {
 
 static void bdrv_rbd_init(void)
 {
+    if (!rbd_flush || rbd_aio_flush) {

block/rbd.c static BlockDriver bdrv_rbd = { · line 1008

Quoted 10 lines
block/rbd.c +8 -0
+        bdrv_rbd.bdrv_co_flush_to_disk = NULL;
+    }
+    if (!rbd_aio_flush) {
+        bdrv_rbd.bdrv_aio_flush = NULL;
+    }
+    if (!rbd_aio_discard) {
+        bdrv_rbd.bdrv_aio_discard = NULL;
+    }
     bdrv_register(&bdrv_rbd);
 }

After searching the net a bit and trying out some things myself, I'm afraid that this approach doesn't work. It does seem to do the right thing when build and runtime version are the same, but new build -> old runtime segfaults (because the symbol doesn't become NULL) and old build -> new runtime segfaults (because the symbol stays NULL). Unless I missed some build option that is different in qemu than in my test program.

So it looks as if you had to use dlsym() instead.

Kevin

#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] rbd: disable unsupported librbd functions at runtime

Quoted 58 lines · Kevin Wolf

Am 04.04.2013 um 10:35 hat Josh Durgin geschrieben:

Quoted 46 lines

QEMU may be compiled against a newer version of librbd, but run and dynamically linked with an older version that does not support these functions. Declare them as weak symbols so they can be checked for existence at runtime.

Only rbd_aio_discard, rbd_aio_flush, and rbd_flush were added after the initial version of librbd, so only they need to be checked.

---
  block/rbd.c |   19 +++++++++++++++++++
  1 file changed, 19 insertions(+)
block/rbd.c +11 -0
index 037d82b..69a339a 100644
@@ -44,6 +44,15 @@
   * leading "\".
   */
 
+/*
+ * Treat newer librbd functions as weak symbols so we can detect
+ * whether they're supported at runtime, and disable their use
+ * if they aren't available.
+ */
+#pragma weak rbd_aio_discard
+#pragma weak rbd_aio_flush
+#pragma weak rbd_flush
+
  /* rbd_aio_discard added in 0.1.2 */
  #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
  #define LIBRBD_SUPPORTS_DISCARD
@@ -970,6 +979,7 @@ static BlockDriver bdrv_rbd = {
      .bdrv_aio_readv         = qemu_rbd_aio_readv,
      .bdrv_aio_writev        = qemu_rbd_aio_writev,
 
+    /* select which of these to use at runtime in bdrv_rbd_init */
      .bdrv_aio_flush         = qemu_rbd_aio_flush,
      .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
 
@@ -985,6 +995,15 @@ static BlockDriver bdrv_rbd = {
 
  static void bdrv_rbd_init(void)
  {
+    if (!rbd_flush || rbd_aio_flush) {

block/rbd.c static BlockDriver bdrv_rbd = { · line 1008

Quoted 10 lines
block/rbd.c +8 -0
+        bdrv_rbd.bdrv_co_flush_to_disk = NULL;
+    }
+    if (!rbd_aio_flush) {
+        bdrv_rbd.bdrv_aio_flush = NULL;
+    }
+    if (!rbd_aio_discard) {
+        bdrv_rbd.bdrv_aio_discard = NULL;
+    }
      bdrv_register(&bdrv_rbd);
  }
Quoted 7 lines

After searching the net a bit and trying out some things myself, I'm afraid that this approach doesn't work. It does seem to do the right thing when build and runtime version are the same, but new build -> old runtime segfaults (because the symbol doesn't become NULL) and old build -> new runtime segfaults (because the symbol stays NULL). Unless I missed some build option that is different in qemu than in my test program.

It worked when downgrading the runtime version of librbd for me, so maybe something about qemu's build was different. This patch wouldn't allow newer functions in a runtime version to be used though, since they would be disabled if qemu were built against an older version.

Quoted 1 line

So it looks as if you had to use dlsym() instead.

I tried this initially, using glib's portable wrappers, but found that it would require using the dlopen'd version only - not linking at build time against librbd at all. I thought this might be too big a change, but now it seems like the best way to go.

Using this approach, upgrading from a version of librbd that doesn't support e.g. rbd_aio_flush to one that does would not require recompiling qemu to be able to use the new function. In general, librbd would not be needed at compile time for qemu to be able to use it, which would make the rbd block driver much easier to install on distros where rbd isn't enabled at build time.

If you don't mind this approach, I'll post another version using only dlopen'd (via glib) librbd/librados.

Thanks for the reviews,
Josh

#7 lore raw

Re: [Qemu-devel] [PATCH 2/2] rbd: disable unsupported librbd functions at runtime

Am 04.04.2013 um 18:50 hat Josh Durgin geschrieben:

Quoted 9 lines · Kevin Wolf
Quoted 7 lines

After searching the net a bit and trying out some things myself, I'm afraid that this approach doesn't work. It does seem to do the right thing when build and runtime version are the same, but new build -> old runtime segfaults (because the symbol doesn't become NULL) and old build -> new runtime segfaults (because the symbol stays NULL). Unless I missed some build option that is different in qemu than in my test program.

Quoted 4 lines

It worked when downgrading the runtime version of librbd for me, so maybe something about qemu's build was different. This patch wouldn't allow newer functions in a runtime version to be used though, since they would be disabled if qemu were built against an older version.

Interesting that one way worked for you. At least it seems to be unreliable, unfortunately.

Quoted 6 lines
Quoted 1 line

So it looks as if you had to use dlsym() instead.

I tried this initially, using glib's portable wrappers, but found that it would require using the dlopen'd version only - not linking at build time against librbd at all. I thought this might be too big a change, but now it seems like the best way to go.

Aw, I didn't expect that... You're using g_module_open/symbol then? I never used it, but from reading the docs maybe g_module_open with a NULL filename might do the right thing when linked at build time?

On the other hand, not linking at build time at all and relying on dlopen() only give us another nice feature: Distros can enable the rbd block driver without introducing a hard dependency of qemu on librbd. Maybe worth doing it for this reason alone.

Quoted 9 lines

Using this approach, upgrading from a version of librbd that doesn't support e.g. rbd_aio_flush to one that does would not require recompiling qemu to be able to use the new function. In general, librbd would not be needed at compile time for qemu to be able to use it, which would make the rbd block driver much easier to install on distros where rbd isn't enabled at build time.

If you don't mind this approach, I'll post another version using only dlopen'd (via glib) librbd/librados.

Sure, if you don't mind implementing it I think it's a good idea. I didn't mean to ask you for such a large change with my innocent comments...

Kevin

#8 lore raw

PATCH v3 2/2 rbd: link and load librbd dynamically

This allows the rbd block driver to detect symbols in the installed version of librbd, and enable or disable features appropriately. This obviates the #ifdefs regarding librbd versions.

Loading librbd dynamically also makes the rbd block driver easier to install and package, since it removes the dependency on librbd at build time.

Add structures containing the necessary function pointer signatures and types from librbd, and fill them in the first time the rbd module is used. Use glib's g_module interface so we don't preclude future portability, and don't have to deal with odd dlopen behavior directly.

Internally, librbd and some libraries it depends on use C++ templates, which mean that they each contain a defined weak symbol for their definition. Due to the way the linker resolves duplicate symbols, the libraries loaded by librbd end up using the template definitions from librbd, creating a circular dependency. This means that once librbd is loaded, it won't be unloaded. Changing this behavior might work with a Sun ld, but there doesn't seem to be a portable (or even working with GNU ld) way to hide these C++ symbols correctly. Instead, never unload librbd, and explicitly make it resident.

---
 block/Makefile.objs |    3 +-
 block/rbd.c         |  292 ++++++++++++++++++++++++++++++++++++---------------
 block/rbd_types.h   |   95 +++++++++++++++++
 configure           |   41 +-------
 4 files changed, 309 insertions(+), 122 deletions(-)
 create mode 100644 block/rbd_types.h
block/Makefile.objs +1 -2
index c067f38..2ad32f7 100644
@@ -8,10 +8,9 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o rbd.o sheepdog.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
 block-obj-$(CONFIG_CURL) += curl.o
-block-obj-$(CONFIG_RBD) += rbd.o
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
 endif
 
block/rbd.c +210 -82

519 lines not on this page · raw message

block/rbd_types.h new file +95 -0

95 lines not on this page · raw message

configure +3 -38

84 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#9 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

Quoted 23 lines · Josh Durgin

This allows the rbd block driver to detect symbols in the installed version of librbd, and enable or disable features appropriately. This obviates the #ifdefs regarding librbd versions.

Loading librbd dynamically also makes the rbd block driver easier to install and package, since it removes the dependency on librbd at build time.

Add structures containing the necessary function pointer signatures and types from librbd, and fill them in the first time the rbd module is used. Use glib's g_module interface so we don't preclude future portability, and don't have to deal with odd dlopen behavior directly.

Internally, librbd and some libraries it depends on use C++ templates, which mean that they each contain a defined weak symbol for their definition. Due to the way the linker resolves duplicate symbols, the libraries loaded by librbd end up using the template definitions from librbd, creating a circular dependency. This means that once librbd is loaded, it won't be unloaded. Changing this behavior might work with a Sun ld, but there doesn't seem to be a portable (or even working with GNU ld) way to hide these C++ symbols correctly. Instead, never unload librbd, and explicitly make it resident.

Quoted 8 lines
---
 block/Makefile.objs |    3 +-
 block/rbd.c         |  292 ++++++++++++++++++++++++++++++++++++---------------
 block/rbd_types.h   |   95 +++++++++++++++++
 configure           |   41 +-------
 4 files changed, 309 insertions(+), 122 deletions(-)
 create mode 100644 block/rbd_types.h

NACK

I think we're solving the problem at the wrong level. Writing our own dynamic linker and adding boilerplate to juggle function pointers every time we use a library dependency is ugly.

There are two related problems here:

1. Packagers do not want to enable niche dependencies since users will complain that the package is bloated and pulls in too much stuff.

2. QEMU linked against a newer library version fails to run on hosts that have an older library.

Problem #1 has several solutions:

1. Let packagers take care of it. For example, vim is often shipped in several packages that have various amounts of dependencies (vim-tiny, vim-gtk, etc). Packagers create the specialized packages for specific groups of users to meet their demands without dragging in too many dependencies.

2. Make QEMU modular - host devices should be shared libraries that are loaded at runtime. There should be no stable API so that development stays flexible and we discourage binary-only modules. This lets packagers easily ship a qemu-rbd package, for example, that drops in a .so file that QEMU can load at runtime.

Problem #2 is already solved:

The dynamic linker will refuse to load the program if there are missing symbols. It's not possible to mix and match binaries across environments while downgrading their library dependencies. With effort, this could be doable but it's not an interesting use case that many users care about - they get their binaries from a distro or build them from source with correct dependencies.

Maybe it's time to move block drivers and other components into modules?

Stefan

#10 lore raw

Re: [Qemu-devel] runtime Block driver modules (was Re: [PATCH v3 2/2] rbd: link and load librbd dynamically)

Quoted 33 lines · Stefan Hajnoczi
Quoted 23 lines · Josh Durgin

This allows the rbd block driver to detect symbols in the installed version of librbd, and enable or disable features appropriately. This obviates the #ifdefs regarding librbd versions.

Loading librbd dynamically also makes the rbd block driver easier to install and package, since it removes the dependency on librbd at build time.

Add structures containing the necessary function pointer signatures and types from librbd, and fill them in the first time the rbd module is used. Use glib's g_module interface so we don't preclude future portability, and don't have to deal with odd dlopen behavior directly.

Internally, librbd and some libraries it depends on use C++ templates, which mean that they each contain a defined weak symbol for their definition. Due to the way the linker resolves duplicate symbols, the libraries loaded by librbd end up using the template definitions from librbd, creating a circular dependency. This means that once librbd is loaded, it won't be unloaded. Changing this behavior might work with a Sun ld, but there doesn't seem to be a portable (or even working with GNU ld) way to hide these C++ symbols correctly. Instead, never unload librbd, and explicitly make it resident.

Quoted 8 lines
---
  block/Makefile.objs |    3 +-
  block/rbd.c         |  292 ++++++++++++++++++++++++++++++++++++---------------
  block/rbd_types.h   |   95 +++++++++++++++++
  configure           |   41 +-------
  4 files changed, 309 insertions(+), 122 deletions(-)

create mode 100644 block/rbd_types.h

Quoted 5 lines

NACK

I think we're solving the problem at the wrong level. Writing our own dynamic linker and adding boilerplate to juggle function pointers every time we use a library dependency is ugly.

I wouldn't call this writing our own dynamic linker. To load a library at runtime requires some boilerplate and using function pointers, although there could be cleaner ways of setting it up.

Quoted 7 lines

There are two related problems here:

1. Packagers do not want to enable niche dependencies since users will complain that the package is bloated and pulls in too much stuff.

2. QEMU linked against a newer library version fails to run on hosts that have an older library.

Related to 2, there's also a need to rebuild QEMU to be able to access new functionality in a newer version of a library than QEMU was linked against. This would be easier to do if the devices were modules themselves, since only the module that used the library would need to be rebuilt.

Quoted 16 lines

Problem #1 has several solutions:

1. Let packagers take care of it. For example, vim is often shipped in several packages that have various amounts of dependencies (vim-tiny, vim-gtk, etc). Packagers create the specialized packages for specific groups of users to meet their demands without dragging in too many dependencies.

2. Make QEMU modular - host devices should be shared libraries that are loaded at runtime. There should be no stable API so that development stays flexible and we discourage binary-only modules. This lets packagers easily ship a qemu-rbd package, for example, that drops in a .so file that QEMU can load at runtime.

Problem #2 is already solved:

Quoted 8 lines

The dynamic linker will refuse to load the program if there are missing symbols. It's not possible to mix and match binaries across environments while downgrading their library dependencies. With effort, this could be doable but it's not an interesting use case that many users care about - they get their binaries from a distro or build them from source with correct dependencies.

Maybe it's time to move block drivers and other components into modules?

I think that would be great. I'm not too familiar with the other components, so I'll discuss block drivers as a first step.

I could see this happening in at a few different ways. These could be incremental steps or final implementations, increasing in complexity and effort:

1) It seems like it would be possible to achieve an initial version of runtime loading with minimal driver changes by loading modules instead of using block_init(), and using the existing driver-specific block_init() methods (renamed to be the same across modules) as the only function. This would avoid the function pointer ugliness since it would be hidden by the existing BlockDriver structure.

2) The existing BlockDriver methods could become the module interface, with a couple extra functions for defining the current data members (format_name, protocol_name, instance_size, and create_options). The block layer could build up a BlockDriver for each module based on the functions it exports, detected by g_module_symbol().

3) An entirely different module interface from what exists today in the block drivers.

Thoughts?

Josh

#11 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

In reply to Stefan Hajnoczi
Quoted 38 lines · Stefan Hajnoczi

On Wed, Apr 10, 2013 at 2:05 AM, Josh Durgin <[email protected]> wrote:
NACK

I think we're solving the problem at the wrong level. Writing our own dynamic linker and adding boilerplate to juggle function pointers every time we use a library dependency is ugly.

There are two related problems here:

1. Packagers do not want to enable niche dependencies since users will complain that the package is bloated and pulls in too much stuff.

2. QEMU linked against a newer library version fails to run on hosts that have an older library.

Problem #1 has several solutions:

1. Let packagers take care of it. For example, vim is often shipped in several packages that have various amounts of dependencies (vim-tiny, vim-gtk, etc). Packagers create the specialized packages for specific groups of users to meet their demands without dragging in too many dependencies.

2. Make QEMU modular - host devices should be shared libraries that are loaded at runtime. There should be no stable API so that development stays flexible and we discourage binary-only modules. This lets packagers easily ship a qemu-rbd package, for example, that drops in a .so file that QEMU can load at runtime.

Problem #2 is already solved:

The dynamic linker will refuse to load the program if there are missing symbols. It's not possible to mix and match binaries across environments while downgrading their library dependencies. With effort, this could be doable but it's not an interesting use case that many users care about - they get their binaries from a distro or build them from source with correct dependencies.

Quoted 2 lines

Maybe it's time to move block drivers and other components into modules?

This is really a build system issue more than anything else. There are no internal API changes needed.

All that's needed is to something like (in module.h):

/* This should not be used directly. Use block_init etc. instead. */ #ifdef CONFIG_MODULE
#define module_init(function, type) \
const gchar *g_module_check_init(GModule *module) \

{				               	   \
    register_module_init(function, type);	   \
    return NULL;				   \
}
#else
#define module_init(function, type)                                         \
static void __attribute__((constructor)) do_qemu_init_ ## function(void) {  \
    register_module_init(function, type);                                   \

}
#endif

We then also need a way to load modules prior to calling init using the GModule interfaces. Easiest thing to do is just load all .so's in a single directory (/usr/lib/qemu/modules/*.so?) prior to calling any module init functions.

What we need from the build system is the ability to build things either builtin or as modules. Paolo has a GSoC proposal to integrate kconfig. This would be a great approach to solving this problem.

Doing it this way would let us build not only block drivers but also devices as modules. This would let us make QXL a module making it easier for distros to not have a hard dependence on libspice for the QEMU package.

Regards,

Anthony Liguori

Quoted 2 lines

Stefan

#12 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

Il 10/04/2013 17:08, Anthony Liguori ha scritto:

Quoted 12 lines

/* This should not be used directly. Use block_init etc. instead. */ #ifdef CONFIG_MODULE
#define module_init(function, type) \
const gchar *g_module_check_init(GModule *module) \

{				               	   \
    register_module_init(function, type);	   \
    return NULL;				   \
}
#else
#define module_init(function, type)                                         \
static void __attribute__((constructor)) do_qemu_init_ ## function(void) {  \
    register_module_init(function, type);                                   \
Quoted 2 lines

}
#endif

Not even that is needed. Modules can have constructor functions that use symbols in the main executable.

Basically, modules would be opened with G_MODULE_BIND_LOCAL and communicate with QEMU via constructor functions only (registering driver modules or QOM types).

It is really more of a build-system hacking project than anything else.

Paolo

Quoted 4 lines

We then also need a way to load modules prior to calling init using the GModule interfaces. Easiest thing to do is just load all .so's in a single directory (/usr/lib/qemu/modules/*.so?) prior to calling any module init functions.

#13 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

Quoted 16 lines · Paolo Bonzini

Il 10/04/2013 17:08, Anthony Liguori ha scritto:

Quoted 12 lines

/* This should not be used directly. Use block_init etc. instead. */ #ifdef CONFIG_MODULE
#define module_init(function, type) \
const gchar *g_module_check_init(GModule *module) \

{				               	   \
    register_module_init(function, type);	   \
    return NULL;				   \
}
#else
#define module_init(function, type)                                         \
static void __attribute__((constructor)) do_qemu_init_ ## function(void) {  \
    register_module_init(function, type);                                   \
Quoted 2 lines

}
#endif

Quoted 8 lines

Not even that is needed. Modules can have constructor functions that use symbols in the main executable.

Basically, modules would be opened with G_MODULE_BIND_LOCAL and communicate with QEMU via constructor functions only (registering driver modules or QOM types).

It is really more of a build-system hacking project than anything else.

Great. So it seems like we just need a function early in QEMU startup that enumerates all shared libraries in QEMU_MODULE_PATH and opens them with G_MODULE_BIND_LOCAL.

Perhaps in the future we'll load modules on-demand to avoid reduce footprint, but for now we can just load all of them just like you get when you build a QEMU binary with everything included.

Stefan

#14 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

In reply to Anthony Liguori
Quoted 68 lines · Anthony Liguori
Quoted 38 lines · Stefan Hajnoczi

On Wed, Apr 10, 2013 at 2:05 AM, Josh Durgin <[email protected]> wrote:
NACK

I think we're solving the problem at the wrong level. Writing our own dynamic linker and adding boilerplate to juggle function pointers every time we use a library dependency is ugly.

There are two related problems here:

1. Packagers do not want to enable niche dependencies since users will complain that the package is bloated and pulls in too much stuff.

2. QEMU linked against a newer library version fails to run on hosts that have an older library.

Problem #1 has several solutions:

1. Let packagers take care of it. For example, vim is often shipped in several packages that have various amounts of dependencies (vim-tiny, vim-gtk, etc). Packagers create the specialized packages for specific groups of users to meet their demands without dragging in too many dependencies.

2. Make QEMU modular - host devices should be shared libraries that are loaded at runtime. There should be no stable API so that development stays flexible and we discourage binary-only modules. This lets packagers easily ship a qemu-rbd package, for example, that drops in a .so file that QEMU can load at runtime.

Problem #2 is already solved:

The dynamic linker will refuse to load the program if there are missing symbols. It's not possible to mix and match binaries across environments while downgrading their library dependencies. With effort, this could be doable but it's not an interesting use case that many users care about - they get their binaries from a distro or build them from source with correct dependencies.

Quoted 2 lines

Maybe it's time to move block drivers and other components into modules?

This is really a build system issue more than anything else. There are no internal API changes needed.

All that's needed is to something like (in module.h):

/* This should not be used directly. Use block_init etc. instead. */ #ifdef CONFIG_MODULE
#define module_init(function, type) \
const gchar *g_module_check_init(GModule *module) \

{				               	   \
    register_module_init(function, type);	   \
    return NULL;				   \
}
#else
#define module_init(function, type)                                         \
static void __attribute__((constructor)) do_qemu_init_ ## function(void) {  \
    register_module_init(function, type);                                   \

}
#endif

We then also need a way to load modules prior to calling init using the GModule interfaces. Easiest thing to do is just load all .so's in a single directory (/usr/lib/qemu/modules/*.so?) prior to calling any module init functions.

Quoted 8 lines

What we need from the build system is the ability to build things either builtin or as modules. Paolo has a GSoC proposal to integrate kconfig. This would be a great approach to solving this problem.

Doing it this way would let us build not only block drivers but also devices as modules. This would let us make QXL a module making it easier for distros to not have a hard dependence on libspice for the QEMU package.

I'd love to do this for the net subsystem as well so distros can provide the qemu-net-vde package without requiring a VDE dependency from the core QEMU package.

Stefan

#15 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

In reply to Anthony Liguori

Hi Anthony, Stefan, Paolo,

[Resurrecting an old thread, here!]

Quoted 58 lines · On Wed, 10 Apr 2013 Anthony Liguori wrote:
Quoted 37 lines · Stefan Hajnoczi

NACK

I think we're solving the problem at the wrong level. Writing our own dynamic linker and adding boilerplate to juggle function pointers every time we use a library dependency is ugly.

There are two related problems here:

1. Packagers do not want to enable niche dependencies since users will complain that the package is bloated and pulls in too much stuff.

2. QEMU linked against a newer library version fails to run on hosts that have an older library.

Problem #1 has several solutions:

1. Let packagers take care of it. For example, vim is often shipped in several packages that have various amounts of dependencies (vim-tiny, vim-gtk, etc). Packagers create the specialized packages for specific groups of users to meet their demands without dragging in too many dependencies.

2. Make QEMU modular - host devices should be shared libraries that are loaded at runtime. There should be no stable API so that development stays flexible and we discourage binary-only modules. This lets packagers easily ship a qemu-rbd package, for example, that drops in a .so file that QEMU can load at runtime.

Problem #2 is already solved:

The dynamic linker will refuse to load the program if there are missing symbols. It's not possible to mix and match binaries across environments while downgrading their library dependencies. With effort, this could be doable but it's not an interesting use case that many users care about - they get their binaries from a distro or build them from source with correct dependencies.

Quoted 2 lines

Maybe it's time to move block drivers and other components into modules?

This is really a build system issue more than anything else. There are no internal API changes needed.

All that's needed is to something like (in module.h):

/* This should not be used directly. Use block_init etc. instead. */ #ifdef CONFIG_MODULE
#define module_init(function, type) \
const gchar *g_module_check_init(GModule *module) \

{				               	   \
    register_module_init(function, type);	   \
    return NULL;				   \
}
#else
#define module_init(function, type)                                         \
static void __attribute__((constructor)) do_qemu_init_ ## function(void) {  \
    register_module_init(function, type);                                   \
Quoted 2 lines

}
#endif

Has any progress been made toward a generic dynamic linking solution for block drivers? It is a conceptually simple change, but non-trivial for anyone unfamiliar with the build system.

In the mean time, the inability to dynamically link librbd is continuing to cause significant pain for distro users. Would you consider merging the rbd-specific linking as an interim solution until something is generically available to qemu?

sage

#16 lore raw

Re: [PATCH v3 2/2] rbd: link and load librbd dynamically

Quoted 8 lines · --On 21 June 2013 11:42:34 -0700 Sage Weil <[email protected]> wrote:

Has any progress been made toward a generic dynamic linking solution for block drivers? It is a conceptually simple change, but non-trivial for anyone unfamiliar with the build system.

In the mean time, the inability to dynamically link librbd is continuing to cause significant pain for distro users. Would you consider merging the rbd-specific linking as an interim solution until something is generically available to qemu?

FWIW I have this implemented here:
https://github.com/flexiant/qemu/commits/v1.0-rbd-add-async-flush

specifically this commit:
https://github.com/flexiant/qemu/commit/6fa2e9c95bdaca7c814881e27f04424fb6cc
2960

This is a backport of qemu 1.5's librbd to qemu 1.0 (which is slighly confusing) but the #pragma weak technique is basically the same.

I had to use a slightly different technique to Josh's original version to get it to compile with old includes and still run with a new library, as well as vice versa.

It would take me only a few minutes to bring this back as a patch for 1.5 if anyone is interested. I assumed they would not be.

Signature · 1 line
Alex Bligh
#17 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] rbd: link and load librbd dynamically

In reply to Sage Weil
Quoted 9 lines · Sage Weil

Hi Anthony, Stefan, Paolo,

[Resurrecting an old thread, here!]

On Wed, 10 Apr 2013 Anthony Liguori wrote:

Has any progress been made toward a generic dynamic linking solution for block drivers? It is a conceptually simple change, but non-trivial for anyone unfamiliar with the build system.

There are patches on the list in fact.

Quoted 4 lines

In the mean time, the inability to dynamically link librbd is continuing to cause significant pain for distro users. Would you consider merging the rbd-specific linking as an interim solution until something is generically available to qemu?

Regards,

Anthony Liguori

Quoted 2 lines

sage

#18 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 5 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Quoted 8 lines
Quoted 4 lines

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Josh

Quoted 11 lines
Quoted 6 lines

Implement this as bdrv_aio_flush, since it matches other aio functions in the rbd block driver, and leave out bdrv_co_flush_to_disk when the asynchronous version is available.

Looks good otherwise.

Kevin

#19 lore raw
Quoted 12 lines · Josh Durgin
Quoted 11 lines · Kevin Wolf

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 9 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

Quoted 6 lines
Quoted 3 lines

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Hi Josh,
I'm happy with Patch v3 1/2. Does that work for you?

I don't want to take Patch v3 2/2 or the dlsym() function pointer patch.

Stefan

#20 lore raw

Am 11.04.2013 um 10:02 hat Stefan Hajnoczi geschrieben:

Quoted 17 lines · Josh Durgin
Quoted 16 lines · Kevin Wolf
Quoted 14 lines

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 9 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

Quoted 5 lines
Quoted 2 lines

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Hi Josh,
I'm happy with Patch v3 1/2. Does that work for you?

Only patch 1/2 would add dead code as .bdrv_aio_flush would never be called. I think we should rather take v1 of the series then, with the #ifdefs at build time.

Kevin

#21 lore raw
Quoted 21 lines · Kevin Wolf

Am 11.04.2013 um 10:02 hat Stefan Hajnoczi geschrieben:

Quoted 20 lines · Josh Durgin
Quoted 18 lines · Kevin Wolf
Quoted 6 lines

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 5 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Quoted 8 lines
Quoted 4 lines

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Quoted 6 lines
Quoted 2 lines

Hi Josh,
I'm happy with Patch v3 1/2. Does that work for you?

Only patch 1/2 would add dead code as .bdrv_aio_flush would never be called. I think we should rather take v1 of the series then, with the #ifdefs at build time.

Yes, that would be a problem with only v3 1/2. v2 of the original series is fine, but v1 was accidentally missing a hunk. To be clear, I think just http://patchwork.ozlabs.org/patch/232489/ would be good.

Thanks,
Josh

#22 lore raw

Am 11.04.2013 um 19:19 hat Josh Durgin geschrieben:

Quoted 25 lines · Kevin Wolf
Quoted 24 lines

Am 11.04.2013 um 10:02 hat Stefan Hajnoczi geschrieben:

Quoted 22 lines · Josh Durgin
Quoted 12 lines · Kevin Wolf
Quoted 11 lines

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 9 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

Quoted 6 lines
Quoted 3 lines

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Hi Josh,
I'm happy with Patch v3 1/2. Does that work for you?

Quoted 7 lines
Quoted 3 lines

Only patch 1/2 would add dead code as .bdrv_aio_flush would never be called. I think we should rather take v1 of the series then, with the #ifdefs at build time.

Yes, that would be a problem with only v3 1/2. v2 of the original series is fine, but v1 was accidentally missing a hunk. To be clear, I think just http://patchwork.ozlabs.org/patch/232489/ would be good.

Yes, sorry, I should have checked before posting this. v2 I meant.

Kevin

#23 lore raw
Quoted 30 lines · Kevin Wolf

Am 11.04.2013 um 19:19 hat Josh Durgin geschrieben:

Quoted 29 lines · Kevin Wolf
Quoted 27 lines

Am 11.04.2013 um 10:02 hat Stefan Hajnoczi geschrieben:

Quoted 17 lines · Josh Durgin
Quoted 16 lines · Kevin Wolf
Quoted 14 lines

Am 29.03.2013 um 21:03 hat Josh Durgin geschrieben:

Quoted 9 lines

The existing bdrv_co_flush_to_disk implementation uses rbd_flush(), which is sychronous and causes the main qemu thread to block until it is complete. This results in unresponsiveness and extra latency for the guest.

Fix this by using an asynchronous version of flush. This was added to librbd with a special #define to indicate its presence, since it will be backported to stable versions. Thus, there is no need to check the version of librbd.

librbd is linked dynamically and the version on the build host isn't necessarily the same as the version qemu is run with. So shouldn't this better be a runtime check?

Quoted 5 lines
Quoted 2 lines

While we discuss runtime loading separately, would you mind taking this patch as-is for now?

Hi Josh,
I'm happy with Patch v3 1/2. Does that work for you?

Only patch 1/2 would add dead code as .bdrv_aio_flush would never be called. I think we should rather take v1 of the series then, with the #ifdefs at build time.

Quoted 5 lines
Quoted 3 lines

Yes, that would be a problem with only v3 1/2. v2 of the original series is fine, but v1 was accidentally missing a hunk. To be clear, I think just http://patchwork.ozlabs.org/patch/232489/ would be good.

Yes, sorry, I should have checked before posting this. v2 I meant.

Thanks Josh and Kevin. Will take v2.

Stefan