From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
"fam@euphon.net" <fam@euphon.net>,
Denis Lunev <den@virtuozzo.com>,
"mreitz@redhat.com" <mreitz@redhat.com>,
"stefanha@redhat.com" <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: workaround for unaligned byte range in fallocate()
Date: Thu, 22 Aug 2019 19:10:33 +0000 [thread overview]
Message-ID: <bfba1920-0cca-85f5-83f1-d68bb4ba37e1@virtuozzo.com> (raw)
In-Reply-To: <0b9bfdf5-911f-595e-b941-28ab1e6c4d5f@virtuozzo.com>
22.08.2019 21:55, Vladimir Sementsov-Ogievskiy wrote:
> 22.08.2019 21:31, Andrey Shinkevich wrote:
>> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
>> and make better error handling for the file systems that do not support
>> fallocate() for the unaligned byte range. Allow falling back to pwrite
>> in case fallocate() returns EINVAL.
>>
>> Suggested-by: Kevin Wolf <kwolf@redhat.com>
>> Suggested-by: Eric Blake <eblake@redhat.com>
>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>> ---
>> Discussed in email thread with the message ID
>> <1554474244-553661-1-git-send-email-andrey.shinkevich@virtuozzo.com>
>>
>> block/file-posix.c | 7 +++++++
>> block/io.c | 2 +-
>> 2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/file-posix.c b/block/file-posix.c
>> index fbeb006..2c254ff 100644
>> --- a/block/file-posix.c
>> +++ b/block/file-posix.c
>> @@ -1588,6 +1588,13 @@ static int j(void *opaque)
>> if (s->has_write_zeroes) {
>> int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE,
>> aiocb->aio_offset, aiocb->aio_nbytes);
>> + if (ret == -EINVAL) {
>> + /*
>> + * Allow falling back to pwrite for file systems that
>> + * do not support fallocate() for unaligned byte range.
>> + */
>> + return -ENOTSUP;
>> + }
>> if (ret == 0 || ret != -ENOTSUP) {
>> return ret;
>> }
>
> Hmm stop, you've done exactly what Den was afraid of:
>
> the next line
> s->has_write_zeroes = false;
>
> will disable write_zeroes forever.
>
> Something like
>
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1588,10 +1588,12 @@ static int handle_aiocb_write_zeroes(void *opaque)
> if (s->has_write_zeroes) {
> int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE,
> aiocb->aio_offset, aiocb->aio_nbytes);
> - if (ret == 0 || ret != -ENOTSUP) {
> + if (ret == 0 || (ret != -ENOTSUP && ret != -EINVAL)) {
> return ret;
> }
> - s->has_write_zeroes = false;
> + if (ret == -ENOTSUP) {
> + s->has_write_zeroes = false;
> + }
> }
> #endif
>
>
> will work better. So, handle ENOTSUP as "disable write_zeros forever", and EINVAL as
> "don't disable, but fallback to writing zeros". And we need same handling for following do_fallocate() calls
> too (otherwise they again fails with EINVAL which will break the whole thing).
>
Oops, sorry, I misread your patch, it's OK.
Still we may want to handle other do_fallocate() calls in same manner, or may be just:
@@ -1558,7 +1558,13 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
assert(!bs->supported_zero_flags);
}
- if (ret < 0 && !(flags & BDRV_REQ_NO_FALLBACK)) {
+ /*
+ * We are sure that our arguments make sense, so consider "invalid
+ * argument" in same manner as "not supported".
+ */
+ if ((ret == -ENOTSUP || ret == -EINVAL) &&
+ !(flags & BDRV_REQ_NO_FALLBACK))
+ {
/* Fall back to bounce buffer if write zeroes is unsupported */
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
--
Best regards,
Vladimir
next prev parent reply other threads:[~2019-08-22 19:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 18:31 [Qemu-devel] [PATCH] block: workaround for unaligned byte range in fallocate() Andrey Shinkevich
2019-08-22 18:55 ` Vladimir Sementsov-Ogievskiy
2019-08-22 19:10 ` Vladimir Sementsov-Ogievskiy [this message]
2019-08-22 21:09 ` Eric Blake
2019-08-23 12:07 ` Andrey Shinkevich
2019-08-27 12:35 ` Denis V. Lunev
2019-08-27 12:39 ` Andrey Shinkevich
2019-08-27 13:50 ` Eric Blake
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=bfba1920-0cca-85f5-83f1-d68bb4ba37e1@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=andrey.shinkevich@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@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).