qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
@ 2019-08-27 13:52 Andrey Shinkevich
  2019-08-27 13:55 ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Shinkevich @ 2019-08-27 13:52 UTC (permalink / raw)
  To: qemu-devel, qemu-block
  Cc: kwolf, fam, vsementsov, mreitz, stefanha, andrey.shinkevich, den

Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
and use better error handling for file systems that do not support
fallocate() for an 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>
Reviewed-by: Eric Blake <eblake@redhat.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..b00259f 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1588,6 +1588,13 @@ 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 == -EINVAL) {
+            /*
+             * Allow falling back to pwrite for file systems that
+             * do not support fallocate() for an unaligned byte range.
+             */
+            return -ENOTSUP;
+        }
         if (ret == 0 || ret != -ENOTSUP) {
             return ret;
         }
diff --git a/block/io.c b/block/io.c
index 56bbf19..58f08cd 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1558,7 +1558,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
             assert(!bs->supported_zero_flags);
         }
 
-        if (ret < 0 && !(flags & BDRV_REQ_NO_FALLBACK)) {
+        if (ret == -ENOTSUP && !(flags & BDRV_REQ_NO_FALLBACK)) {
             /* Fall back to bounce buffer if write zeroes is unsupported */
             BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
  2019-08-27 13:52 [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate() Andrey Shinkevich
@ 2019-08-27 13:55 ` Eric Blake
  2019-08-27 14:04   ` Andrey Shinkevich
  2019-08-27 14:08   ` Andrey Shinkevich
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Blake @ 2019-08-27 13:55 UTC (permalink / raw)
  To: Andrey Shinkevich, qemu-devel, qemu-block
  Cc: kwolf, fam, vsementsov, mreitz, stefanha, den


[-- Attachment #1.1: Type: text/plain, Size: 878 bytes --]

On 8/27/19 8:52 AM, Andrey Shinkevich wrote:
> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
> and use better error handling for file systems that do not support
> fallocate() for an 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>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  block/file-posix.c | 7 +++++++
>  block/io.c         | 2 +-
>  2 files changed, 8 insertions(+), 1 deletion(-)

Queuing this in my NBD tree (as I performed testing on top of it when
working on NBD fast-zero).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
  2019-08-27 13:55 ` Eric Blake
@ 2019-08-27 14:04   ` Andrey Shinkevich
  2019-08-27 14:30     ` Eric Blake
  2019-08-27 14:08   ` Andrey Shinkevich
  1 sibling, 1 reply; 6+ messages in thread
From: Andrey Shinkevich @ 2019-08-27 14:04 UTC (permalink / raw)
  To: Eric Blake, qemu-devel, qemu-block
  Cc: kwolf, fam, Vladimir Sementsov-Ogievskiy, Denis Lunev, mreitz, stefanha



On 27/08/2019 16:55, Eric Blake wrote:
> On 8/27/19 8:52 AM, Andrey Shinkevich wrote:
>> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
>> and use better error handling for file systems that do not support
>> fallocate() for an 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>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>   block/file-posix.c | 7 +++++++
>>   block/io.c         | 2 +-
>>   2 files changed, 8 insertions(+), 1 deletion(-)
> 
> Queuing this in my NBD tree (as I performed testing on top of it when
> working on NBD fast-zero).
> 
Eric,
I'm sorry about missing your message in the previous email thread - just 
few minute difference. Please add
Reviewed-by: Denis V. Lunev <den@openvz.org>
because I used the stale commit ID from bash history and that line 
didn't go to the v2 patch (((

Thank you.
Andrey
-- 
With the best regards,
Andrey Shinkevich

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
  2019-08-27 13:55 ` Eric Blake
  2019-08-27 14:04   ` Andrey Shinkevich
@ 2019-08-27 14:08   ` Andrey Shinkevich
  1 sibling, 0 replies; 6+ messages in thread
From: Andrey Shinkevich @ 2019-08-27 14:08 UTC (permalink / raw)
  To: Eric Blake, qemu-devel, qemu-block
  Cc: kwolf, fam, Vladimir Sementsov-Ogievskiy, Denis Lunev, mreitz, stefanha



On 27/08/2019 16:55, Eric Blake wrote:
> On 8/27/19 8:52 AM, Andrey Shinkevich wrote:
>> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
>> and use better error handling for file systems that do not support
>> fallocate() for an 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>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>   block/file-posix.c | 7 +++++++
>>   block/io.c         | 2 +-
>>   2 files changed, 8 insertions(+), 1 deletion(-)
> 
> Queuing this in my NBD tree (as I performed testing on top of it when
> working on NBD fast-zero).
> 

Also, maybe the thread message ID would be good to mention as well:
<1554474244-553661-1-git-send-email-andrey.shinkevich@virtuozzo.com>

Andrey
-- 
With the best regards,
Andrey Shinkevich

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
  2019-08-27 14:04   ` Andrey Shinkevich
@ 2019-08-27 14:30     ` Eric Blake
  2019-08-27 14:36       ` Andrey Shinkevich
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2019-08-27 14:30 UTC (permalink / raw)
  To: Andrey Shinkevich, qemu-devel, qemu-block
  Cc: kwolf, fam, Vladimir Sementsov-Ogievskiy, Denis Lunev, mreitz, stefanha


[-- Attachment #1.1: Type: text/plain, Size: 1359 bytes --]

On 8/27/19 9:04 AM, Andrey Shinkevich wrote:
> 
> 
> On 27/08/2019 16:55, Eric Blake wrote:
>> On 8/27/19 8:52 AM, Andrey Shinkevich wrote:
>>> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
>>> and use better error handling for file systems that do not support
>>> fallocate() for an 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>
>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>> ---
>>>   block/file-posix.c | 7 +++++++
>>>   block/io.c         | 2 +-
>>>   2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> Queuing this in my NBD tree (as I performed testing on top of it when
>> working on NBD fast-zero).
>>
> Eric,
> I'm sorry about missing your message in the previous email thread - just 
> few minute difference. Please add
> Reviewed-by: Denis V. Lunev <den@openvz.org>
> because I used the stale commit ID from bash history and that line 
> didn't go to the v2 patch (((

No problem - crossed emails is nothing new. I'll add the R-b.


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate()
  2019-08-27 14:30     ` Eric Blake
@ 2019-08-27 14:36       ` Andrey Shinkevich
  0 siblings, 0 replies; 6+ messages in thread
From: Andrey Shinkevich @ 2019-08-27 14:36 UTC (permalink / raw)
  To: Eric Blake, qemu-devel, qemu-block
  Cc: kwolf, fam, Vladimir Sementsov-Ogievskiy, Denis Lunev, mreitz, stefanha



On 27/08/2019 17:30, Eric Blake wrote:
> On 8/27/19 9:04 AM, Andrey Shinkevich wrote:
>>
>>
>> On 27/08/2019 16:55, Eric Blake wrote:
>>> On 8/27/19 8:52 AM, Andrey Shinkevich wrote:
>>>> Revert the commit 118f99442d 'block/io.c: fix for the allocation failure'
>>>> and use better error handling for file systems that do not support
>>>> fallocate() for an 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>
>>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>>> ---
>>>>    block/file-posix.c | 7 +++++++
>>>>    block/io.c         | 2 +-
>>>>    2 files changed, 8 insertions(+), 1 deletion(-)
>>>
>>> Queuing this in my NBD tree (as I performed testing on top of it when
>>> working on NBD fast-zero).
>>>
>> Eric,
>> I'm sorry about missing your message in the previous email thread - just
>> few minute difference. Please add
>> Reviewed-by: Denis V. Lunev <den@openvz.org>
>> because I used the stale commit ID from bash history and that line
>> didn't go to the v2 patch (((
> 
> No problem - crossed emails is nothing new. I'll add the R-b.
> 
> 
Thanks a lot Eric.

Andrey
-- 
With the best regards,
Andrey Shinkevich

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-27 14:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 13:52 [Qemu-devel] [PATCH v2] block: workaround for unaligned byte range in fallocate() Andrey Shinkevich
2019-08-27 13:55 ` Eric Blake
2019-08-27 14:04   ` Andrey Shinkevich
2019-08-27 14:30     ` Eric Blake
2019-08-27 14:36       ` Andrey Shinkevich
2019-08-27 14:08   ` Andrey Shinkevich

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).