All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, jsnow@redhat.com,
	mreitz@redhat.com, stefanha@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH 4/9] block/qed: use buffer-based io
Date: Tue, 30 Apr 2019 12:46:53 +0200	[thread overview]
Message-ID: <20190430104653.GD5607@linux.fritz.box> (raw)
In-Reply-To: <20190422145838.70903-5-vsementsov@virtuozzo.com>

Am 22.04.2019 um 16:58 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Move to _co_ versions of io functions qed_read_table() and
> qed_write_table(), as we use qemu_co_mutex_unlock()
> anyway.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/qed-table.c | 12 +++++-------
>  block/qed.c       |  6 ++----
>  2 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/block/qed-table.c b/block/qed-table.c
> index c497bd4aec..cf30edd977 100644
> --- a/block/qed-table.c
> +++ b/block/qed-table.c
> @@ -21,22 +21,22 @@
>  /* Called with table_lock held.  */
>  static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)
>  {
> -    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(
> -        qiov, table->offsets, s->header.cluster_size * s->header.table_size);
> +    unsigned int bytes = s->header.cluster_size * s->header.table_size;
> +
>      int noffsets;
>      int i, ret;
>  
>      trace_qed_read_table(s, offset, table);
>  
>      qemu_co_mutex_unlock(&s->table_lock);
> -    ret = bdrv_preadv(s->bs->file, offset, &qiov);
> +    ret = bdrv_co_pread(s->bs->file, offset, bytes, table->offsets, 0);

Careful! This function is not marked as coroutine_fn, and I remember
that there were some non-coroutine callers when I converted qed to
coroutines.

It looks like we're lucky and all callers have been converted to
coroutines meanwhile, but I would prefer if we added the coroutine_fn
marker everywhere where we rely on it now to document this fact.

>      qemu_co_mutex_lock(&s->table_lock);
>      if (ret < 0) {
>          goto out;
>      }
>  
>      /* Byteswap offsets */
> -    noffsets = qiov.size / sizeof(uint64_t);
> +    noffsets = bytes / sizeof(uint64_t);
>      for (i = 0; i < noffsets; i++) {
>          table->offsets[i] = le64_to_cpu(table->offsets[i]);
>      }
> @@ -66,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;
> -    QEMUIOVector qiov;
>      size_t len_bytes;
>      int ret;
>  
> @@ -79,7 +78,6 @@ 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);
> -    qemu_iovec_init_buf(&qiov, new_table->offsets, len_bytes);
>  
>      /* Byteswap table */
>      for (i = start; i < end; i++) {
> @@ -91,7 +89,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
>      offset += start * sizeof(uint64_t);
>  
>      qemu_co_mutex_unlock(&s->table_lock);
> -    ret = bdrv_pwritev(s->bs->file, offset, &qiov);
> +    ret = bdrv_co_pwrite(s->bs->file, offset, len_bytes, new_table->offsets, 0);
>      qemu_co_mutex_lock(&s->table_lock);
>      trace_qed_write_table_cb(s, table, flush, ret);
>      if (ret < 0) {

Same for the callers of this function.

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com,
	stefanha@redhat.com, den@openvz.org, jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/9] block/qed: use buffer-based io
Date: Tue, 30 Apr 2019 12:46:53 +0200	[thread overview]
Message-ID: <20190430104653.GD5607@linux.fritz.box> (raw)
Message-ID: <20190430104653.YU6TcjK0p3pt6bmoTCAmu435mH8VaQuIMwHqWsbhFpI@z> (raw)
In-Reply-To: <20190422145838.70903-5-vsementsov@virtuozzo.com>

Am 22.04.2019 um 16:58 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Move to _co_ versions of io functions qed_read_table() and
> qed_write_table(), as we use qemu_co_mutex_unlock()
> anyway.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/qed-table.c | 12 +++++-------
>  block/qed.c       |  6 ++----
>  2 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/block/qed-table.c b/block/qed-table.c
> index c497bd4aec..cf30edd977 100644
> --- a/block/qed-table.c
> +++ b/block/qed-table.c
> @@ -21,22 +21,22 @@
>  /* Called with table_lock held.  */
>  static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)
>  {
> -    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(
> -        qiov, table->offsets, s->header.cluster_size * s->header.table_size);
> +    unsigned int bytes = s->header.cluster_size * s->header.table_size;
> +
>      int noffsets;
>      int i, ret;
>  
>      trace_qed_read_table(s, offset, table);
>  
>      qemu_co_mutex_unlock(&s->table_lock);
> -    ret = bdrv_preadv(s->bs->file, offset, &qiov);
> +    ret = bdrv_co_pread(s->bs->file, offset, bytes, table->offsets, 0);

Careful! This function is not marked as coroutine_fn, and I remember
that there were some non-coroutine callers when I converted qed to
coroutines.

It looks like we're lucky and all callers have been converted to
coroutines meanwhile, but I would prefer if we added the coroutine_fn
marker everywhere where we rely on it now to document this fact.

>      qemu_co_mutex_lock(&s->table_lock);
>      if (ret < 0) {
>          goto out;
>      }
>  
>      /* Byteswap offsets */
> -    noffsets = qiov.size / sizeof(uint64_t);
> +    noffsets = bytes / sizeof(uint64_t);
>      for (i = 0; i < noffsets; i++) {
>          table->offsets[i] = le64_to_cpu(table->offsets[i]);
>      }
> @@ -66,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;
> -    QEMUIOVector qiov;
>      size_t len_bytes;
>      int ret;
>  
> @@ -79,7 +78,6 @@ 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);
> -    qemu_iovec_init_buf(&qiov, new_table->offsets, len_bytes);
>  
>      /* Byteswap table */
>      for (i = start; i < end; i++) {
> @@ -91,7 +89,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
>      offset += start * sizeof(uint64_t);
>  
>      qemu_co_mutex_unlock(&s->table_lock);
> -    ret = bdrv_pwritev(s->bs->file, offset, &qiov);
> +    ret = bdrv_co_pwrite(s->bs->file, offset, len_bytes, new_table->offsets, 0);
>      qemu_co_mutex_lock(&s->table_lock);
>      trace_qed_write_table_cb(s, table, flush, ret);
>      if (ret < 0) {

Same for the callers of this function.

Kevin


  reply	other threads:[~2019-04-30 10:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 14:58 [Qemu-devel] [PATCH 0/9] block: buffer-based io Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 1/9] block: introduce byte-based io helpers Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 2/9] block/qcow2: use buffer-based io Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 3/9] block/qcow: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 4/9] block/qed: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-30 10:46   ` Kevin Wolf [this message]
2019-04-30 10:46     ` Kevin Wolf
2019-04-22 14:58 ` [Qemu-devel] [PATCH 5/9] block/parallels: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 6/9] block/backup: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 7/9] block/commit: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 8/9] block/stream: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-22 14:58 ` [Qemu-devel] [PATCH 9/9] qemu-img: " Vladimir Sementsov-Ogievskiy
2019-04-22 14:58   ` Vladimir Sementsov-Ogievskiy
2019-04-23 13:06 ` [Qemu-devel] [PATCH 0/9] block: " Stefan Hajnoczi
2019-04-23 13:06   ` Stefan Hajnoczi
2019-04-23 16:20   ` Vladimir Sementsov-Ogievskiy
2019-04-23 16:20     ` Vladimir Sementsov-Ogievskiy
2019-04-30  9:38 ` Stefano Garzarella
2019-04-30  9:38   ` Stefano Garzarella
2019-04-30  9:46   ` Vladimir Sementsov-Ogievskiy
2019-04-30  9:46     ` Vladimir Sementsov-Ogievskiy
2019-04-30 10:52 ` Kevin Wolf
2019-04-30 10:52   ` Kevin Wolf

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=20190430104653.GD5607@linux.fritz.box \
    --to=kwolf@redhat.com \
    --cc=den@openvz.org \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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.