[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen master] file-posix: Handle `EINVAL` fallocate return value



commit bae127d4dcf6158c5042e2eee9582430839a9967
Author:     Antoine Damhet <antoine.damhet@xxxxxxxxxxxxxxx>
AuthorDate: Fri Jul 17 15:56:04 2020 +0200
Commit:     Kevin Wolf <kwolf@xxxxxxxxxx>
CommitDate: Tue Jul 21 16:28:57 2020 +0200

    file-posix: Handle `EINVAL` fallocate return value
    
    The `detect-zeroes=unmap` option may issue unaligned
    `FALLOC_FL_PUNCH_HOLE` requests, raw block devices can (and will) return
    `EINVAL`, qemu should then write the zeroes to the blockdev instead of
    issuing an `IO_ERROR`.
    
    The problem can be reprodced like this:
    
    $ qemu-io -c 'write -P 0 42 1234' --image-opts 
driver=host_device,filename=/dev/loop0,detect-zeroes=unmap
    write failed: Invalid argument
    
    Signed-off-by: Antoine Damhet <antoine.damhet@xxxxxxxxxxxxxxx>
    Message-Id: <20200717135603.51180-1-antoine.damhet@xxxxxxxxxxxxxxx>
    Signed-off-by: Kevin Wolf <kwolf@xxxxxxxxxx>
---
 block/file-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 8cc39a1ef6..9a00d4190a 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1698,7 +1698,11 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
     int ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                            aiocb->aio_offset, aiocb->aio_nbytes);
-    if (ret != -ENOTSUP) {
+    switch (ret) {
+    case -ENOTSUP:
+    case -EINVAL:
+        break;
+    default:
         return ret;
     }
 #endif
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.