diff mbox

[RFC,v3] RBD: Add support readv,writev for rbd

Message ID 20170121105949.15466-1-jazeltq@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

jazeltq@gmail.com Jan. 21, 2017, 10:59 a.m. UTC
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 | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)

Comments

no-reply@patchew.org Jan. 21, 2017, 11:13 a.m. UTC | #1
Hi,

Your series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [RFC v3] RBD: Add support readv,writev for rbd
Message-id: 20170121105949.15466-1-jazeltq@gmail.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
f826583 RBD: Add support readv,writev for rbd

=== OUTPUT BEGIN ===
Checking PATCH 1/1: RBD: Add support readv,writev for rbd...
ERROR: trailing whitespace
#81: FILE: block/rbd.c:679:
+    char * buf = NULL; $

ERROR: "foo * bar" should be "foo *bar"
#81: FILE: block/rbd.c:679:
+    char * buf = NULL; 

ERROR: trailing whitespace
#91: FILE: block/rbd.c:689:
+    $

total: 3 errors, 0 warnings, 126 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
diff mbox

Patch

diff --git a/block/rbd.c b/block/rbd.c
index a57b3e3..4add4dd 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -73,7 +73,12 @@  typedef struct RBDAIOCB {
     BlockAIOCB common;
     int64_t ret;
     QEMUIOVector *qiov;
+/* Note:
+ * The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h.
+ */
+#ifndef LIBRBD_SUPPORTS_IOVEC
     char *bounce;
+#endif
     RBDAIOCmd cmd;
     int error;
     struct BDRVRBDState *s;
@@ -83,7 +88,9 @@  typedef struct RADOSCB {
     RBDAIOCB *acb;
     struct BDRVRBDState *s;
     int64_t size;
+#ifndef LIBRBD_SUPPORTS_IOVEC
     char *buf;
+#endif
     int64_t ret;
 } RADOSCB;
 
@@ -426,11 +433,21 @@  static void qemu_rbd_complete_aio(RADOSCB *rcb)
         }
     } else {
         if (r < 0) {
+#ifndef LIBRBD_SUPPORTS_IOVEC
             memset(rcb->buf, 0, rcb->size);
+#else
+            iov_memset(acb->qiov->iov, acb->qiov->niov, 0, 0, acb->qiov->size);
+#endif
             acb->ret = r;
             acb->error = 1;
         } else if (r < rcb->size) {
+#ifndef LIBRBD_SUPPORTS_IOVEC
             memset(rcb->buf + r, 0, rcb->size - r);
+#else
+            iov_memset(acb->qiov->iov, acb->qiov->niov,
+                       r, 0, acb->qiov->size - r);
+#endif
+
             if (!acb->error) {
                 acb->ret = rcb->size;
             }
@@ -441,10 +458,12 @@  static void qemu_rbd_complete_aio(RADOSCB *rcb)
 
     g_free(rcb);
 
+#ifndef LIBRBD_SUPPORTS_IOVEC
     if (acb->cmd == RBD_AIO_READ) {
         qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
     }
     qemu_vfree(acb->bounce);
+#endif
     acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
 
     qemu_aio_unref(acb);
@@ -655,8 +674,10 @@  static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     RBDAIOCB *acb;
     RADOSCB *rcb = NULL;
     rbd_completion_t c;
-    char *buf;
     int r;
+#ifndef LIBRBD_SUPPORTS_IOVEC
+    char * buf = NULL; 
+#endif
 
     BDRVRBDState *s = bs->opaque;
 
@@ -664,6 +685,8 @@  static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     acb->cmd = cmd;
     acb->qiov = qiov;
     assert(!qiov || qiov->size == size);
+#ifndef LIBRBD_SUPPORTS_IOVEC
+    
     if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
         acb->bounce = NULL;
     } else {
@@ -672,19 +695,21 @@  static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
             goto failed;
         }
     }
-    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;
+#endif
+    acb->ret = 0;
+    acb->error = 0;
+    acb->s = s;
 
     rcb = g_new(RADOSCB, 1);
+
     rcb->acb = acb;
+#ifndef LIBRBD_SUPPORTS_IOVEC
     rcb->buf = buf;
+#endif
     rcb->s = acb->s;
     rcb->size = size;
     r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
@@ -694,10 +719,18 @@  static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 
     switch (cmd) {
     case RBD_AIO_WRITE:
+#ifndef LIBRBD_SUPPORTS_IOVEC
         r = rbd_aio_write(s->image, off, size, buf, c);
+#else
+        r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
+#endif
         break;
     case RBD_AIO_READ:
+#ifndef LIBRBD_SUPPORTS_IOVEC
         r = rbd_aio_read(s->image, off, size, buf, c);
+#else
+        r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
+#endif
         break;
     case RBD_AIO_DISCARD:
         r = rbd_aio_discard_wrapper(s->image, off, size, c);
@@ -719,7 +752,9 @@  failed_completion:
     rbd_aio_release(c);
 failed:
     g_free(rcb);
+#ifndef LIBRBD_SUPPORTS_IOVEC
     qemu_vfree(acb->bounce);
+#endif
     qemu_aio_unref(acb);
     return NULL;
 }