All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: dgilbert@redhat.com, quintela@redhat.com, jsnow@redhat.com,
	den@openvz.org, fam@euphon.net, stefanha@redhat.com,
	mreitz@redhat.com, kwolf@redhat.com, jcody@redhat.com,
	vsementsov@virtuozzo.com
Subject: [Qemu-devel] [PATCH v3 10/17] block/qed: use qemu_iovec_init_buf
Date: Thu,  7 Feb 2019 13:24:38 +0300	[thread overview]
Message-ID: <20190207102445.71998-11-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20190207102445.71998-1-vsementsov@virtuozzo.com>

Use new qemu_iovec_init_buf() instead of
qemu_iovec_init_external( ... , 1), which simplifies the code.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qed-table.c | 16 +++-------------
 block/qed.c       | 31 +++++++++----------------------
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/block/qed-table.c b/block/qed-table.c
index 7df5680adb..c497bd4aec 100644
--- a/block/qed-table.c
+++ b/block/qed-table.c
@@ -21,16 +21,11 @@
 /* Called with table_lock held.  */
 static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)
 {
-    QEMUIOVector qiov;
+    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(
+        qiov, table->offsets, s->header.cluster_size * s->header.table_size);
     int noffsets;
     int i, ret;
 
-    struct iovec iov = {
-        .iov_base = table->offsets,
-        .iov_len = s->header.cluster_size * s->header.table_size,
-    };
-    qemu_iovec_init_external(&qiov, &iov, 1);
-
     trace_qed_read_table(s, offset, table);
 
     qemu_co_mutex_unlock(&s->table_lock);
@@ -71,7 +66,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
     unsigned int sector_mask = BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1;
     unsigned int start, end, i;
     QEDTable *new_table;
-    struct iovec iov;
     QEMUIOVector qiov;
     size_t len_bytes;
     int ret;
@@ -85,11 +79,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
     len_bytes = (end - start) * sizeof(uint64_t);
 
     new_table = qemu_blockalign(s->bs, len_bytes);
-    iov = (struct iovec) {
-        .iov_base = new_table->offsets,
-        .iov_len = len_bytes,
-    };
-    qemu_iovec_init_external(&qiov, &iov, 1);
+    qemu_iovec_init_buf(&qiov, new_table->offsets, len_bytes);
 
     /* Byteswap table */
     for (i = start; i < end; i++) {
diff --git a/block/qed.c b/block/qed.c
index 1280870024..a010e5b349 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -113,18 +113,13 @@ static int coroutine_fn qed_write_header(BDRVQEDState *s)
     int nsectors = DIV_ROUND_UP(sizeof(QEDHeader), BDRV_SECTOR_SIZE);
     size_t len = nsectors * BDRV_SECTOR_SIZE;
     uint8_t *buf;
-    struct iovec iov;
     QEMUIOVector qiov;
     int ret;
 
     assert(s->allocating_acb || s->allocating_write_reqs_plugged);
 
     buf = qemu_blockalign(s->bs, len);
-    iov = (struct iovec) {
-        .iov_base = buf,
-        .iov_len = len,
-    };
-    qemu_iovec_init_external(&qiov, &iov, 1);
+    qemu_iovec_init_buf(&qiov, buf, len);
 
     ret = bdrv_co_preadv(s->bs->file, 0, qiov.size, &qiov, 0);
     if (ret < 0) {
@@ -913,7 +908,6 @@ static int coroutine_fn qed_copy_from_backing_file(BDRVQEDState *s,
 {
     QEMUIOVector qiov;
     QEMUIOVector *backing_qiov = NULL;
-    struct iovec iov;
     int ret;
 
     /* Skip copy entirely if there is no work to do */
@@ -921,11 +915,7 @@ static int coroutine_fn qed_copy_from_backing_file(BDRVQEDState *s,
         return 0;
     }
 
-    iov = (struct iovec) {
-        .iov_base = qemu_blockalign(s->bs, len),
-        .iov_len = len,
-    };
-    qemu_iovec_init_external(&qiov, &iov, 1);
+    qemu_iovec_init_buf(&qiov, qemu_blockalign(s->bs, len), len);
 
     ret = qed_read_backing_file(s, pos, &qiov, &backing_qiov);
 
@@ -946,7 +936,7 @@ static int coroutine_fn qed_copy_from_backing_file(BDRVQEDState *s,
     }
     ret = 0;
 out:
-    qemu_vfree(iov.iov_base);
+    qemu_vfree(qemu_iovec_get_buf(&qiov));
     return ret;
 }
 
@@ -1447,8 +1437,12 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs,
                                                   BdrvRequestFlags flags)
 {
     BDRVQEDState *s = bs->opaque;
-    QEMUIOVector qiov;
-    struct iovec iov;
+
+    /*
+     * Zero writes start without an I/O buffer.  If a buffer becomes necessary
+     * then it will be allocated during request processing.
+     */
+    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes);
 
     /* Fall back if the request is not aligned */
     if (qed_offset_into_cluster(s, offset) ||
@@ -1456,13 +1450,6 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs,
         return -ENOTSUP;
     }
 
-    /* Zero writes start without an I/O buffer.  If a buffer becomes necessary
-     * then it will be allocated during request processing.
-     */
-    iov.iov_base = NULL;
-    iov.iov_len = bytes;
-
-    qemu_iovec_init_external(&qiov, &iov, 1);
     return qed_co_request(bs, offset >> BDRV_SECTOR_BITS, &qiov,
                           bytes >> BDRV_SECTOR_BITS,
                           QED_AIOCB_WRITE | QED_AIOCB_ZERO);
-- 
2.18.0

  parent reply	other threads:[~2019-02-07 10:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 10:24 [Qemu-devel] [PATCH v3 00/17] block: local qiov helper Vladimir Sementsov-Ogievskiy
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 01/17] block: enhance QEMUIOVector structure Vladimir Sementsov-Ogievskiy
2019-02-07 14:50   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 02/17] block/io: use qemu_iovec_init_buf Vladimir Sementsov-Ogievskiy
2019-02-07 14:53   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 03/17] block/block-backend: use QEMU_IOVEC_INIT_BUF Vladimir Sementsov-Ogievskiy
2019-02-07 14:54   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 04/17] block/backup: use qemu_iovec_init_buf Vladimir Sementsov-Ogievskiy
2019-02-07 15:06   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 05/17] block/commit: use QEMU_IOVEC_INIT_BUF Vladimir Sementsov-Ogievskiy
2019-02-07 15:07   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 06/17] block/stream: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:08   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 07/17] block/parallels: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:11   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 08/17] block/qcow: use qemu_iovec_init_buf Vladimir Sementsov-Ogievskiy
2019-02-07 15:13   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 09/17] block/qcow2: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:15   ` Eric Blake
2019-02-07 10:24 ` Vladimir Sementsov-Ogievskiy [this message]
2019-02-07 15:18   ` [Qemu-devel] [PATCH v3 10/17] block/qed: " Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 11/17] block/vmdk: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:19   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 12/17] qemu-img: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:20   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 13/17] migration/block: " Vladimir Sementsov-Ogievskiy
2019-02-07 15:20   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 14/17] tests/test-bdrv-drain: use QEMU_IOVEC_INIT_BUF Vladimir Sementsov-Ogievskiy
2019-02-07 15:21   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 15/17] hw/ide: drop iov field from IDEState Vladimir Sementsov-Ogievskiy
2019-02-07 15:23   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 16/17] hw/ide: drop iov field from IDEBufferedRequest Vladimir Sementsov-Ogievskiy
2019-02-07 15:38   ` Eric Blake
2019-02-07 10:24 ` [Qemu-devel] [PATCH v3 17/17] hw/ide: drop iov field from IDEDMA Vladimir Sementsov-Ogievskiy
2019-02-07 15:39   ` Eric Blake
2019-02-11  6:03 ` [Qemu-devel] [PATCH v3 00/17] block: local qiov helper Stefan Hajnoczi
2019-02-11  6:04 ` Stefan Hajnoczi
2019-02-12 17:41   ` Vladimir Sementsov-Ogievskiy
2019-02-13  7:52 ` Stefan Hajnoczi
2019-02-13  8:19 ` Stefan Hajnoczi
2019-02-18 10:24   ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190207102445.71998-11-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=dgilbert@redhat.com \
    --cc=fam@euphon.net \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.