From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhUfZ-0007dB-Kh for qemu-devel@nongnu.org; Wed, 30 Sep 2015 23:36:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhUfY-00069k-IC for qemu-devel@nongnu.org; Wed, 30 Sep 2015 23:36:33 -0400 References: <1443542050-26720-1-git-send-email-rjones@redhat.com> From: Eric Blake Message-ID: <560CAA3A.3090502@redhat.com> Date: Wed, 30 Sep 2015 21:36:26 -0600 MIME-Version: 1.0 In-Reply-To: <1443542050-26720-1-git-send-email-rjones@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7DkE7JIlGMtCAE04WjONU9SfjEHfQC6iR" Subject: Re: [Qemu-devel] [PATCH] block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" , kwolf@redhat.com Cc: codonell@redhat.com, dgilbert@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --7DkE7JIlGMtCAE04WjONU9SfjEHfQC6iR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/29/2015 09:54 AM, Richard W.M. Jones wrote: > https://bugzilla.redhat.com/show_bug.cgi?id=3D1265196 >=20 > The following command fails on an NFS mountpoint: >=20 > $ qemu-img create -f qcow2 -o preallocation=3Dfalloc disk.img 262144 > Formatting 'disk.img', fmt=3Dqcow2 size=3D262144 encryption=3Doff clu= ster_size=3D65536 preallocation=3D'falloc' lazy_refcounts=3Doff > qemu-img: disk.img: Could not preallocate data for the new file: Bad = file descriptor >=20 > The reason turns out to be because NFS doesn't support the > posix_fallocate call. glibc emulates it instead. However glibc's > emulation involves using the pread(2) syscall. The pread syscall > fails with EBADF if the file descriptor is opened without the read > open-flag (ie. open (..., O_WRONLY)). >=20 Failing with EBADF feels fishy (POSIX requests EINVAL in that case) - but that's an upstream glibc discussion that has forked from this thread and doesn't hold up the qemu fix. > I contacted glibc upstream about this, and their response is here: >=20 > https://bugzilla.redhat.com/show_bug.cgi?id=3D1265196#c9 >=20 > There are two possible fixes: Use Linux fallocate directly, or (this > fix) work around the problem in qemu by opening the file with O_RDWR > instead of O_WRONLY. >=20 > Signed-off-by: Richard W.M. Jones > BZ: https://bugzilla.redhat.com/show_bug.cgi?id=3D1265196 > --- > block/raw-posix.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --7DkE7JIlGMtCAE04WjONU9SfjEHfQC6iR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWDKo6AAoJEKeha0olJ0NqwGAIAJNLtFwfUtExrrypGG7Enrvj NFf6nhepIHzI3jZFamgYxo8thCXk3b71zUlX00LJWkHwpPgbpWX5AySiht/lXbOc a+ayN3/NPH7pvfNBOZ+BRMkXMx1yuE2ZjrN0v6sE2oyU4KmMCLjvyU4Yo7aYXWPu YdYvZaI9vvIGrMezcxMeFQbJYpV3QI4Xd/L0BJCPevV2ZPfrMY5h/nZwpl5reSB7 wsv7/xumgl8fX8gDq6TPdXQFSjw4BpqoxVXTUCqWngk2y7cBLWlcIp9+0CW/4kP6 lgpa1Y7OzL2En69abYxr2EuAMasWfr0S+Rk3gauuFFLhtmptAxf/uo70SNjW/WE= =kfZb -----END PGP SIGNATURE----- --7DkE7JIlGMtCAE04WjONU9SfjEHfQC6iR--