From: Fam Zheng <famz@redhat.com>
To: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: John Snow <jsnow@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Disable image locking for snapshot drive?
Date: Fri, 21 Jul 2017 09:46:11 +0800 [thread overview]
Message-ID: <20170721014611.GL11032@lemon> (raw)
In-Reply-To: <DM2PR21MB00604522F0A851502DF8B4FD9EA70@DM2PR21MB0060.namprd21.prod.outlook.com>
On Thu, 07/20 21:49, Andrew Baumann via Qemu-devel wrote:
> > From: Fam Zheng [mailto:famz@redhat.com]
> > Sent: Wednesday, 19 July 2017 23:53
> >
> > On Tue, 07/18 16:19, Andrew Baumann wrote:
> > > > From: Eric Blake [mailto:eblake@redhat.com]
> > > > Sent: Tuesday, 18 July 2017 8:07
> > > > On 07/17/2017 07:33 PM, John Snow wrote:
> > > > > On 07/17/2017 07:30 PM, Andrew Baumann via Qemu-devel wrote:
> > > > >> I'm running a recent Linux build of qemu on Windows Subsystem for
> > Linux
> > > > (WSL) which doesn't appear to implement file locking:
> > > > >>
> > > > >> $ qemu-system-aarch64 ... -drive file=test.vhdx,if=none,id=hd0 -
> > device
> > > > virtio-blk-pci,drive=hd0
> > > > >> qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to
> > > > unlock byte 100
> > > >
> > > > Does WSL implement fcntl(F_SETLK) but not fcntl(F_OFD_SETLK)?
> > >
> > > Yes, this appears to be the case (there's also one report that it's broken):
> > > https://github.com/Microsoft/BashOnWindows/issues/1927
> >
> > What does fcntl(F_OFD_SETLK) return? If it is -ENOTSUP, we can probably
> > detect
> > that and disable locking. Can you try the patch pasted in the end?
>
> It returns -EINVAL. Your patch works, if I change the error code. Maybe
> testing for either ENOTSUP or EINVAL, and only allowing the fallback if the
> user didn't force locking on, would be a reasonable compromise?
I'm less comfortable with treating -EINVAL as "not supported".
A better fallback simply disabling is probably F_SETLK. Anyway I think a message
to stderr should be printed like the "#ifndef F_OFD_SETLK" case.
I'll work on a formal patch which does that.
Thanks,
Fam
>
> Cheers,
> Andrew
>
> > ---
> >
> > diff --git a/block/file-posix.c b/block/file-posix.c
> > index cfbb236f6f..0be5bbbd53 100644
> > --- a/block/file-posix.c
> > +++ b/block/file-posix.c
> > @@ -493,6 +493,12 @@ static int raw_open_common(BlockDriverState *bs,
> > QDict *options,
> > }
> > s->fd = fd;
> >
> > + if (s->use_lock) {
> > + int ret0 = qemu_unlock_fd(fd, 0, 0);
> > + if (ret0 == -ENOTSUP) {
> > + s->use_lock = false;
> > + }
> > + }
> > s->lock_fd = -1;
> > if (s->use_lock) {
> > fd = qemu_open(filename, s->open_flags);
>
prev parent reply other threads:[~2017-07-21 1:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 23:30 [Qemu-devel] Disable image locking for snapshot drive? Andrew Baumann
2017-07-18 0:33 ` John Snow
2017-07-18 2:19 ` Andrew Baumann
2017-07-18 15:07 ` Eric Blake
2017-07-18 16:19 ` Andrew Baumann
2017-07-20 6:53 ` Fam Zheng
2017-07-20 21:49 ` Andrew Baumann
2017-07-21 1:46 ` Fam Zheng [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=20170721014611.GL11032@lemon \
--to=famz@redhat.com \
--cc=Andrew.Baumann@microsoft.com \
--cc=jsnow@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).