qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: virtio-fs@redhat.com, qemu-devel@nongnu.org, miklos@szeredi.hu
Subject: Re: [Virtio-fs] [PATCH 4/4] virtiofsd: Implement blocking posix locks
Date: Mon, 9 Dec 2019 11:06:17 +0000	[thread overview]
Message-ID: <20191209110617.GE3403@work-vm> (raw)
In-Reply-To: <20191127190808.GA18507@redhat.com>

* Vivek Goyal (vgoyal@redhat.com) wrote:
> On Tue, Nov 26, 2019 at 01:02:29PM +0000, Dr. David Alan Gilbert wrote:
> 
> [..]
> > > > > @@ -1950,21 +1948,54 @@ static void lo_setlk(fuse_req_t req, fuse_ino_t ino,
> > > > >  
> > > > >  	if (!plock) {
> > > > >  		saverr = ret;
> > > > > +		pthread_mutex_unlock(&inode->plock_mutex);
> > > > >  		goto out;
> > > > >  	}
> > > > >  
> > > > > +	/*
> > > > > +	 * plock is now released when inode is going away. We already have
> > > > > +	 * a reference on inode, so it is guaranteed that plock->fd is
> > > > > +	 * still around even after dropping inode->plock_mutex lock
> > > > > +	 */
> > > > > +	ofd = plock->fd;
> > > > > +	pthread_mutex_unlock(&inode->plock_mutex);
> > > > > +
> > > > > +	/*
> > > > > +	 * If this lock request can block, request caller to wait for
> > > > > +	 * notification. Do not access req after this. Once lock is
> > > > > +	 * available, send a notification instead.
> > > > > +	 */
> > > > > +	if (sleep && lock->l_type != F_UNLCK) {
> > > > > +		/*
> > > > > +		 * If notification queue is not enabled, can't support async
> > > > > +		 * locks.
> > > > > +		 */
> > > > > +		if (!se->notify_enabled) {
> > > > > +			saverr = EOPNOTSUPP;
> > > > > +			goto out;
> > > > > +		}
> > > > > +		async_lock = true;
> > > > > +		unique = req->unique;
> > > > > +		fuse_reply_wait(req);
> > > > > +	}
> > > > >  	/* TODO: Is it alright to modify flock? */
> > > > >  	lock->l_pid = 0;
> > > > > -	ret = fcntl(plock->fd, F_OFD_SETLK, lock);
> > > > > +	if (async_lock)
> > > > > +		ret = fcntl(ofd, F_OFD_SETLKW, lock);
> > > > > +	else
> > > > > +		ret = fcntl(ofd, F_OFD_SETLK, lock);
> > > > 
> > > > What happens if the guest is rebooted after it's asked
> > > > for, but not been granted a lock?
> > > 
> > > I think a regular reboot can't be done till a request is pending, because
> > > virtio-fs can't be unmounted and unmount will wait for all pending
> > > requests to finish.
> > > 
> > > Destroying qemu will destroy deamon too.
> > > 
> > > Are there any other reboot paths I have missed.
> > 
> > Yes, there are a few other ways the guest can reboot:
> >   a) A echo b > /proc/sysrq-trigger
> 
> I tried it. Both qemu and virtiofsd hang. virtiofsd wants to stop a 
> queue. And that tries to stop thrad pool. But one of the threads in
> thread pool is blocked on setlkw. So g_thread_pool_free() hangs.
> 
> I am not seeing any option in glib thread pool API to stop or send
> signal to threads which are blocked.

Is there a way to setup pthread_cancel ?  The upstream libfuse code
has somec ases where it enables cancellation very carefully around
something that might block, does it, then disables cancellation.

Dave

> Thanks
> Vivek
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



      reply	other threads:[~2019-12-09 11:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 20:55 [PATCH 0/4] [RFC] virtiofsd, vhost-user-fs: Add support for notification queue Vivek Goyal
2019-11-15 20:55 ` [PATCH 1/4] virtiofsd: Release file locks using F_UNLCK Vivek Goyal
2019-11-22 10:07   ` Stefan Hajnoczi
2019-11-22 13:45     ` Vivek Goyal
2019-11-15 20:55 ` [PATCH 2/4] virtiofd: Create a notification queue Vivek Goyal
2019-11-22 10:19   ` Stefan Hajnoczi
2019-11-22 14:47     ` Vivek Goyal
2019-11-22 17:29       ` Dr. David Alan Gilbert
2019-11-15 20:55 ` [PATCH 3/4] virtiofsd: Specify size of notification buffer using config space Vivek Goyal
2019-11-22 10:33   ` Stefan Hajnoczi
2019-11-25 14:57     ` Vivek Goyal
2019-11-15 20:55 ` [PATCH 4/4] virtiofsd: Implement blocking posix locks Vivek Goyal
2019-11-22 10:53   ` Stefan Hajnoczi
2019-11-25 15:38     ` [Virtio-fs] " Vivek Goyal
2019-11-22 17:47   ` Dr. David Alan Gilbert
2019-11-25 15:44     ` [Virtio-fs] " Vivek Goyal
2019-11-26 13:02       ` Dr. David Alan Gilbert
2019-11-27 19:08         ` Vivek Goyal
2019-12-09 11:06           ` Dr. David Alan Gilbert [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=20191209110617.GE3403@work-vm \
    --to=dgilbert@redhat.com \
    --cc=miklos@szeredi.hu \
    --cc=qemu-devel@nongnu.org \
    --cc=vgoyal@redhat.com \
    --cc=virtio-fs@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).