From: Kevin Wolf <kwolf@redhat.com>
To: antoine.damhet@blade-group.com
Cc: qemu-devel@nongnu.org, "open list:raw" <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH RESEND] file-posix: Handle `EINVAL` fallocate return value
Date: Mon, 20 Jul 2020 16:07:26 +0200 [thread overview]
Message-ID: <20200720140726.GD5541@linux.fritz.box> (raw)
In-Reply-To: <20200717135603.51180-1-antoine.damhet@blade-group.com>
Am 17.07.2020 um 15:56 hat antoine.damhet@blade-group.com geschrieben:
> From: Antoine Damhet <antoine.damhet@blade-group.com>
>
> 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`.
>
> Signed-off-by: Antoine Damhet <antoine.damhet@blade-group.com>
Do you have a simple reproducer for this? I tried it with something like
this (also with a LV instead of loop, but it didn't really make a
difference):
$ ./qemu-io -c 'write -P 0 42 1234' --image-opts driver=host_device,filename=/dev/loop0,cache.direct=on,detect-zeroes=on
wrote 1234/1234 bytes at offset 42
1.205 KiB, 1 ops; 00.00 sec (2.021 MiB/sec and 1717.5697 ops/sec)
So I don't seem to run into an error.
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 8067e238cb..b2fabcc1b8 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1620,7 +1620,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
This means that we fall back to BLKZEROOUT in case of -EINVAL. Does this
return a better error code in the relevant cases, or did you just happen
to test a case where it was skipped or returned -ENOTSUP?
Kevin
next prev parent reply other threads:[~2020-07-20 14:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 13:56 [PATCH RESEND] file-posix: Handle `EINVAL` fallocate return value antoine.damhet
2020-07-20 14:07 ` Kevin Wolf [this message]
2020-07-20 15:37 ` Antoine Damhet
2020-07-21 14:21 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200720140726.GD5541@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=antoine.damhet@blade-group.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).