Skip to content

Commit bae127d

Browse files
xdbobkevmw
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent 90218a9 commit bae127d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

block/file-posix.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,11 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
16981698
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
16991699
int ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
17001700
aiocb->aio_offset, aiocb->aio_nbytes);
1701-
if (ret != -ENOTSUP) {
1701+
switch (ret) {
1702+
case -ENOTSUP:
1703+
case -EINVAL:
1704+
break;
1705+
default:
17021706
return ret;
17031707
}
17041708
#endif

0 commit comments

Comments
 (0)