From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Rao, Lei" <lei.rao@intel.com>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
"vsementsov@virtuozzo.com" <vsementsov@virtuozzo.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Zhang, Chen" <chen.zhang@intel.com>,
"hreitz@redhat.com" <hreitz@redhat.com>,
"eblake@redhat.com" <eblake@redhat.com>
Subject: Re: [PATCH] QIO: Add force_quit to the QIOChannel to ensure QIO exits cleanly in some corner case
Date: Wed, 1 Dec 2021 10:06:27 +0000 [thread overview]
Message-ID: <YadJI0B4YrZTs3/m@redhat.com> (raw)
In-Reply-To: <DM8PR11MB5640D2F156E53A0CD644AC71FD689@DM8PR11MB5640.namprd11.prod.outlook.com>
On Wed, Dec 01, 2021 at 09:48:31AM +0000, Rao, Lei wrote:
>
>
> -----Original Message-----
> From: Daniel P. Berrangé <berrange@redhat.com>
> Sent: Wednesday, December 1, 2021 5:11 PM
> To: Rao, Lei <lei.rao@intel.com>
> Cc: Zhang, Chen <chen.zhang@intel.com>; eblake@redhat.com; vsementsov@virtuozzo.com; kwolf@redhat.com; hreitz@redhat.com; qemu-block@nongnu.org; qemu-devel@nongnu.org
> Subject: Re: [PATCH] QIO: Add force_quit to the QIOChannel to ensure QIO exits cleanly in some corner case
>
> >
> > Signed-off-by: Lei Rao <lei.rao@intel.com>
> > Signed-off-by: Zhang Chen <chen.zhang@intel.com>
> > ---
> > block/nbd.c | 5 +++++
> > include/io/channel.h | 19 +++++++++++++++++++
> > io/channel.c | 22 ++++++++++++++++++++++
> > 3 files changed, 46 insertions(+)
> >
> > diff --git a/block/nbd.c b/block/nbd.c index 5ef462db1b..5ee4eaaf57
> > 100644
> > --- a/block/nbd.c
> > +++ b/block/nbd.c
> > @@ -208,6 +208,8 @@ static void nbd_teardown_connection(BlockDriverState *bs)
> > assert(!s->in_flight);
> >
> > if (s->ioc) {
> > + qio_channel_set_force_quit(s->ioc, true);
> > + qio_channel_coroutines_wake(s->ioc);
> > qio_channel_shutdown(s->ioc, QIO_CHANNEL_SHUTDOWN_BOTH,
> > NULL);
>
> Calling shutdown here should already be causing the qio_chanel_readv_all to wakeup and break out of its
> poll() loop. We shouldn't need to add a second way to break out of the poll().
>
> Calling shutdown can wake up the coroutines which is polling. But I think it's not enough. I tried to forcibly wake up the NBD coroutine,
> It may cause segment fault. The root cause is that it will continue to access ioc->xxx in qio_channel_yield(), but the ioc has been released and set it NULL such as in
> nbd_co_do_establish_connection(); I think call shutdown will have the same result. So, I add the force_quit, once set it true, it will immediately exit without accessing IOC.
That's a bug in the NBD code then. NBD must not be freeing the IO channel
object while it is performing read/write API calls on it.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2021-12-01 10:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 7:54 [PATCH] QIO: Add force_quit to the QIOChannel to ensure QIO exits cleanly in some corner case Rao, Lei
2021-12-01 9:10 ` Daniel P. Berrangé
2021-12-01 9:48 ` Rao, Lei
2021-12-01 10:06 ` Daniel P. Berrangé [this message]
2021-12-01 14:27 ` Vladimir Sementsov-Ogievskiy
2021-12-02 2:49 ` Rao, Lei
2021-12-02 5:14 ` Rao, Lei
2021-12-02 8:53 ` Daniel P. Berrangé
2021-12-02 9:54 ` Vladimir Sementsov-Ogievskiy
2021-12-03 1:26 ` Rao, Lei
2021-12-13 8:02 ` Rao, Lei
2021-12-13 8:38 ` Vladimir Sementsov-Ogievskiy
2021-12-13 9:46 ` Rao, Lei
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=YadJI0B4YrZTs3/m@redhat.com \
--to=berrange@redhat.com \
--cc=chen.zhang@intel.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lei.rao@intel.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--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 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).