All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: berto@igalia.com, qemu-block@nongnu.org, qemu-devel@nongnu.org,
	armbru@redhat.com, stefanha@redhat.com, famz@redhat.com,
	mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 04/16] quorum: Convert to BdrvChild
Date: Mon, 12 Oct 2015 20:58:51 -0400	[thread overview]
Message-ID: <20151013005851.GK11943@localhost.localdomain> (raw)
In-Reply-To: <1444392941-28704-5-git-send-email-kwolf@redhat.com>

On Fri, Oct 09, 2015 at 02:15:29PM +0200, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Alberto Garcia <berto@igalia.com>
> Reviewed-by: Fam Zheng <famz@redhat.com>
> ---
>  block/quorum.c | 65 ++++++++++++++++++++++++++++++----------------------------
>  1 file changed, 34 insertions(+), 31 deletions(-)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index 8fe53b4..b9ba028 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -64,7 +64,7 @@ typedef struct QuorumVotes {
>  
>  /* the following structure holds the state of one quorum instance */
>  typedef struct BDRVQuorumState {
> -    BlockDriverState **bs; /* children BlockDriverStates */
> +    BdrvChild **children;  /* children BlockDriverStates */
>      int num_children;      /* children count */
>      int threshold;         /* if less than threshold children reads gave the
>                              * same result a quorum error occurs.
> @@ -336,7 +336,7 @@ static void quorum_report_bad_versions(BDRVQuorumState *s,
>              continue;
>          }
>          QLIST_FOREACH(item, &version->items, next) {
> -            quorum_report_bad(acb, s->bs[item->index]->node_name, 0);
> +            quorum_report_bad(acb, s->children[item->index]->bs->node_name, 0);
>          }
>      }
>  }
> @@ -369,8 +369,9 @@ static bool quorum_rewrite_bad_versions(BDRVQuorumState *s, QuorumAIOCB *acb,
>              continue;
>          }
>          QLIST_FOREACH(item, &version->items, next) {
> -            bdrv_aio_writev(s->bs[item->index], acb->sector_num, acb->qiov,
> -                            acb->nb_sectors, quorum_rewrite_aio_cb, acb);
> +            bdrv_aio_writev(s->children[item->index]->bs, acb->sector_num,
> +                            acb->qiov, acb->nb_sectors, quorum_rewrite_aio_cb,
> +                            acb);
>          }
>      }
>  
> @@ -639,13 +640,13 @@ static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb)
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        acb->qcrs[i].buf = qemu_blockalign(s->bs[i], acb->qiov->size);
> +        acb->qcrs[i].buf = qemu_blockalign(s->children[i]->bs, acb->qiov->size);
>          qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov);
>          qemu_iovec_clone(&acb->qcrs[i].qiov, acb->qiov, acb->qcrs[i].buf);
>      }
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_aio_readv(s->bs[i], acb->sector_num, &acb->qcrs[i].qiov,
> +        bdrv_aio_readv(s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov,
>                         acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]);
>      }
>  
> @@ -656,12 +657,12 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)
>  {
>      BDRVQuorumState *s = acb->common.bs->opaque;
>  
> -    acb->qcrs[acb->child_iter].buf = qemu_blockalign(s->bs[acb->child_iter],
> -                                                     acb->qiov->size);
> +    acb->qcrs[acb->child_iter].buf =
> +        qemu_blockalign(s->children[acb->child_iter]->bs, acb->qiov->size);
>      qemu_iovec_init(&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov);
>      qemu_iovec_clone(&acb->qcrs[acb->child_iter].qiov, acb->qiov,
>                       acb->qcrs[acb->child_iter].buf);
> -    bdrv_aio_readv(s->bs[acb->child_iter], acb->sector_num,
> +    bdrv_aio_readv(s->children[acb->child_iter]->bs, acb->sector_num,
>                     &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors,
>                     quorum_aio_cb, &acb->qcrs[acb->child_iter]);
>  
> @@ -702,8 +703,8 @@ static BlockAIOCB *quorum_aio_writev(BlockDriverState *bs,
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        acb->qcrs[i].aiocb = bdrv_aio_writev(s->bs[i], sector_num, qiov,
> -                                             nb_sectors, &quorum_aio_cb,
> +        acb->qcrs[i].aiocb = bdrv_aio_writev(s->children[i]->bs, sector_num,
> +                                             qiov, nb_sectors, &quorum_aio_cb,
>                                               &acb->qcrs[i]);
>      }
>  
> @@ -717,12 +718,12 @@ static int64_t quorum_getlength(BlockDriverState *bs)
>      int i;
>  
>      /* check that all file have the same length */
> -    result = bdrv_getlength(s->bs[0]);
> +    result = bdrv_getlength(s->children[0]->bs);
>      if (result < 0) {
>          return result;
>      }
>      for (i = 1; i < s->num_children; i++) {
> -        int64_t value = bdrv_getlength(s->bs[i]);
> +        int64_t value = bdrv_getlength(s->children[i]->bs);
>          if (value < 0) {
>              return value;
>          }
> @@ -741,7 +742,7 @@ static void quorum_invalidate_cache(BlockDriverState *bs, Error **errp)
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_invalidate_cache(s->bs[i], &local_err);
> +        bdrv_invalidate_cache(s->children[i]->bs, &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
>              return;
> @@ -762,7 +763,7 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
>      error_votes.compare = quorum_64bits_compare;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        result = bdrv_co_flush(s->bs[i]);
> +        result = bdrv_co_flush(s->children[i]->bs);
>          result_value.l = result;
>          quorum_count_vote(&error_votes, &result_value, i);
>      }
> @@ -782,7 +783,7 @@ static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs,
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bool perm = bdrv_recurse_is_first_non_filter(s->bs[i],
> +        bool perm = bdrv_recurse_is_first_non_filter(s->children[i]->bs,
>                                                       candidate);
>          if (perm) {
>              return true;
> @@ -922,8 +923,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
>          }
>      }
>  
> -    /* allocate the children BlockDriverState array */
> -    s->bs = g_new0(BlockDriverState *, s->num_children);
> +    /* allocate the children array */
> +    s->children = g_new0(BdrvChild *, s->num_children);
>      opened = g_new0(bool, s->num_children);
>  
>      for (i = 0; i < s->num_children; i++) {
> @@ -931,9 +932,10 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
>          ret = snprintf(indexstr, 32, "children.%d", i);
>          assert(ret < 32);
>  
> -        ret = bdrv_open_image(&s->bs[i], NULL, options, indexstr, bs,
> -                              &child_format, false, &local_err);
> -        if (ret < 0) {
> +        s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
> +                                         &child_format, false, &local_err);
> +        if (local_err) {
> +            ret = -EINVAL;
>              goto close_exit;
>          }
>  
> @@ -949,9 +951,9 @@ close_exit:
>          if (!opened[i]) {
>              continue;
>          }
> -        bdrv_unref(s->bs[i]);
> +        bdrv_unref_child(bs, s->children[i]);
>      }
> -    g_free(s->bs);
> +    g_free(s->children);
>      g_free(opened);
>  exit:
>      qemu_opts_del(opts);
> @@ -968,10 +970,10 @@ static void quorum_close(BlockDriverState *bs)
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_unref(s->bs[i]);
> +        bdrv_unref_child(bs, s->children[i]);
>      }
>  
> -    g_free(s->bs);
> +    g_free(s->children);
>  }
>  
>  static void quorum_detach_aio_context(BlockDriverState *bs)
> @@ -980,7 +982,7 @@ static void quorum_detach_aio_context(BlockDriverState *bs)
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_detach_aio_context(s->bs[i]);
> +        bdrv_detach_aio_context(s->children[i]->bs);
>      }
>  }
>  
> @@ -991,7 +993,7 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_attach_aio_context(s->bs[i], new_context);
> +        bdrv_attach_aio_context(s->children[i]->bs, new_context);
>      }
>  }
>  
> @@ -1003,16 +1005,17 @@ static void quorum_refresh_filename(BlockDriverState *bs)
>      int i;
>  
>      for (i = 0; i < s->num_children; i++) {
> -        bdrv_refresh_filename(s->bs[i]);
> -        if (!s->bs[i]->full_open_options) {
> +        bdrv_refresh_filename(s->children[i]->bs);
> +        if (!s->children[i]->bs->full_open_options) {
>              return;
>          }
>      }
>  
>      children = qlist_new();
>      for (i = 0; i < s->num_children; i++) {
> -        QINCREF(s->bs[i]->full_open_options);
> -        qlist_append_obj(children, QOBJECT(s->bs[i]->full_open_options));
> +        QINCREF(s->children[i]->bs->full_open_options);
> +        qlist_append_obj(children,
> +                         QOBJECT(s->children[i]->bs->full_open_options));
>      }
>  
>      opts = qdict_new();
> -- 
> 1.8.3.1
>

Reviewed-by: Jeff Cody <jcody@redhat.com>

  reply	other threads:[~2015-10-13  0:59 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 12:15 [Qemu-devel] [PATCH v3 00/16] block: Get rid of bdrv_swap() Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 01/16] block: Introduce BDS.file_child Kevin Wolf
2015-10-13  0:43   ` Jeff Cody
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 02/16] vmdk: Use BdrvChild instead of BDS for references to extents Kevin Wolf
2015-10-13  0:55   ` Jeff Cody
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 03/16] blkverify: Convert s->test_file to BdrvChild Kevin Wolf
2015-10-13  0:57   ` Jeff Cody
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 04/16] quorum: Convert " Kevin Wolf
2015-10-13  0:58   ` Jeff Cody [this message]
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 05/16] block: Convert bs->file " Kevin Wolf
2015-10-13  1:33   ` Jeff Cody
2015-10-13  8:59     ` Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 06/16] block: Remove bdrv_open_image() Kevin Wolf
2015-10-13  1:33   ` Jeff Cody
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 07/16] block: Convert bs->backing_hd to BdrvChild Kevin Wolf
2015-10-12 13:07   ` Alberto Garcia
2015-10-12 16:55   ` Max Reitz
2015-10-13  1:53   ` Jeff Cody
2015-10-13  8:31     ` Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 08/16] block: Manage backing file references in bdrv_set_backing_hd() Kevin Wolf
2015-10-12 13:29   ` Alberto Garcia
2015-10-12 17:13   ` Max Reitz
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 09/16] block: Split bdrv_move_feature_fields() Kevin Wolf
2015-10-12 13:47   ` Alberto Garcia
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 10/16] block/io: Make bdrv_requests_pending() public Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 11/16] block-backend: Add blk_set_bs() Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 12/16] block: Introduce parents list Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 13/16] block: Implement bdrv_append() without bdrv_swap() Kevin Wolf
2015-10-12 14:27   ` Alberto Garcia
2015-10-13  8:39     ` Kevin Wolf
2015-10-13  9:01       ` Alberto Garcia
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 14/16] blockjob: Store device name at job creation Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 15/16] block: Add and use bdrv_replace_in_backing_chain() Kevin Wolf
2015-10-09 12:15 ` [Qemu-devel] [PATCH v3 16/16] block: Remove bdrv_swap() Kevin Wolf
2015-10-13 10:25 ` [Qemu-devel] [PATCH v3 00/16] block: Get rid of bdrv_swap() Stefan Hajnoczi
2015-10-13 11:18 ` 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=20151013005851.GK11943@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --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.