From: Eric Blake <eblake@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>, kwolf@redhat.com
Cc: codonell@redhat.com, dgilbert@redhat.com, qemu-block@nongnu.org,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue.
Date: Wed, 30 Sep 2015 21:36:26 -0600 [thread overview]
Message-ID: <560CAA3A.3090502@redhat.com> (raw)
In-Reply-To: <1443542050-26720-1-git-send-email-rjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
On 09/29/2015 09:54 AM, Richard W.M. Jones wrote:
> 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)).
>
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:
>
> 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 <rjones@redhat.com>
> BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1265196
> ---
> block/raw-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-10-01 3:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 15:54 [Qemu-devel] [PATCH] block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue Richard W.M. Jones
2015-09-30 11:42 ` Kevin Wolf
2015-09-30 20:44 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2015-10-01 3:36 ` Eric Blake [this message]
2015-10-02 14:36 ` [Qemu-devel] " Peter Maydell
2015-10-02 14:43 ` Richard W.M. Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=560CAA3A.3090502@redhat.com \
--to=eblake@redhat.com \
--cc=codonell@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).