From: Hanna Czenczek <hreitz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu-block@nongnu.org
Subject: Re: [PATCH v2 2/2] block/io: skip head/tail requests on EINVAL
Date: Fri, 11 Apr 2025 10:18:55 +0200 [thread overview]
Message-ID: <c2daf7e2-359b-4e4b-826f-511fa9c0e3fb@redhat.com> (raw)
In-Reply-To: <20250410184103.23385-3-stefanha@redhat.com>
On 10.04.25 20:41, Stefan Hajnoczi wrote:
> When guests send misaligned discard requests, the block layer breaks
> them up into a misaligned head, an aligned main body, and a misaligned
> tail.
>
> The file-posix block driver on Linux returns -EINVAL on misaligned
> discard requests. This causes bdrv_co_pdiscard() to fail and guests
> configured with werror=stop will pause.
>
> Add a special case for misaligned head/tail requests. Simply continue
> when EINVAL is encountered so that the aligned main body of the request
> can be completed and the guest is not paused. This is the best we can do
> when guest discard limits do not match the host discard limits.
>
> Fixes: https://issues.redhat.com/browse/RHEL-86032
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> block/io.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/block/io.c b/block/io.c
> index 1ba8d1aeea..a0d0b31a3e 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -3180,7 +3180,11 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
> }
> }
> if (ret && ret != -ENOTSUP) {
> - goto out;
> + if (ret == -EINVAL && (offset % align != 0 || num % align != 0)) {
Could use `(offset | num) % align != 0`, but either way:
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
> + /* Silently skip rejected unaligned head/tail requests */
> + } else {
> + goto out; /* bail out */
> + }
> }
>
> offset += num;
next prev parent reply other threads:[~2025-04-11 8:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 18:41 [PATCH v2 0/2] block: discard alignment fixes Stefan Hajnoczi
2025-04-10 18:41 ` [PATCH v2 1/2] file-posix: probe discard alignment on Linux block devices Stefan Hajnoczi
2025-04-11 8:15 ` Hanna Czenczek
2025-04-14 15:34 ` Stefan Hajnoczi
2025-04-16 10:43 ` Kevin Wolf
2025-04-10 18:41 ` [PATCH v2 2/2] block/io: skip head/tail requests on EINVAL Stefan Hajnoczi
2025-04-11 8:18 ` Hanna Czenczek [this message]
2025-04-11 17:28 ` Eric Blake
2025-04-14 13:39 ` Hanna Czenczek
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=c2daf7e2-359b-4e4b-826f-511fa9c0e3fb@redhat.com \
--to=hreitz@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).