|
|
9ae3a8 |
From 9452583824b50cb6f095c5ec1894b38df7b01175 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <9452583824b50cb6f095c5ec1894b38df7b01175.1464449390.git.jen@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <c7936395ecf322b3de37662c7c6b772e36866cc7.1464449390.git.jen@redhat.com>
|
|
|
9ae3a8 |
References: <c7936395ecf322b3de37662c7c6b772e36866cc7.1464449390.git.jen@redhat.com>
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 May 2016 11:28:41 -0400
|
|
|
9ae3a8 |
Subject: [CHANGE 3/3] block/raw-posix: Open file descriptor O_RDWR to work
|
|
|
9ae3a8 |
around glibc posix_fallocate emulation issue.
|
|
|
9ae3a8 |
To: rhvirt-patches@redhat.com,
|
|
|
9ae3a8 |
jen@redhat.com
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1464002921-1079-2-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 70425
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH 1/1] block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue.
|
|
|
9ae3a8 |
Bugzilla: 1268345
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Richard Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The following command fails on an NFS mountpoint:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
$ qemu-img create -f qcow2 -o preallocation=falloc disk.img 262144
|
|
|
9ae3a8 |
Formatting 'disk.img', fmt=qcow2 size=262144 encryption=off cluster_size=65536 preallocation='falloc' lazy_refcounts=off
|
|
|
9ae3a8 |
qemu-img: disk.img: Could not preallocate data for the new file: Bad file descriptor
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The reason turns out to be because NFS doesn't support the
|
|
|
9ae3a8 |
posix_fallocate call. glibc emulates it instead. However glibc's
|
|
|
9ae3a8 |
emulation involves using the pread(2) syscall. The pread syscall
|
|
|
9ae3a8 |
fails with EBADF if the file descriptor is opened without the read
|
|
|
9ae3a8 |
open-flag (ie. open (..., O_WRONLY)).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
I contacted glibc upstream about this, and their response is here:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1265196#c9
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
There are two possible fixes: Use Linux fallocate directly, or (this
|
|
|
9ae3a8 |
fix) work around the problem in qemu by opening the file with O_RDWR
|
|
|
9ae3a8 |
instead of O_WRONLY.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 73ba05d936e82fe01b2b2cf987bf3aecb4792af5)
|
|
|
9ae3a8 |
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/raw-posix.c | 2 +-
|
|
|
9ae3a8 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/raw-posix.c b/block/raw-posix.c
|
|
|
9ae3a8 |
index 1f5275f..92fcb6c 100644
|
|
|
9ae3a8 |
--- a/block/raw-posix.c
|
|
|
9ae3a8 |
+++ b/block/raw-posix.c
|
|
|
9ae3a8 |
@@ -1265,7 +1265,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
options++;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
|
|
9ae3a8 |
+ fd = qemu_open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
|
|
|
9ae3a8 |
0644);
|
|
|
9ae3a8 |
if (fd < 0) {
|
|
|
9ae3a8 |
result = -errno;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
2.5.5
|
|
|
9ae3a8 |
|