From: Bin Wu <wu.wubin@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] fix the co_queue multi-adding bug
Date: Mon, 9 Feb 2015 17:47:29 +0800 [thread overview]
Message-ID: <54D88231.3060706@huawei.com> (raw)
In-Reply-To: <54D87C7B.9010600@redhat.com>
On 2015/2/9 17:23, Paolo Bonzini wrote:
>
>
> On 07/02/2015 10:51, w00214312 wrote:
>> From: Bin Wu <wu.wubin@huawei.com>
>>
>> When we test the drive_mirror between different hosts by ndb devices,
>> we find that, during the cancel phase the qemu process crashes sometimes.
>> By checking the crash core file, we find the stack as follows, which means
>> a coroutine re-enter error occurs:
>
> This bug probably can be fixed simply by delaying the setting of
> recv_coroutine.
>
> What are the symptoms if you only apply your "qemu-coroutine-lock: fix
> co_queue multi-adding bug" patch but not "qemu-coroutine: fix
> qemu_co_queue_run_restart error"?
>
> Can you try the patch below? (Compile-tested only).
>
yes, I think this patch can solve the problem too. I will try the patch latter.
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index 6e1c97c..23d6a71 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -104,10 +104,21 @@ static int nbd_co_send_request(NbdClientSession *s,
> QEMUIOVector *qiov, int offset)
> {
> AioContext *aio_context;
> - int rc, ret;
> + int rc, ret, i;
>
> qemu_co_mutex_lock(&s->send_mutex);
> +
> + for (i = 0; i < MAX_NBD_REQUESTS; i++) {
> + if (s->recv_coroutine[i] == NULL) {
> + s->recv_coroutine[i] = qemu_coroutine_self();
> + break;
> + }
> + }
> +
> + assert(i < MAX_NBD_REQUESTS);
> + request->handle = INDEX_TO_HANDLE(s, i);
> s->send_coroutine = qemu_coroutine_self();
> +
> aio_context = bdrv_get_aio_context(s->bs);
> aio_set_fd_handler(aio_context, s->sock,
> nbd_reply_ready, nbd_restart_write, s);
> @@ -164,8 +175,6 @@ static void nbd_co_receive_reply(NbdClientSession *s,
> static void nbd_coroutine_start(NbdClientSession *s,
> struct nbd_request *request)
> {
> - int i;
> -
> /* Poor man semaphore. The free_sema is locked when no other request
> * can be accepted, and unlocked after receiving one reply. */
> if (s->in_flight >= MAX_NBD_REQUESTS - 1) {
> @@ -174,15 +183,7 @@ static void nbd_coroutine_start(NbdClientSession *s,
> }
> s->in_flight++;
>
> - for (i = 0; i < MAX_NBD_REQUESTS; i++) {
> - if (s->recv_coroutine[i] == NULL) {
> - s->recv_coroutine[i] = qemu_coroutine_self();
> - break;
> - }
> - }
> -
> - assert(i < MAX_NBD_REQUESTS);
> - request->handle = INDEX_TO_HANDLE(s, i);
> + /* s->recv_coroutine[i] is set as soon as we get the send_lock. */
> }
>
> static void nbd_coroutine_end(NbdClientSession *s,
>
>
>
--
Bin Wu
next prev parent reply other threads:[~2015-02-09 9:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-07 9:51 [Qemu-devel] [PATCH] fix the co_queue multi-adding bug w00214312
2015-02-07 9:51 ` [Qemu-devel] [PATCH] qemu-coroutine-lock: fix " w00214312
2015-02-09 8:12 ` Fam Zheng
2015-02-09 9:36 ` Bin Wu
2015-02-09 9:37 ` Paolo Bonzini
2015-02-09 10:12 ` Kevin Wolf
2015-02-10 1:08 ` Bin Wu
2015-02-09 9:23 ` [Qemu-devel] [PATCH] fix the " Paolo Bonzini
2015-02-09 9:47 ` Bin Wu [this message]
2015-02-10 6:34 ` Bin Wu
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=54D88231.3060706@huawei.com \
--to=wu.wubin@huawei.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).