|
|
1072c8 |
From 94d99b13b48e922861570f043490efc966b3b445 Mon Sep 17 00:00:00 2001
|
|
|
1072c8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Date: Fri, 25 Jun 2021 17:41:04 -0400
|
|
|
1072c8 |
Subject: [PATCH 4/4] file-posix: Handle `EINVAL` fallocate return value
|
|
|
1072c8 |
MIME-Version: 1.0
|
|
|
1072c8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
1072c8 |
Content-Transfer-Encoding: 8bit
|
|
|
1072c8 |
|
|
|
1072c8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Message-id: <20210625174104.44313-3-kwolf@redhat.com>
|
|
|
1072c8 |
Patchwork-id: 101778
|
|
|
1072c8 |
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 2/2] file-posix: Handle `EINVAL` fallocate return value
|
|
|
1072c8 |
Bugzilla: 1970912
|
|
|
1072c8 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
1072c8 |
|
|
|
1072c8 |
From: Antoine Damhet <antoine.damhet@blade-group.com>
|
|
|
1072c8 |
|
|
|
1072c8 |
The `detect-zeroes=unmap` option may issue unaligned
|
|
|
1072c8 |
`FALLOC_FL_PUNCH_HOLE` requests, raw block devices can (and will) return
|
|
|
1072c8 |
`EINVAL`, qemu should then write the zeroes to the blockdev instead of
|
|
|
1072c8 |
issuing an `IO_ERROR`.
|
|
|
1072c8 |
|
|
|
1072c8 |
The problem can be reprodced like this:
|
|
|
1072c8 |
|
|
|
1072c8 |
$ qemu-io -c 'write -P 0 42 1234' --image-opts driver=host_device,filename=/dev/loop0,detect-zeroes=unmap
|
|
|
1072c8 |
write failed: Invalid argument
|
|
|
1072c8 |
|
|
|
1072c8 |
Signed-off-by: Antoine Damhet <antoine.damhet@blade-group.com>
|
|
|
1072c8 |
Message-Id: <20200717135603.51180-1-antoine.damhet@blade-group.com>
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
(cherry picked from commit bae127d4dcf6158c5042e2eee9582430839a9967)
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
1072c8 |
---
|
|
|
1072c8 |
block/file-posix.c | 6 +++++-
|
|
|
1072c8 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
1072c8 |
|
|
|
1072c8 |
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
|
1072c8 |
index 837edcf027..6cd19e6c9a 100644
|
|
|
1072c8 |
--- a/block/file-posix.c
|
|
|
1072c8 |
+++ b/block/file-posix.c
|
|
|
1072c8 |
@@ -1632,7 +1632,11 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
|
|
|
1072c8 |
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
|
|
|
1072c8 |
int ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
|
|
|
1072c8 |
aiocb->aio_offset, aiocb->aio_nbytes);
|
|
|
1072c8 |
- if (ret != -ENOTSUP) {
|
|
|
1072c8 |
+ switch (ret) {
|
|
|
1072c8 |
+ case -ENOTSUP:
|
|
|
1072c8 |
+ case -EINVAL:
|
|
|
1072c8 |
+ break;
|
|
|
1072c8 |
+ default:
|
|
|
1072c8 |
return ret;
|
|
|
1072c8 |
}
|
|
|
1072c8 |
#endif
|
|
|
1072c8 |
--
|
|
|
1072c8 |
2.27.0
|
|
|
1072c8 |
|