qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] docs: document file-posix locking protocol


From: Daniel P . Berrangé
Subject: Re: [PATCH v2] docs: document file-posix locking protocol
Date: Thu, 15 Jul 2021 18:19:05 +0100
User-agent: Mutt/2.0.7 (2021-05-04)

On Thu, Jul 15, 2021 at 08:13:40PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> 03.07.2021 17:50, Nir Soffer wrote:
> > On Sat, Jul 3, 2021 at 4:51 PM Vladimir Sementsov-Ogievskiy
> > <vsementsov@virtuozzo.com> wrote:
> 
> [..]
> 
> > > +
> > > +Important notice: Qemu may fallback to POSIX file locks only if OFD locks
> > > +unavailable. Other programs should behave similarly: use POSIX file locks
> > > +only if OFD locks unavailable and if you are OK with drawbacks of POSIX
> > > +file locks (for example, they are lost on close() of any file descriptor
> > > +for that file).
> > 
> > Worth an example.
> 
> Hmm.. Copying here the whole #ifdef and probing logic around these locks from 
> Qemu is too much..
> 
> I can't imagine what small and short could be added here.
> 
> Actually I think, OFD is old enough so we shouldn't care
> too much about older kernels without it. Let's just rewrite
> paragraph to something like this:

Yes, that's a good point. From a Linux POV, I think our platform
support matrix means we can assume existance of OFD locking
unconditionally. The kernel impl transparently applies to all
filesystems too.

So we could likely change the code such that Linux always uses
OFD and non-Linux uses traditional POSIX locks.

> Related question, are POSIX locks somehow compatible with OFD
> locks? If one program use OFD and the other use POSIX locks on
> the same file.. Will it work or not?

Yes, the kernel level implementation uses the same locking primitives
internally. The only difference between the two is how they're invoked
from userspace, and the semantics around lock release when closing
files. So it is fully compatible with applications mixing the two
APIs for fcntl POSIX and OFD locking

The flock() syscall is however completely independant locking
from the fcntl based locking.


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 :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]