From: Kevin Wolf <kwolf@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: ronniesahlberg@gmail.com, qemu-devel@nongnu.org,
qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block/nfs: add support for nfs_umount
Date: Wed, 4 Sep 2019 11:34:59 +0200 [thread overview]
Message-ID: <20190904093459.GA21246@localhost.localdomain> (raw)
In-Reply-To: <1BDCDF9A-2146-43FE-AF4B-145F479AFD2B@kamp.de>
Am 03.09.2019 um 21:52 hat Peter Lieven geschrieben:
>
>
> > Am 03.09.2019 um 16:56 schrieb Kevin Wolf <kwolf@redhat.com>:
> >
> > Am 03.09.2019 um 15:44 hat Peter Lieven geschrieben:
> >> libnfs recently added support for unmounting. Add support
> >> in Qemu too.
> >>
> >> Signed-off-by: Peter Lieven <pl@kamp.de>
> >
> > Looks trivial enough to review even for me. :-)
> >
> > Thanks, applied to the block branch.
> >
> > Kevin
>
> I am not sure what the reason is, but with this patch I sometimes run
> into nfs_process_read being called for a cdrom mounted from nfs after
> I ejected it (and the whole nfs client context is already destroyed).
Does this mean that nfs_umount() gets some response, but we don't
properly wait for it? Or is some older request still in flight?
> It seems that the following fixes the issue. It might be that the
> nfs_umount call just reveals this bug. nfs_close is also doing sync
> I/O with the libnfs library. If we mount a nfs share we are doing
> everything with sync calls and then set up the aio stuff with
> nfs_set_events. I think that we need to stop the aio before we are
> executing the sync calls to nfs_close and nfs_umount.
Disabling the fd handlers is probably just papering over the problem. If
there is something in flight, we should wait for its completion. In
theory, block devices are drained before calling .bdrv_close, so
either we have a bug with draining nfs nodes correctly, or .bdrv_close
initiates something new itself that we should wait for.
> Also not sure if holding the mutex is necessary here.
Not for aio_set_fd_handler(), but I don't know the requirements of
nfs_get_fd().
Kevin
> diff --git a/block/nfs.c b/block/nfs.c
> index ffa6484c1a..cb2e0d375a 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -389,6 +389,10 @@ static void nfs_attach_aio_context(BlockDriverState *bs,
> static void nfs_client_close(NFSClient *client)
> {
> if (client->context) {
> + qemu_mutex_lock(&client->mutex);
> + aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
> + false, NULL, NULL, NULL, NULL);
> + qemu_mutex_unlock(&client->mutex);
> if (client->fh) {
> nfs_close(client->context, client->fh);
> client->fh = NULL;
> @@ -396,8 +400,6 @@ static void nfs_client_close(NFSClient *client)
> #ifdef LIBNFS_FEATURE_UMOUNT
> nfs_umount(client->context);
> #endif
> - aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
> - false, NULL, NULL, NULL, NULL);
> nfs_destroy_context(client->context);
> client->context = NULL;
> }
next prev parent reply other threads:[~2019-09-04 9:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 13:44 [Qemu-devel] [PATCH] block/nfs: add support for nfs_umount Peter Lieven
2019-09-03 14:56 ` Kevin Wolf
2019-09-03 19:52 ` Peter Lieven
2019-09-04 9:34 ` Kevin Wolf [this message]
2019-09-05 9:43 ` Peter Lieven
2019-09-05 10:05 ` ronnie sahlberg
2019-09-05 10:16 ` Peter Lieven
2019-09-05 10:28 ` ronnie sahlberg
2019-09-05 10:32 ` Peter Lieven
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=20190904093459.GA21246@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.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).