From: Paolo Bonzini <pbonzini@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>, qemu-devl <qemu-devel@nongnu.org>
Cc: qemu-stable <qemu-stable@nongnu.org>,
Li Zhijian <lizhijian@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v2] nbd: release exp->blk after all clients are closed
Date: Wed, 16 Sep 2015 10:41:29 +0200 [thread overview]
Message-ID: <55F92B39.9000506@redhat.com> (raw)
In-Reply-To: <55F929E2.1020501@cn.fujitsu.com>
On 16/09/2015 10:35, Wen Congyang wrote:
> If the socket fd is shutdown, there may be some data which is received before
> shutdown. We will read the data and do read/write in nbd_trip(). But the exp's
> blk is NULL, and it will cause qemu crashed.
>
> Reported-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Thanks, this looks good. I have added
Cc: qemu-stable@nongnu.org
and will send a pull request soon.
Paolo
> ---
> nbd.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/nbd.c b/nbd.c
> index 06b501b..07240bd 100644
> --- a/nbd.c
> +++ b/nbd.c
> @@ -1131,12 +1131,6 @@ void nbd_export_close(NBDExport *exp)
> }
> nbd_export_set_name(exp, NULL);
> nbd_export_put(exp);
> - if (exp->blk) {
> - blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
> - blk_aio_detach, exp);
> - blk_unref(exp->blk);
> - exp->blk = NULL;
> - }
> }
>
> void nbd_export_get(NBDExport *exp)
> @@ -1159,6 +1153,13 @@ void nbd_export_put(NBDExport *exp)
> exp->close(exp);
> }
>
> + if (exp->blk) {
> + blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
> + blk_aio_detach, exp);
> + blk_unref(exp->blk);
> + exp->blk = NULL;
> + }
> +
> g_free(exp);
> }
> }
> @@ -1305,6 +1306,14 @@ static void nbd_trip(void *opaque)
> goto invalid_request;
> }
>
> + if (client->closing) {
> + /*
> + * The client may be closed when we are blocked in
> + * nbd_co_receive_request()
> + */
> + goto done;
> + }
> +
> switch (command) {
> case NBD_CMD_READ:
> TRACE("Request type is READ");
>
prev parent reply other threads:[~2015-09-16 8:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 8:35 [Qemu-devel] [PATCH v2] nbd: release exp->blk after all clients are closed Wen Congyang
2015-09-16 8:41 ` Paolo Bonzini [this message]
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=55F92B39.9000506@redhat.com \
--to=pbonzini@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=wency@cn.fujitsu.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).