All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-21  6:50 ` jazeltq
  0 siblings, 0 replies; 12+ messages in thread
From: jazeltq @ 2017-02-21  6:50 UTC (permalink / raw)
  To: jdurgin, jcody, dillaman, kwolf, mreitz, qemu-block
  Cc: tianqing, ceph-devel, jazeltq, qemu-devel

From: tianqing <tianqing@unitedstack.com>

Rbd can do readv and writev directly, so wo do not need to transform
iov to buf or vice versa any more.

Signed-off-by: tianqing <tianqing@unitedstack.com>
---
 block/rbd.c | 80 ++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 56 insertions(+), 24 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index a57b3e3..22e8e69 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -62,6 +62,13 @@
 #define RBD_MAX_SNAP_NAME_SIZE 128
 #define RBD_MAX_SNAPS 100
 
+/* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
+#ifdef LIBRBD_SUPPORTS_IOVEC
+#define LIBRBD_USE_IOVEC 1
+#else
+#define LIBRBD_USE_IOVEC 0
+#endif
+
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
@@ -310,6 +317,17 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
     return ret;
 }
 
+static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
+{
+    if (LIBRBD_USE_IOVEC) {
+        RBDAIOCB *acb = rcb->acb;
+        iov_memset(acb->qiov->iov, acb->qiov->niov, offs, 0,
+                   acb->qiov->size - offs);
+    } else {
+        memset(rcb->buf + offs, 0, rcb->size - offs);
+    }
+}
+
 static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
 {
     Error *local_err = NULL;
@@ -426,11 +444,11 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
         }
     } else {
         if (r < 0) {
-            memset(rcb->buf, 0, rcb->size);
+            qemu_rbd_memset(rcb, 0);
             acb->ret = r;
             acb->error = 1;
         } else if (r < rcb->size) {
-            memset(rcb->buf + r, 0, rcb->size - r);
+            qemu_rbd_memset(rcb, r);
             if (!acb->error) {
                 acb->ret = rcb->size;
             }
@@ -441,10 +459,13 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
 
     g_free(rcb);
 
-    if (acb->cmd == RBD_AIO_READ) {
-        qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+    if (!LIBRBD_USE_IOVEC) {
+        if (acb->cmd == RBD_AIO_READ) {
+            qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+        }
+        qemu_vfree(acb->bounce);
     }
-    qemu_vfree(acb->bounce);
+
     acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
 
     qemu_aio_unref(acb);
@@ -655,7 +676,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     RBDAIOCB *acb;
     RADOSCB *rcb = NULL;
     rbd_completion_t c;
-    char *buf;
     int r;
 
     BDRVRBDState *s = bs->opaque;
@@ -664,27 +684,29 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb->cmd = cmd;
     acb->qiov = qiov;
     assert(!qiov || qiov->size == size);
-    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
-        acb->bounce = NULL;
-    } else {
-        acb->bounce = qemu_try_blockalign(bs, qiov->size);
-        if (acb->bounce == NULL) {
-            goto failed;
+
+    rcb = g_new(RADOSCB, 1);
+
+    if (!LIBRBD_USE_IOVEC) {
+        if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
+            acb->bounce = NULL;
+        } else {
+            acb->bounce = qemu_try_blockalign(bs, qiov->size);
+            if (acb->bounce == NULL) {
+                goto failed;
+            }
         }
+        if (cmd == RBD_AIO_WRITE) {
+            qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
+        }
+        rcb->buf = acb->bounce;
     }
+
     acb->ret = 0;
     acb->error = 0;
     acb->s = s;
 
-    if (cmd == RBD_AIO_WRITE) {
-        qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
-    }
-
-    buf = acb->bounce;
-
-    rcb = g_new(RADOSCB, 1);
     rcb->acb = acb;
-    rcb->buf = buf;
     rcb->s = acb->s;
     rcb->size = size;
     r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
@@ -694,10 +716,18 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 
     switch (cmd) {
     case RBD_AIO_WRITE:
-        r = rbd_aio_write(s->image, off, size, buf, c);
+#ifdef LIBRBD_SUPPORTS_IOVEC
+            r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
+#else
+            r = rbd_aio_write(s->image, off, size, rcb->buf, c);
+#endif
         break;
     case RBD_AIO_READ:
-        r = rbd_aio_read(s->image, off, size, buf, c);
+#ifdef LIBRBD_SUPPORTS_IOVEC
+            r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
+#else
+            r = rbd_aio_read(s->image, off, size, rcb->buf, c);
+#endif
         break;
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
@@ -712,14 +742,16 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     if (r < 0) {
         goto failed_completion;
     }
-
     return &acb->common;
 
 failed_completion:
     rbd_aio_release(c);
 failed:
     g_free(rcb);
-    qemu_vfree(acb->bounce);
+    if (!LIBRBD_USE_IOVEC) {
+        qemu_vfree(acb->bounce);
+    }
+
     qemu_aio_unref(acb);
     return NULL;
 }
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-21  6:50 ` jazeltq
  0 siblings, 0 replies; 12+ messages in thread
From: jazeltq @ 2017-02-21  6:50 UTC (permalink / raw)
  To: jdurgin, jcody, dillaman, kwolf, mreitz, qemu-block
  Cc: qemu-devel, ceph-devel, jazeltq, tianqing

From: tianqing <tianqing@unitedstack.com>

Rbd can do readv and writev directly, so wo do not need to transform
iov to buf or vice versa any more.

Signed-off-by: tianqing <tianqing@unitedstack.com>
---
 block/rbd.c | 80 ++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 56 insertions(+), 24 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index a57b3e3..22e8e69 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -62,6 +62,13 @@
 #define RBD_MAX_SNAP_NAME_SIZE 128
 #define RBD_MAX_SNAPS 100
 
+/* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
+#ifdef LIBRBD_SUPPORTS_IOVEC
+#define LIBRBD_USE_IOVEC 1
+#else
+#define LIBRBD_USE_IOVEC 0
+#endif
+
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
@@ -310,6 +317,17 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
     return ret;
 }
 
+static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
+{
+    if (LIBRBD_USE_IOVEC) {
+        RBDAIOCB *acb = rcb->acb;
+        iov_memset(acb->qiov->iov, acb->qiov->niov, offs, 0,
+                   acb->qiov->size - offs);
+    } else {
+        memset(rcb->buf + offs, 0, rcb->size - offs);
+    }
+}
+
 static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
 {
     Error *local_err = NULL;
@@ -426,11 +444,11 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
         }
     } else {
         if (r < 0) {
-            memset(rcb->buf, 0, rcb->size);
+            qemu_rbd_memset(rcb, 0);
             acb->ret = r;
             acb->error = 1;
         } else if (r < rcb->size) {
-            memset(rcb->buf + r, 0, rcb->size - r);
+            qemu_rbd_memset(rcb, r);
             if (!acb->error) {
                 acb->ret = rcb->size;
             }
@@ -441,10 +459,13 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
 
     g_free(rcb);
 
-    if (acb->cmd == RBD_AIO_READ) {
-        qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+    if (!LIBRBD_USE_IOVEC) {
+        if (acb->cmd == RBD_AIO_READ) {
+            qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+        }
+        qemu_vfree(acb->bounce);
     }
-    qemu_vfree(acb->bounce);
+
     acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
 
     qemu_aio_unref(acb);
@@ -655,7 +676,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     RBDAIOCB *acb;
     RADOSCB *rcb = NULL;
     rbd_completion_t c;
-    char *buf;
     int r;
 
     BDRVRBDState *s = bs->opaque;
@@ -664,27 +684,29 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb->cmd = cmd;
     acb->qiov = qiov;
     assert(!qiov || qiov->size == size);
-    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
-        acb->bounce = NULL;
-    } else {
-        acb->bounce = qemu_try_blockalign(bs, qiov->size);
-        if (acb->bounce == NULL) {
-            goto failed;
+
+    rcb = g_new(RADOSCB, 1);
+
+    if (!LIBRBD_USE_IOVEC) {
+        if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
+            acb->bounce = NULL;
+        } else {
+            acb->bounce = qemu_try_blockalign(bs, qiov->size);
+            if (acb->bounce == NULL) {
+                goto failed;
+            }
         }
+        if (cmd == RBD_AIO_WRITE) {
+            qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
+        }
+        rcb->buf = acb->bounce;
     }
+
     acb->ret = 0;
     acb->error = 0;
     acb->s = s;
 
-    if (cmd == RBD_AIO_WRITE) {
-        qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
-    }
-
-    buf = acb->bounce;
-
-    rcb = g_new(RADOSCB, 1);
     rcb->acb = acb;
-    rcb->buf = buf;
     rcb->s = acb->s;
     rcb->size = size;
     r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
@@ -694,10 +716,18 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 
     switch (cmd) {
     case RBD_AIO_WRITE:
-        r = rbd_aio_write(s->image, off, size, buf, c);
+#ifdef LIBRBD_SUPPORTS_IOVEC
+            r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
+#else
+            r = rbd_aio_write(s->image, off, size, rcb->buf, c);
+#endif
         break;
     case RBD_AIO_READ:
-        r = rbd_aio_read(s->image, off, size, buf, c);
+#ifdef LIBRBD_SUPPORTS_IOVEC
+            r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
+#else
+            r = rbd_aio_read(s->image, off, size, rcb->buf, c);
+#endif
         break;
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
@@ -712,14 +742,16 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     if (r < 0) {
         goto failed_completion;
     }
-
     return &acb->common;
 
 failed_completion:
     rbd_aio_release(c);
 failed:
     g_free(rcb);
-    qemu_vfree(acb->bounce);
+    if (!LIBRBD_USE_IOVEC) {
+        qemu_vfree(acb->bounce);
+    }
+
     qemu_aio_unref(acb);
     return NULL;
 }
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [RFC v6] RBD: Add support readv,writev for rbd
  2017-02-21  6:50 ` [Qemu-devel] " jazeltq
@ 2017-02-24  3:52   ` Jeff Cody
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeff Cody @ 2017-02-24  3:52 UTC (permalink / raw)
  To: jazeltq
  Cc: jdurgin, dillaman, kwolf, mreitz, qemu-block, qemu-devel,
	ceph-devel, tianqing

On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
> From: tianqing <tianqing@unitedstack.com>
> 
> Rbd can do readv and writev directly, so wo do not need to transform
> iov to buf or vice versa any more.
> 
> Signed-off-by: tianqing <tianqing@unitedstack.com>
> ---


This is marked as an RFC still - is this a series you would like to see in
2.9?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-24  3:52   ` Jeff Cody
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff Cody @ 2017-02-24  3:52 UTC (permalink / raw)
  To: jazeltq
  Cc: jdurgin, dillaman, kwolf, mreitz, qemu-block, qemu-devel,
	ceph-devel, tianqing

On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
> From: tianqing <tianqing@unitedstack.com>
> 
> Rbd can do readv and writev directly, so wo do not need to transform
> iov to buf or vice versa any more.
> 
> Signed-off-by: tianqing <tianqing@unitedstack.com>
> ---


This is marked as an RFC still - is this a series you would like to see in
2.9?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC v6] RBD: Add support readv,writev for rbd
  2017-02-24  3:52   ` [Qemu-devel] " Jeff Cody
@ 2017-02-24  6:09     ` Jaze Lee
  -1 siblings, 0 replies; 12+ messages in thread
From: Jaze Lee @ 2017-02-24  6:09 UTC (permalink / raw)
  To: Jeff Cody
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
>> From: tianqing <tianqing@unitedstack.com>
>>
>> Rbd can do readv and writev directly, so wo do not need to transform
>> iov to buf or vice versa any more.
>>
>> Signed-off-by: tianqing <tianqing@unitedstack.com>
>> ---
>
>
> This is marked as an RFC still - is this a series you would like to see in
> 2.9?

Yes.   What should i do if i like it in 2.9

-- 
谦谦君子

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-24  6:09     ` Jaze Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Jaze Lee @ 2017-02-24  6:09 UTC (permalink / raw)
  To: Jeff Cody
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
>> From: tianqing <tianqing@unitedstack.com>
>>
>> Rbd can do readv and writev directly, so wo do not need to transform
>> iov to buf or vice versa any more.
>>
>> Signed-off-by: tianqing <tianqing@unitedstack.com>
>> ---
>
>
> This is marked as an RFC still - is this a series you would like to see in
> 2.9?

Yes.   What should i do if i like it in 2.9

-- 
谦谦君子

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC v6] RBD: Add support readv,writev for rbd
  2017-02-24  6:09     ` [Qemu-devel] " Jaze Lee
@ 2017-02-24 11:42       ` Jeff Cody
  -1 siblings, 0 replies; 12+ messages in thread
From: Jeff Cody @ 2017-02-24 11:42 UTC (permalink / raw)
  To: Jaze Lee
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

On Fri, Feb 24, 2017 at 02:09:31PM +0800, Jaze Lee wrote:
> 2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> > On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
> >> From: tianqing <tianqing@unitedstack.com>
> >>
> >> Rbd can do readv and writev directly, so wo do not need to transform
> >> iov to buf or vice versa any more.
> >>
> >> Signed-off-by: tianqing <tianqing@unitedstack.com>
> >> ---
> >
> >
> > This is marked as an RFC still - is this a series you would like to see in
> > 2.9?
> 
> Yes.   What should i do if i like it in 2.9
>

Ideally you would submit the series as a non-RFC patch (that is, it would
have progressed to a normal patch away from RFC).

But in this case, it seems to me that this patch has progressed beyond RFC;
is there any reason it is still marked as RFC instead of just a patch?  It
looks OK to me.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-24 11:42       ` Jeff Cody
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff Cody @ 2017-02-24 11:42 UTC (permalink / raw)
  To: Jaze Lee
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

On Fri, Feb 24, 2017 at 02:09:31PM +0800, Jaze Lee wrote:
> 2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> > On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
> >> From: tianqing <tianqing@unitedstack.com>
> >>
> >> Rbd can do readv and writev directly, so wo do not need to transform
> >> iov to buf or vice versa any more.
> >>
> >> Signed-off-by: tianqing <tianqing@unitedstack.com>
> >> ---
> >
> >
> > This is marked as an RFC still - is this a series you would like to see in
> > 2.9?
> 
> Yes.   What should i do if i like it in 2.9
>

Ideally you would submit the series as a non-RFC patch (that is, it would
have progressed to a normal patch away from RFC).

But in this case, it seems to me that this patch has progressed beyond RFC;
is there any reason it is still marked as RFC instead of just a patch?  It
looks OK to me.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC v6] RBD: Add support readv,writev for rbd
  2017-02-24 11:42       ` [Qemu-devel] " Jeff Cody
@ 2017-02-24 12:51         ` Jaze Lee
  -1 siblings, 0 replies; 12+ messages in thread
From: Jaze Lee @ 2017-02-24 12:51 UTC (permalink / raw)
  To: Jeff Cody
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

Sorry, I do not know. I thought we should always add RFC all though
the patch's life...
What is the prefix i should add? PATH 0 ?

2017-02-24 19:42 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> On Fri, Feb 24, 2017 at 02:09:31PM +0800, Jaze Lee wrote:
>> 2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
>> > On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
>> >> From: tianqing <tianqing@unitedstack.com>
>> >>
>> >> Rbd can do readv and writev directly, so wo do not need to transform
>> >> iov to buf or vice versa any more.
>> >>
>> >> Signed-off-by: tianqing <tianqing@unitedstack.com>
>> >> ---
>> >
>> >
>> > This is marked as an RFC still - is this a series you would like to see in
>> > 2.9?
>>
>> Yes.   What should i do if i like it in 2.9
>>
>
> Ideally you would submit the series as a non-RFC patch (that is, it would
> have progressed to a normal patch away from RFC).
>
> But in this case, it seems to me that this patch has progressed beyond RFC;
> is there any reason it is still marked as RFC instead of just a patch?  It
> looks OK to me.
>



-- 
谦谦君子

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-24 12:51         ` Jaze Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Jaze Lee @ 2017-02-24 12:51 UTC (permalink / raw)
  To: Jeff Cody
  Cc: Josh Durgin, Jason Dillaman, Kevin Wolf, Max Reitz, qemu-block,
	qemu-devel, ceph-devel, tianqing

Sorry, I do not know. I thought we should always add RFC all though
the patch's life...
What is the prefix i should add? PATH 0 ?

2017-02-24 19:42 GMT+08:00 Jeff Cody <jcody@redhat.com>:
> On Fri, Feb 24, 2017 at 02:09:31PM +0800, Jaze Lee wrote:
>> 2017-02-24 11:52 GMT+08:00 Jeff Cody <jcody@redhat.com>:
>> > On Tue, Feb 21, 2017 at 02:50:03PM +0800, jazeltq@gmail.com wrote:
>> >> From: tianqing <tianqing@unitedstack.com>
>> >>
>> >> Rbd can do readv and writev directly, so wo do not need to transform
>> >> iov to buf or vice versa any more.
>> >>
>> >> Signed-off-by: tianqing <tianqing@unitedstack.com>
>> >> ---
>> >
>> >
>> > This is marked as an RFC still - is this a series you would like to see in
>> > 2.9?
>>
>> Yes.   What should i do if i like it in 2.9
>>
>
> Ideally you would submit the series as a non-RFC patch (that is, it would
> have progressed to a normal patch away from RFC).
>
> But in this case, it seems to me that this patch has progressed beyond RFC;
> is there any reason it is still marked as RFC instead of just a patch?  It
> looks OK to me.
>



-- 
谦谦君子

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC v6] RBD: Add support readv,writev for rbd
  2017-02-21  3:43 jazeltq
@ 2017-02-21  4:50 ` Jeff Cody
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff Cody @ 2017-02-21  4:50 UTC (permalink / raw)
  To: jazeltq
  Cc: kwolf, qemu-block, qemu-devel, mreitz, tianqing, ceph-devel, dillaman

On Tue, Feb 21, 2017 at 11:43:36AM +0800, jazeltq@gmail.com wrote:
> From: tianqing <tianqing@unitedstack.com>
> 
> Rbd can do readv and writev directly, so wo do not need to transform
> iov to buf or vice versa any more.
> 
> Signed-off-by: tianqing <tianqing@unitedstack.com>
> ---
>  block/rbd.c | 79 ++++++++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 54 insertions(+), 25 deletions(-)
> 


[...]

>      case RBD_AIO_WRITE:
> -        r = rbd_aio_write(s->image, off, size, buf, c);
> +        if(!LIBRBD_USE_IOVEC)
> +            r = rbd_aio_write(s->image, off, size, rcb->buf, c);
> +        else
> +            r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
>          break;
>      case RBD_AIO_READ:
> -        r = rbd_aio_read(s->image, off, size, buf, c);
> +        if(!LIBRBD_USE_IOVEC)
> +            r = rbd_aio_read(s->image, off, size, rcb->buf, c);
> +        else
> +            r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);

These will need to stay #ifdef's since they are new symbols.

>          break;
>      case RBD_AIO_DISCARD:
>          r = rbd_aio_discard_wrapper(s->image, off, size, c);
> @@ -712,14 +740,15 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
>      if (r < 0) {
>          goto failed_completion;
>      }
> -
>      return &acb->common;
>  
>  failed_completion:
>      rbd_aio_release(c);
>  failed:
>      g_free(rcb);
> -    qemu_vfree(acb->bounce);
> +    if(!LIBRBD_USE_IOVEC)
> +        qemu_vfree(acb->bounce);
> +
>      qemu_aio_unref(acb);
>      return NULL;
>  }
> -- 
> 2.10.2
>

(Also code formatting as pointed out by patchew)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [RFC v6] RBD: Add support readv,writev for rbd
@ 2017-02-21  3:43 jazeltq
  2017-02-21  4:50 ` Jeff Cody
  0 siblings, 1 reply; 12+ messages in thread
From: jazeltq @ 2017-02-21  3:43 UTC (permalink / raw)
  To: jdurgin, jcody, dillaman, kwolf, mreitz, qemu-block
  Cc: qemu-devel, ceph-devel, jazeltq, tianqing

From: tianqing <tianqing@unitedstack.com>

Rbd can do readv and writev directly, so wo do not need to transform
iov to buf or vice versa any more.

Signed-off-by: tianqing <tianqing@unitedstack.com>
---
 block/rbd.c | 79 ++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 54 insertions(+), 25 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index a57b3e3..5373680 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -62,6 +62,13 @@
 #define RBD_MAX_SNAP_NAME_SIZE 128
 #define RBD_MAX_SNAPS 100
 
+/* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
+#ifdef LIBRBD_SUPPORTS_IOVEC
+#define LIBRBD_USE_IOVEC 1
+#else
+#define LIBRBD_USE_IOVEC 0
+#endif
+
 typedef enum {
     RBD_AIO_READ,
     RBD_AIO_WRITE,
@@ -310,6 +317,17 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
     return ret;
 }
 
+static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
+{
+    if(LIBRBD_USE_IOVEC){
+        RBDAIOCB *acb = rcb->acb;
+        iov_memset(acb->qiov->iov, acb->qiov->niov, offs, 0,
+                   acb->qiov->size - offs);
+    } else {
+        memset(rcb->buf + offs, 0, rcb->size - offs);
+    }
+}
+
 static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
 {
     Error *local_err = NULL;
@@ -426,11 +444,11 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
         }
     } else {
         if (r < 0) {
-            memset(rcb->buf, 0, rcb->size);
+            qemu_rbd_memset(rcb, 0);
             acb->ret = r;
             acb->error = 1;
         } else if (r < rcb->size) {
-            memset(rcb->buf + r, 0, rcb->size - r);
+            qemu_rbd_memset(rcb, r);
             if (!acb->error) {
                 acb->ret = rcb->size;
             }
@@ -440,11 +458,14 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
     }
 
     g_free(rcb);
-
-    if (acb->cmd == RBD_AIO_READ) {
-        qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+ 
+    if(!LIBRBD_USE_IOVEC){
+         if (acb->cmd == RBD_AIO_READ) {
+             qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
+         }
+         qemu_vfree(acb->bounce);
     }
-    qemu_vfree(acb->bounce);
+
     acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
 
     qemu_aio_unref(acb);
@@ -655,7 +676,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     RBDAIOCB *acb;
     RADOSCB *rcb = NULL;
     rbd_completion_t c;
-    char *buf;
     int r;
 
     BDRVRBDState *s = bs->opaque;
@@ -664,27 +684,29 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb->cmd = cmd;
     acb->qiov = qiov;
     assert(!qiov || qiov->size == size);
-    if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
-        acb->bounce = NULL;
-    } else {
-        acb->bounce = qemu_try_blockalign(bs, qiov->size);
-        if (acb->bounce == NULL) {
-            goto failed;
+
+    rcb = g_new(RADOSCB, 1);
+
+    if(!LIBRBD_USE_IOVEC){
+        if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
+            acb->bounce = NULL;
+        } else {
+            acb->bounce = qemu_try_blockalign(bs, qiov->size);
+            if (acb->bounce == NULL) {
+                goto failed;
+            }
         }
+        if (cmd == RBD_AIO_WRITE) {
+            qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
+        }
+        rcb->buf = acb->bounce;
     }
+
     acb->ret = 0;
     acb->error = 0;
     acb->s = s;
 
-    if (cmd == RBD_AIO_WRITE) {
-        qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
-    }
-
-    buf = acb->bounce;
-
-    rcb = g_new(RADOSCB, 1);
     rcb->acb = acb;
-    rcb->buf = buf;
     rcb->s = acb->s;
     rcb->size = size;
     r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
@@ -694,10 +716,16 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 
     switch (cmd) {
     case RBD_AIO_WRITE:
-        r = rbd_aio_write(s->image, off, size, buf, c);
+        if(!LIBRBD_USE_IOVEC)
+            r = rbd_aio_write(s->image, off, size, rcb->buf, c);
+        else
+            r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
         break;
     case RBD_AIO_READ:
-        r = rbd_aio_read(s->image, off, size, buf, c);
+        if(!LIBRBD_USE_IOVEC)
+            r = rbd_aio_read(s->image, off, size, rcb->buf, c);
+        else
+            r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
         break;
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
@@ -712,14 +740,15 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     if (r < 0) {
         goto failed_completion;
     }
-
     return &acb->common;
 
 failed_completion:
     rbd_aio_release(c);
 failed:
     g_free(rcb);
-    qemu_vfree(acb->bounce);
+    if(!LIBRBD_USE_IOVEC)
+        qemu_vfree(acb->bounce);
+
     qemu_aio_unref(acb);
     return NULL;
 }
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-02-24 12:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21  6:50 [RFC v6] RBD: Add support readv,writev for rbd jazeltq
2017-02-21  6:50 ` [Qemu-devel] " jazeltq
2017-02-24  3:52 ` Jeff Cody
2017-02-24  3:52   ` [Qemu-devel] " Jeff Cody
2017-02-24  6:09   ` Jaze Lee
2017-02-24  6:09     ` [Qemu-devel] " Jaze Lee
2017-02-24 11:42     ` Jeff Cody
2017-02-24 11:42       ` [Qemu-devel] " Jeff Cody
2017-02-24 12:51       ` Jaze Lee
2017-02-24 12:51         ` [Qemu-devel] " Jaze Lee
  -- strict thread matches above, loose matches on Subject: below --
2017-02-21  3:43 jazeltq
2017-02-21  4:50 ` Jeff Cody

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.