From: Wen Congyang <wency@cn.fujitsu.com>
To: Alberto Garcia <berto@igalia.com>,
qemu devel <qemu-devel@nongnu.org>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
qemu block <qemu-block@nongnu.org>,
Jiang Yunhong <yunhong.jiang@intel.com>,
Dong Eddie <eddie.dong@intel.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Gonglei <arei.gonglei@huawei.com>,
Yang Hongyang <yanghy@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v5 2/4] quorum: implement bdrv_add_child() and bdrv_del_child()
Date: Thu, 8 Oct 2015 10:10:14 +0800 [thread overview]
Message-ID: <5615D086.1090505@cn.fujitsu.com> (raw)
In-Reply-To: <w51k2qyhinl.fsf@maestria.local.igalia.com>
On 10/07/2015 10:12 PM, Alberto Garcia wrote:
> On Tue 22 Sep 2015 09:44:20 AM CEST, Wen Congyang wrote:
>
>> +++ b/block/quorum.c
>> @@ -66,6 +66,9 @@ typedef struct QuorumVotes {
>> typedef struct BDRVQuorumState {
>> BlockDriverState **bs; /* children BlockDriverStates */
>> int num_children; /* children count */
>> + int max_children; /* The maximum children count, we need to reallocate
>> + * bs if num_children grows larger than maximum.
>> + */
>> int threshold; /* if less than threshold children reads gave the
>> * same result a quorum error occurs.
>> */
>
> As you announce in the cover letter of this series, your code depends on
> the parents list patch written by Kevin here:
>
> http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html
>
> As you might be aware, and as part of the same series by Kevin,
> BDRVQuorumState will no longer hold a list of BlockDriverState but a
> list of BdrvChild instead:
>
> https://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04571.html
I notice that, and I only one patch from Kevin now. I will fix it in the
next version.
>
>> +static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
>> + Error **errp)
>> +{
>> + BDRVQuorumState *s = bs->opaque;
>> +
>> + bdrv_drain(bs);
>> +
>> + if (s->num_children == s->max_children) {
>> + if (s->max_children >= INT_MAX) {
>> + error_setg(errp, "Too many children");
>> + return;
>> + }
>
> max_children can never be greater than INT_MAX. Use == instead.
>
>> + s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1);
>> + s->bs[s->num_children] = NULL;
>
> No need to set the pointer to NULL here, and you are anyway setting the
> pointer to the new child a few lines afterwards.
Yes, I will remove it in the next version.
>
>> + s->max_children++;
>> + }
>> +
>> + bdrv_ref(child_bs);
>> + bdrv_attach_child(bs, child_bs, &child_format);
>> + s->bs[s->num_children++] = child_bs;
>> +}
>> +
>> +static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
>> + Error **errp)
>> +{
>> + BDRVQuorumState *s = bs->opaque;
>> + BdrvChild *child;
>> + int i;
>> +
>> + for (i = 0; i < s->num_children; i++) {
>> + if (s->bs[i] == child_bs) {
>> + break;
>> + }
>> + }
>> +
>> + QLIST_FOREACH(child, &bs->children, next) {
>> + if (child->bs == child_bs) {
>> + break;
>> + }
>> + }
>> +
>> + /* we have checked it in bdrv_del_child() */
>> + assert(i < s->num_children && child);
>> +
>> + if (s->num_children <= s->threshold) {
>> + error_setg(errp,
>> + "The number of children cannot be lower than the vote threshold %d",
>> + s->threshold);
>> + return;
>> + }
>> +
>> + bdrv_drain(bs);
>> + /* We can safely remove this child now */
>> + memmove(&s->bs[i], &s->bs[i + 1],
>> + (s->num_children - i - 1) * sizeof(void *));
>> + s->num_children--;
>> + s->bs[s->num_children] = NULL;
>
> Same here, no one will check or use s->bs[s->num_children] so there's no
> need to make it NULL.
>
> Apart from the issue of using only part of Kevin's series, the rest are
> minor things.
I will fix it in the next version.
>
> Thanks and sorry for the late review!
Thanks for your review
Wen Congyang
>
> Berto
> .
>
next prev parent reply other threads:[~2015-10-08 2:10 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 7:44 [Qemu-devel] [PATCH v5 0/4] qapi: child add/delete support Wen Congyang
2015-09-22 7:44 ` [Qemu-devel] [PATCH v5 1/4] Add new block driver interface to add/delete a BDS's child Wen Congyang
2015-10-07 13:35 ` Alberto Garcia
2015-10-08 2:05 ` Wen Congyang
2015-10-07 18:33 ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-10-08 2:06 ` Wen Congyang
2015-10-07 19:00 ` [Qemu-devel] " Dr. David Alan Gilbert
2015-10-08 2:03 ` Wen Congyang
2015-10-08 18:44 ` Dr. David Alan Gilbert
2015-09-22 7:44 ` [Qemu-devel] [PATCH v5 2/4] quorum: implement bdrv_add_child() and bdrv_del_child() Wen Congyang
2015-10-07 14:12 ` Alberto Garcia
2015-10-08 2:10 ` Wen Congyang [this message]
2015-10-07 18:51 ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-10-08 8:12 ` Alberto Garcia
2015-10-09 15:51 ` Max Reitz
2015-10-12 11:56 ` Alberto Garcia
2015-09-22 7:44 ` [Qemu-devel] [PATCH v5 3/4] qmp: add monitor command to add/remove a child Wen Congyang
2015-10-07 14:33 ` Alberto Garcia
2015-10-07 19:42 ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-10-08 6:15 ` Markus Armbruster
2015-10-08 8:29 ` Alberto Garcia
2015-10-08 10:03 ` Kevin Wolf
2015-10-08 10:13 ` Alberto Garcia
2015-10-09 16:14 ` Max Reitz
2015-10-08 11:02 ` [Qemu-devel] Dynamic reconfiguration (was: qmp: add monitor command to add/remove a child) Kevin Wolf
2015-10-08 11:10 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2015-10-21 8:27 ` [Qemu-devel] [Qemu-block] Dynamic reconfiguration Markus Armbruster
2015-10-26 2:04 ` Wen Congyang
2015-10-26 7:24 ` Markus Armbruster
2015-10-26 7:25 ` Wen Congyang
2015-10-09 16:13 ` [Qemu-devel] [Qemu-block] [PATCH v5 3/4] qmp: add monitor command to add/remove a child Max Reitz
2015-10-09 16:42 ` Dr. David Alan Gilbert
2015-10-09 18:24 ` Max Reitz
2015-10-12 8:07 ` Dr. David Alan Gilbert
2015-10-12 8:18 ` Kevin Wolf
2015-10-12 7:58 ` Markus Armbruster
2015-10-12 7:56 ` Markus Armbruster
2015-10-12 16:27 ` Max Reitz
2015-09-22 7:44 ` [Qemu-devel] [PATCH v5 4/4] hmp: " Wen Congyang
2015-10-07 14:38 ` Alberto Garcia
2015-09-22 11:15 ` [Qemu-devel] [PATCH v5 0/4] qapi: child add/delete support Dr. David Alan Gilbert
2015-09-23 1:08 ` Wen Congyang
2015-09-23 9:21 ` Dr. David Alan Gilbert
2015-09-23 9:30 ` Wen Congyang
2015-10-07 6:40 ` Wen Congyang
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=5615D086.1090505@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eddie.dong@intel.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=yanghy@cn.fujitsu.com \
--cc=yunhong.jiang@intel.com \
--cc=zhang.zhanghailiang@huawei.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.