From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHexn-0003qs-N5 for qemu-devel@nongnu.org; Mon, 07 Dec 2009 09:53:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHexi-0003mL-VR for qemu-devel@nongnu.org; Mon, 07 Dec 2009 09:53:23 -0500 Received: from [199.232.76.173] (port=34742 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHexi-0003mA-Qk for qemu-devel@nongnu.org; Mon, 07 Dec 2009 09:53:18 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:38138) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHexi-0005jF-MX for qemu-devel@nongnu.org; Mon, 07 Dec 2009 09:53:18 -0500 Received: by yxe26 with SMTP id 26so4181189yxe.4 for ; Mon, 07 Dec 2009 06:53:17 -0800 (PST) Message-ID: <4B1D16DA.6040405@codemonkey.ws> Date: Mon, 07 Dec 2009 08:53:14 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Disk image shared and exclusive locks. References: <4B1A9C9F.5040705@codemonkey.ws> <4B1A9E83.2050103@redhat.com> <4B1A9F8C.3010106@codemonkey.ws> <20091207103128.GA26970@shareable.org> <20091207104517.GJ24530@redhat.com> <20091207111953.GA29980@shareable.org> <20091207113014.GK24530@redhat.com> <4B1D0699.4070402@codemonkey.ws> <20091207140132.GN24530@redhat.com> <4B1D0E17.7040507@codemonkey.ws> <20091207142814.GQ24530@redhat.com> In-Reply-To: <20091207142814.GQ24530@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: "Richard W.M. Jones" , qemu-devel@nongnu.org, Avi Kivity Daniel P. Berrange wrote: > It is safe if you assume that no one else has tried to modify the disk > since you opened it, otherwise you'd be commiting changes against a > base state which no longer exists. 1) first user opens cow1.qcow, acquires F_WRLCK 2) first user opens base.qcow, acquires F_RDLCK 3) second user opens cow2.qcow, acquires F_WRLCK 4) second user opens base.qcow, acquires F_RDLCK 5) second user attempts to commit cow2.qcow to base.qcow, tries to acquire F_WRLCK. Calling F_SETLK with F_WRLCK will drop the F_RDLCK and upgrade to F_WRLCK. 6) F_SETLK fails because another process is holding F_RDLCK, error is printed to user Now assume that there is only one user and commit succeeded, then we'd drop back down to F_RDLCK (after an fsync) which means that afterwards, people could open up the image again. Regards, Anthony Liguori