From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b03cv-0002rQ-AE for qemu-devel@nongnu.org; Tue, 10 May 2016 05:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b03ct-00025R-P7 for qemu-devel@nongnu.org; Tue, 10 May 2016 05:06:49 -0400 Date: Tue, 10 May 2016 10:06:35 +0100 From: "Richard W.M. Jones" Message-ID: <20160510090635.GW1683@redhat.com> References: <1462848659-28659-1-git-send-email-famz@redhat.com> <1462848659-28659-9-git-send-email-famz@redhat.com> <20160510085748.GD13377@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160510085748.GD13377@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Fam Zheng , qemu-devel@nongnu.org, Kevin Wolf , Max Reitz , Jeff Cody , Markus Armbruster , Eric Blake , qemu-block@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, John Snow , den@openvz.org On Tue, May 10, 2016 at 09:57:48AM +0100, Daniel P. Berrange wrote: > On Tue, May 10, 2016 at 10:50:40AM +0800, Fam Zheng wrote: > > They are wrappers of POSIX fcntl file locking, with the additional > > interception of open/close (through qemu_open and qemu_close) to offer a > > better semantics that preserves the locks across multiple life cycles of > > different fds on the same file. The reason to make this semantics > > change over the fcntl locks is to make the API cleaner for QEMU > > subsystems. > > > > More precisely, we remove this "feature" of fcntl lock: > > > > If a process closes any file descriptor referring to a file, then > > all of the process's locks on that file are released, regardless of > > the file descriptor(s) on which the locks were obtained. > > > > as long as the fd is always open/closed through qemu_open and > > qemu_close. > > You're not actually really removing that problem - this is just hacking > around it in a manner which is racy & susceptible to silent failure. Whatever happened to file-private locks (https://lwn.net/Articles/586904/)? My very recent glibc doesn't appear to include them, unless the final standard used something different from `F_SETLKPW'. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top