From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGyqr-0001Re-TW for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:55:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGyqn-0001LS-Bb for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:55:25 -0500 Received: from [199.232.76.173] (port=33979 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGyqn-0001LA-1N for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:55:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22435) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGyqm-0001TP-S4 for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:55:21 -0500 Message-ID: <4B1A9E83.2050103@redhat.com> Date: Sat, 05 Dec 2009 19:55:15 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Disk image shared and exclusive locks. References: <20091204165301.GA4167@amd.home.annexia.org> <4B1943A0.7030509@codemonkey.ws> <20091204215517.GA5938@amd.home.annexia.org> <4B198D5B.5080803@codemonkey.ws> <4B1A98D9.7010408@redhat.com> <4B1A9C9F.5040705@codemonkey.ws> In-Reply-To: <4B1A9C9F.5040705@codemonkey.ws> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: "Richard W.M. Jones" , qemu-devel@nongnu.org On 12/05/2009 07:47 PM, Anthony Liguori wrote: > Avi Kivity wrote: >> On 12/05/2009 12:29 AM, Anthony Liguori wrote: >>> >>> Well disk sharing isn't actually bad as long as it's raw or a >>> physical device. >>> >>> For qcow2, it's very complicated by backing files because we really >>> need to express the concept of a read-write lock. >>> >>> That is, as long as the guests are opening the file read only, you >>> should allow many readers. However, you should prevent anyone from >>> opening with write permission. Likewise, writes should prevent >>> future reads. >>> >> >> Well shared/exclusive or read/write locks support exactly that. >> >> For non-raw storage we should take the locks unconditionally, since >> there is no useful way to share such images opened for write access. >> > > I think I made my point poorly. Consider the following: > > qemu-img create -f raw base.img 10G > qemu-img create -f qcow2 -b base.img cow1.img > qemu-img create -f qcow2 -b base.img cow2.img > > qemu -drive file=cow1.img,lock=exclusive > qemu -drive file=cow2.img,lock=exclusive > > With the current patch, the second command will fail and it's > impossible to invoke correctly. That's because flags are passed down > to backing devices directly. You really need to be much smarter here > in how you handle locking. Oh, that's just an implementation bug. Obviously there's no need to open a file for exclusive access if it will only be accessed for read (when merging a snapshot we'd need to upgrade the lock to exclusive while that takes place). I thought you objected to the whole concept. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.