Skip to contentSkip to conversation

file-posix: allow -EBUSY errors during write zeros on block

PATCH Superseded ChangLimin 3 participants 5 messages Mar 2, 2021 – Mar 4, 2021 Block layer

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

ChangLimin

author
#0 lore raw

PATCH 1/1 file-posix: allow -EBUSY errors during write zeros on block

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

---
 block/file-posix.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
block/file-posix.c +0 -0
index 05079b40ca..3e60c96214 100644
@@ -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

#1 lore raw

Am 02.03.2021 um 02:56 hat ChangLimin geschrieben:

Quoted 19 lines

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

---
 block/file-posix.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
block/file-posix.c +0 -0
index 05079b40ca..3e60c96214 100644

block/file-posix.c static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) · line 1636

Quoted 9 lines
block/file-posix.c +4 -1
@@ -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?

block/file-posix.c static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) · line 1637

Quoted 1 line
block/file-posix.c +1 -0
+            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.

block/file-posix.c static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) · line 1641

Quoted 4 lines
block/file-posix.c +1 -0
+            break;
          }
      }
  #endif

Kevin

#2 lore raw
In reply to ChangLimin
Quoted 9 lines · ChangLimin

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

Quoted 27 lines
---
 block/file-posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
block/file-posix.c +6 -2
index 05079b40ca..3e60c96214 100644
@@ -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

author
#4 lore raw

PATCH v2 1/1 file-posix: allow -EBUSY -EINVAL errors during write zeros on block

In reply to ChangLimin

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

---
 block/file-posix.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
block/file-posix.c +7 -2
index 05079b40ca..4e132db929 100644
@@ -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

author
#3 lore raw
In reply to Nir Soffer
Quoted 9 lines
Quoted 8 lines

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

Quoted 8 lines

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

Quoted 27 lines
Quoted 27 lines
---
 block/file-posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
block/file-posix.c +6 -2
index 05079b40ca..3e60c96214 100644
@@ -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