Received: from eggs.gnu.org ([2001:4830:134:3::10]:58862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhFmn-0002H5-7k for qemu-devel@nongnu.org; Wed, 30 Sep 2015 07:43:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhFmm-0005De-4a for qemu-devel@nongnu.org; Wed, 30 Sep 2015 07:43:01 -0400 Date: Wed, 30 Sep 2015 13:42:52 +0200 From: Kevin Wolf Message-ID: <20150930114252.GB3989@noname.str.redhat.com> References: <1443542050-26720-1-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443542050-26720-1-git-send-email-rjones@redhat.com> 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" Cc: codonell@redhat.com, dgilbert@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Am 29.09.2015 um 17:54 hat Richard W.M. Jones geschrieben: > https://bugzilla.redhat.com/show_bug.cgi?id=1265196 > > The following command fails on an NFS mountpoint: > > $ qemu-img create -f qcow2 -o preallocation=falloc disk.img 262144 > Formatting 'disk.img', fmt=qcow2 size=262144 encryption=off cluster_size=65536 preallocation='falloc' lazy_refcounts=off > qemu-img: disk.img: Could not preallocate data for the new file: Bad file descriptor > > 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)). > > I contacted glibc upstream about this, and their response is here: > > https://bugzilla.redhat.com/show_bug.cgi?id=1265196#c9 > > 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. > > Signed-off-by: Richard W.M. Jones > BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1265196 Thanks, applied to the block branch. Kevin