[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 17/25] raw-posix: fix O_DIRECT short reads
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 17/25] raw-posix: fix O_DIRECT short reads |
Date: |
Wed, 27 Aug 2014 12:36:14 -0500 |
From: Stefan Hajnoczi <address@hidden>
The following O_DIRECT read from a <512 byte file fails:
$ truncate -s 320 test.img
$ qemu-io -n -c 'read -P 0 0 512' test.img
qemu-io: can't open device test.img: Could not read image for determining its
format: Invalid argument
Note that qemu-io completes successfully without the -n (O_DIRECT)
option.
This patch fixes qemu-iotests ./check -nocache -vmdk 059.
Cc: address@hidden
Suggested-by: Kevin Wolf <address@hidden>
Reported-by: Markus Armbruster <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
(cherry picked from commit 61ed73cff427206b3a959b18a4877952f566279b)
Signed-off-by: Michael Roth <address@hidden>
---
block/raw-posix.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 8e9758e..87fc170 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -747,6 +747,15 @@ static ssize_t handle_aiocb_rw_linear(RawPosixAIOData
*aiocb, char *buf)
}
if (len == -1 && errno == EINTR) {
continue;
+ } else if (len == -1 && errno == EINVAL &&
+ (aiocb->bs->open_flags & BDRV_O_NOCACHE) &&
+ !(aiocb->aio_type & QEMU_AIO_WRITE) &&
+ offset > 0) {
+ /* O_DIRECT pread() may fail with EINVAL when offset is unaligned
+ * after a short read. Assume that O_DIRECT short reads only occur
+ * at EOF. Therefore this is a short read, not an I/O error.
+ */
+ break;
} else if (len == -1) {
offset = -errno;
break;
--
1.9.1
- [Qemu-stable] [PATCH 10/25] numa: show hex number in error message for consistency and prefix them with 0x, (continued)
- [Qemu-stable] [PATCH 10/25] numa: show hex number in error message for consistency and prefix them with 0x, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 04/25] l2tpv3 (configure): it is linux-specific, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 05/25] ide: only constrain read/write requests to drive size, not other types, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 09/25] pc-dimm: fix up error message, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 08/25] pc-dimm: validate node property, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 13/25] target-arm: Fix return address for A64 BRK instructions, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 11/25] acpi: align RSDP, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 12/25] virtio-blk: fix reference a pointer which might be freed, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 01/25] qmp: hide "hotplugged" device property from device-list-properties, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 15/25] arm/virt: Use PSCI v0.2 function IDs in the DT when KVM uses PSCI v0.2, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 17/25] raw-posix: fix O_DIRECT short reads,
Michael Roth <=
- [Qemu-stable] [PATCH 16/25] block/iscsi: fix memory corruption on iscsi resize, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 19/25] blkdebug: Delete BH in bdrv_aio_cancel, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 18/25] qemu-iotests: add test case 101 for short file I/O, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 21/25] hostmem: set MPOL_MF_MOVE, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 20/25] vmxnet3: Pad short frames to minimum size (60 bytes), Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 23/25] pc: reserve more memory for ACPI for new machine types, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 25/25] thread-pool: avoid deadlock in nested aio_poll() calls, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 24/25] thread-pool: avoid per-thread-pool EventNotifier, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 14/25] target-arm: Rename QEMU PSCI v0.1 definitions, Michael Roth, 2014/08/27
- [Qemu-stable] [PATCH 22/25] pcihp: fix possible array out of bounds, Michael Roth, 2014/08/27