From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKFgX-0005O7-Uw for qemu-devel@nongnu.org; Thu, 12 Sep 2013 18:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKFgQ-0003AD-UI for qemu-devel@nongnu.org; Thu, 12 Sep 2013 18:48:25 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58888 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKFgQ-00039g-KZ for qemu-devel@nongnu.org; Thu, 12 Sep 2013 18:48:18 -0400 Date: Fri, 13 Sep 2013 08:48:04 +1000 From: NeilBrown Message-ID: <20130913084804.6648725c@notabene.brown> In-Reply-To: <20130912142750.GK3514@dhcp-200-207.str.redhat.com> References: <5231A524.2080103@profitbricks.com> <20130912135836.GE18070@stefanha-thinkpad.redhat.com> <20130912142750.GK3514@dhcp-200-207.str.redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/ei_DjwerdqBkb/zj879mvwd"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [RFC] O_EXCL or not open block device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Jack Wang , Paolo Bonzini , Dongsu Park , Stefan Hajnoczi , qemu-devel --Sig_/ei_DjwerdqBkb/zj879mvwd Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 12 Sep 2013 16:27:50 +0200 Kevin Wolf wrote: > Am 12.09.2013 um 15:58 hat Stefan Hajnoczi geschrieben: > > On Thu, Sep 12, 2013 at 01:27:32PM +0200, Jack Wang wrote: > > > Hi all, > > >=20 > > > We're using qemu export md-raid to guest OS, and we saw deadlock on > > > MD(which is already fixed by Neil), please see thread below: > > > > http://marc.info/?l=3Dlinux-raid&m=3D137894040228125&w=3D2 > > >=20 > > > As Neil suggested it would be good for userspace applications to call > > > open() with O_EXCL flag, to avoid such MD hanging problems at the beg= ining. > > >=20 > > > And we checked qemu, it looks it doesn't include O_EXCL flag when open > > > block device. > > >=20 > > > After search in the mail list we found there are a similar discussion: > > >=20 > > > https://lists.nongnu.org/archive/html/qemu-devel/2011-04/msg00722.html > > >=20 > > > > To O_EXCL or not to O_EXCL open host_cdrom > > >=20 > > > Which looks prefer enable O_EXCL, but I checked latest qemu tree, the= re > > > no such code, could anyone give comments on this? > >=20 > > Continuing from that discussion, I think the shared CD-ROM case is > > something we must avoid breaking. It worked in the past so it shouldn't > > break in a new QEMU version. > >=20 > > Kevin: Do you think we should add an option to the host_device > > BlockDriver that sets the O_EXCL open flag? That way users and new > > libvirt can use O_EXCL for host block devices. > >=20 > > The simpler alternative is to always use O_EXCL for non-CDROM host > > devices. Simple patch, no configuration required, but it means we > > continue to lack O_EXCL on CD-ROMs. >=20 > I'm not sure why O_EXCL would be correct on generic block devices when > it's wrong on CD-ROMs. I think it's in fact more likely that other > devices are shared, as backing files. O_EXCL make sense if you or someone else might change the contents. If the device is read-only, or is uniformly treated as read-only, then O_EX= CL is unnecessary and could definitely get in the way. I would be nice if we had O_SHARED and O_EXCL, but unfortunately we don't..= .. I wonder if O_EXCL|O_RDONLY could be treated as a shared lock.... Maybe one day. >=20 > Adding an option is certainly possible, but what would the default be? > If O_EXCL is off by default, would anyone actually use it? I would suggest the default would be to use O_EXCL iff opening with WRITE access. NeilBrown --Sig_/ei_DjwerdqBkb/zj879mvwd Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQIVAwUBUjJEpDnsnt1WYoG5AQLogxAAu8KBsLt6bd1XfLhMkbCnc12/gWZUUgPt 63fwskl6GXm8Gh+t9Kfs++Aco7qFE2S623AcI13RA1XJK6Sp81PO/7Sjx3C2FKAD HwEFo1+p4W4pxXTYJZEqibA/RCq6o3Tf96SE4yFfH+PpbhmOrHbB57wF8Hnn+a0r C04/FQGFaJQ9dniZk8rkuGEceUtV9MhPo9ZpmYdMQPjf6e+SebTyEmcciuKxoNag Q2QGmwJnEmF2iJ1aFy5F1Y5NTJQIKkRCeeP2RdjFEnKGXlrOgWt3mE+uds/P6u95 TmWBsykDFq0VvvFoGr83MzLvmvqKiuCkArJPtjmXblOfMfP8M7wwWbjl6w3f20km O3yS9NAY6DReNlvTvNz16RwCJpjCFp3R9Y+5xoWCNuISZyNx359+YI1l5+VFSnAu qCZSOTqUDu4C9zmScsixQ8v3uWVXMNhxU4sTXMmHPLKsJgyhIU8USgoqZpET0Zib 55wHALXfdD6q0/GwVddemlzxKuVozg62+Y+cqPUGLsusNKQQNRH6/zPy8ENkiUxo Uwh4MnNQj9PTYOjx0QsLk4XX5XwGpTObtBvrjz+GjZjgR1DEQtNlGpEAt98XpQez 4CrPq0jFQywcCGeWeEWGXTAo48wgqS/nMJK9Mp0vvpHoVVkAlq8Pi56H6mNAixyR 8LFMipgI0I8= =297s -----END PGP SIGNATURE----- --Sig_/ei_DjwerdqBkb/zj879mvwd--