All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] file-posix: allow -EBUSY errors during write zeros on block
@ 2021-03-02  1:56 ChangLimin
  2021-03-02 14:10 ` Kevin Wolf
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: ChangLimin @ 2021-03-02  1:56 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz

After Linux 5.10, write zeros to a multipath device using
ioctl(fd, BLKZEROOUT, range) with cache none or directsync will return EBUSY.

Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block
allow -EBUSY errors during ioctl(fd, BLKZEROOUT, range).

Reference commit in Linux 5.10:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02

Signed-off-by: ChangLimin <changlm@chinatelecom.cn>
---
 block/file-posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 05079b40ca..3e60c96214 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
         } while (errno == EINTR);

         ret = translate_err(-errno);
-        if (ret == -ENOTSUP) {
+        switch (ret) {
+        case -ENOTSUP:
+        case -EINVAL:
+        case -EBUSY:
             s->has_write_zeroes = false;
+            return -ENOTSUP;
+            break;
         }
     }
 #endif
--
2.27.0


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

* Re: [PATCH] file-posix: allow -EBUSY errors during write zeros on block
  2021-03-02  1:56 [PATCH] file-posix: allow -EBUSY errors during write zeros on block ChangLimin
@ 2021-03-02 14:10 ` Kevin Wolf
  2021-03-02 16:40 ` Nir Soffer
  2021-03-03  3:24 ` [PATCH V2] file-posix: allow -EBUSY -EINVAL " ChangLimin
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2021-03-02 14:10 UTC (permalink / raw)
  To: ChangLimin; +Cc: qemu-devel, qemu-block, mreitz

Am 02.03.2021 um 02:56 hat ChangLimin geschrieben:
> After Linux 5.10, write zeros to a multipath device using
> ioctl(fd, BLKZEROOUT, range) with cache none or directsync will return EBUSY.
> 
> Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block
> allow -EBUSY errors during ioctl(fd, BLKZEROOUT, range).
> 
> Reference commit in Linux 5.10:
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02
> 
> Signed-off-by: ChangLimin <changlm@chinatelecom.cn>
> ---
>  block/file-posix.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 05079b40ca..3e60c96214 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
>          } while (errno == EINTR);
> 
>          ret = translate_err(-errno);
> -        if (ret == -ENOTSUP) {
> +        switch (ret) {
> +        case -ENOTSUP:
> +        case -EINVAL:
> +        case -EBUSY:
>              s->has_write_zeroes = false;

Do we actually want -EINVAL and -EBUSY to completely stop us from trying
again in future requests? -ENOTSUP will never change in future calls,
but can't -EINVAL and -EBUSY?

By the way, the commit message only explains -EBUSY. Why do we want to
cover -EINVAL here, too?

> +            return -ENOTSUP;

I suppose this is the important change: We convert the error codes to
-ENOTSUP now so that block.c will emulate the operation instead of
failing.  This should be explained in the commit message.

> +            break;
>          }
>      }
>  #endif

Kevin



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

* Re: [PATCH] file-posix: allow -EBUSY errors during write zeros on block
  2021-03-02  1:56 [PATCH] file-posix: allow -EBUSY errors during write zeros on block ChangLimin
  2021-03-02 14:10 ` Kevin Wolf
@ 2021-03-02 16:40 ` Nir Soffer
  2021-03-04  0:14   ` ChangLimin
  2021-03-03  3:24 ` [PATCH V2] file-posix: allow -EBUSY -EINVAL " ChangLimin
  2 siblings, 1 reply; 5+ messages in thread
From: Nir Soffer @ 2021-03-02 16:40 UTC (permalink / raw)
  To: ChangLimin; +Cc: kwolf, qemu-devel, qemu-block, mreitz

On Tue, Mar 2, 2021 at 4:08 AM ChangLimin <changlm@chinatelecom.cn> wrote:
>
> After Linux 5.10, write zeros to a multipath device using
> ioctl(fd, BLKZEROOUT, range) with cache none or directsync will return EBUSY.
>
> Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block
> allow -EBUSY errors during ioctl(fd, BLKZEROOUT, range).
>
> Reference commit in Linux 5.10:
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02

But this can happen only when the block device is used by a file system or
maybe someone else. In qemu we assume that we are the only user of the
block device, so EBUSY is a fatal error that should never happen, no?

Can you explain a real world use case when we get EBUSY?

Nir

> Signed-off-by: ChangLimin <changlm@chinatelecom.cn>
> ---
>  block/file-posix.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 05079b40ca..3e60c96214 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
>          } while (errno == EINTR);
>
>          ret = translate_err(-errno);
> -        if (ret == -ENOTSUP) {
> +        switch (ret) {
> +        case -ENOTSUP:
> +        case -EINVAL:
> +        case -EBUSY:
>              s->has_write_zeroes = false;
> +            return -ENOTSUP;
> +            break;
>          }
>      }
>  #endif
> --
> 2.27.0
>



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

* [PATCH V2] file-posix: allow -EBUSY -EINVAL errors during write zeros on block
  2021-03-02  1:56 [PATCH] file-posix: allow -EBUSY errors during write zeros on block ChangLimin
  2021-03-02 14:10 ` Kevin Wolf
  2021-03-02 16:40 ` Nir Soffer
@ 2021-03-03  3:24 ` ChangLimin
  2 siblings, 0 replies; 5+ messages in thread
From: ChangLimin @ 2021-03-03  3:24 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

Since Linux 5.10, write zeros to a multipath device using
ioctl(fd, BLKZEROOUT, range) with cache none or directsync return -EBUSY
permanently.

Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block
allow -EBUSY and -EINVAL errors during ioctl(fd, BLKZEROOUT, range).

Reference commit in Linux 5.10:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02

Signed-off-by: ChangLimin <changlm@chinatelecom.cn>
---
 block/file-posix.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 05079b40ca..4e132db929 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
         } while (errno == EINTR);

         ret = translate_err(-errno);
-        if (ret == -ENOTSUP) {
-            s->has_write_zeroes = false;
+        switch (ret) {
+        case -ENOTSUP:
+            s->has_write_zeroes = false; /* fall through */
+        case -EINVAL:
+        case -EBUSY:
+            return -ENOTSUP;
+            break;
         }
     }
 #endif
--
2.27.0


[-- Attachment #2: Type: text/html, Size: 2484 bytes --]

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

* Re: [PATCH] file-posix: allow -EBUSY errors during write zeros on block
  2021-03-02 16:40 ` Nir Soffer
@ 2021-03-04  0:14   ` ChangLimin
  0 siblings, 0 replies; 5+ messages in thread
From: ChangLimin @ 2021-03-04  0:14 UTC (permalink / raw)
  To: Nir Soffer; +Cc: kwolf, qemu-devel, qemu-block, mreitz

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

>> After Linux 5.10, write zeros to a multipath device using
>> ioctl(fd, BLKZEROOUT, range) with cache none or directsync will return EBUSY.
>>
>> Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block
>> allow -EBUSY errors during ioctl(fd, BLKZEROOUT, range).
>>
>> Reference commit in Linux 5.10:
>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02
> 
>But this can happen only when the block device is used by a file system or
>maybe someone else. In qemu we assume that we are the only user of the
>block device, so EBUSY is a fatal error that should never happen, no?
> 
>Can you explain a real world use case when we get EBUSY?
> 
>Nir
> 

Please refer to https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_device_mapper_multipath/index
Where multipath is configured to a SAN LUN, ioctl(fd, BLKZEROOUT, range)
to the /dev/dm-x return EBUSY permanently since Linux 5.10.

ChangLimin

>> Signed-off-by: ChangLimin <changlm@chinatelecom.cn>
>> ---
>>  block/file-posix.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/file-posix.c b/block/file-posix.c
>> index 05079b40ca..3e60c96214 100644
>> --- a/block/file-posix.c
>> +++ b/block/file-posix.c
>> @@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
>>          } while (errno == EINTR);
>>
>>          ret = translate_err(-errno);
>> -        if (ret == -ENOTSUP) {
>> +        switch (ret) {
>> +        case -ENOTSUP:
>> +        case -EINVAL:
>> +        case -EBUSY:
>>              s->has_write_zeroes = false;
>> +            return -ENOTSUP;
>> +            break;
>>          }
>>      }
>>  #endif
>> --
>> 2.27.0
>>
 
 

[-- Attachment #2: Type: text/html, Size: 3391 bytes --]

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

end of thread, other threads:[~2021-03-04  0:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02  1:56 [PATCH] file-posix: allow -EBUSY errors during write zeros on block ChangLimin
2021-03-02 14:10 ` Kevin Wolf
2021-03-02 16:40 ` Nir Soffer
2021-03-04  0:14   ` ChangLimin
2021-03-03  3:24 ` [PATCH V2] file-posix: allow -EBUSY -EINVAL " ChangLimin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.