[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads |
Date: |
Fri, 22 Aug 2014 16:51:48 +0200 |
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>
---
block/raw-posix.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5c745b9..d737f3a 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.8.3.1
- [Qemu-devel] [PULL 14/29] virtio-blk: allow block_resize with dataplane, (continued)
- [Qemu-devel] [PULL 14/29] virtio-blk: allow block_resize with dataplane, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 15/29] virtio-blk: fix reference a pointer which might be freed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 17/29] blkdebug: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 18/29] blkverify: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 21/29] iotests: Add test for image filename construction, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 22/29] block/vvfat.c: remove debugging code to reinit stderr if NULL, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 20/29] quorum: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads,
Kevin Wolf <=
- [Qemu-devel] [PULL 23/29] block/iscsi: fix memory corruption on iscsi resize, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 25/29] qemu-iotests: add test case 101 for short file I/O, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 26/29] blkdebug: Delete BH in bdrv_aio_cancel, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 27/29] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 28/29] qemu-img: Allow source cache mode specification, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 29/29] qemu-img: Allow cache mode specification for amend, Kevin Wolf, 2014/08/22
- Re: [Qemu-devel] [PULL 00/29] Block patches, Daniel H Barboza, 2014/08/22
- Re: [Qemu-devel] [PULL 00/29] Block patches, Peter Maydell, 2014/08/22