[libvirt] Use flock() instead of fcntl()

Daniel P. Berrange berrange at redhat.com
Thu Jul 25 09:31:40 UTC 2013


On Thu, Jul 25, 2013 at 08:23:24AM +0000, David Weber wrote:
> Hi,
> 
> we are interested in using virtlockd on an OCFS2 shared filesystem.
> We are now facing the problem that virtlockd uses fcntl() locks which 
> aren't supported by OCFS2 with the o2cb cluster stack and we want 
> to avoid using indirect leases.
> 
> OCFS2 instead supports flock() which is quite similar to fcntl(). I 
> attached a patch which makes libvirt use flock() *instead* of fcntl() 
> and it seems to work.
> 
> NFS on the contrast only supports fcntl() so it should be configurable 
> which lock type to use.
> 
> I'm not very experienced with locking, so would such a patch be
> acceptable or do you see possible problems with it?

We definitely can't use flock() unconditionally like that, as it is
less widely supported than fcntl() locking and is known broken on
most network filesystems (flock() will only lock wrt the local node,
not network-wide).

I'm pretty surprised that you can fcntl() is not supported in ocfs2.
Are you really sure about that ?

This mail message suggests it is supported

  https://oss.oracle.com/pipermail/ocfs2-users/2009-June/003572.html

"Support for fcntl locking aka file-range locking aka posix locking is
 provided by vfs for all file systems. However, that support is appropriate
 only for local file systems.

 In ocfs2, we have added support for cluster-aware fcntl locking via
 the userspace clustering framework that allows one to use ocfs2 with
 different cluster-stacks."

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list