* [PATCH] block/file-posix: Fix return value translation for AIO discards.
@ 2021-10-18 18:07 Ari Sundholm
2021-10-19 2:57 ` Akihiko Odaki
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ari Sundholm @ 2021-10-18 18:07 UTC (permalink / raw)
To: qemu-block
Cc: Kevin Wolf, qemu-devel, Emil Karlson, Hanna Reitz, Akihiko Odaki,
Ari Sundholm
AIO discards regressed as a result of the following commit:
0dfc7af2 block/file-posix: Optimize for macOS
When trying to run blkdiscard within a Linux guest, the request would
fail, with some errors in dmesg:
---- [ snip ] ----
[ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
driverbyte=DRIVER_SENSE
[ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
[current]
[ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
terminated
[ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
00 00 00 00 00 00 00 18 00
[ 4.011061] blk_update_request: I/O error, dev sda, sector 0
---- [ snip ] ----
This turns out to be a result of a flaw in changes to the error value
translation logic in handle_aiocb_discard(). The default return value
may be left untranslated in some configurations, and the wrong variable
is used in one translation.
Fix both issues.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
---
block/file-posix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 53be0bdc1b..6def2a4cba 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
static int handle_aiocb_discard(void *opaque)
{
RawPosixAIOData *aiocb = opaque;
- int ret = -EOPNOTSUPP;
+ int ret = -ENOTSUP;
BDRVRawState *s = aiocb->bs->opaque;
if (!s->has_discard) {
@@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
aiocb->aio_offset, aiocb->aio_nbytes);
- ret = translate_err(-errno);
+ ret = translate_err(ret);
#elif defined(__APPLE__) && (__MACH__)
fpunchhole_t fpunchhole;
fpunchhole.fp_flags = 0;
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block/file-posix: Fix return value translation for AIO discards.
2021-10-18 18:07 [PATCH] block/file-posix: Fix return value translation for AIO discards Ari Sundholm
@ 2021-10-19 2:57 ` Akihiko Odaki
2021-10-19 3:40 ` Philippe Mathieu-Daudé
2021-10-19 11:09 ` [PATCH v2] " Ari Sundholm
2 siblings, 0 replies; 6+ messages in thread
From: Akihiko Odaki @ 2021-10-19 2:57 UTC (permalink / raw)
To: Ari Sundholm
Cc: Kevin Wolf, Emil Karlson, Hanna Reitz, qemu Developers, qemu-block
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
On Tue, Oct 19, 2021 at 3:08 AM Ari Sundholm <ari@tuxera.com> wrote:
>
> AIO discards regressed as a result of the following commit:
> 0dfc7af2 block/file-posix: Optimize for macOS
>
> When trying to run blkdiscard within a Linux guest, the request would
> fail, with some errors in dmesg:
>
> ---- [ snip ] ----
> [ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
> driverbyte=DRIVER_SENSE
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
> [current]
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
> terminated
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
> 00 00 00 00 00 00 00 18 00
> [ 4.011061] blk_update_request: I/O error, dev sda, sector 0
> ---- [ snip ] ----
>
> This turns out to be a result of a flaw in changes to the error value
> translation logic in handle_aiocb_discard(). The default return value
> may be left untranslated in some configurations, and the wrong variable
> is used in one translation.
>
> Fix both issues.
>
> Signed-off-by: Ari Sundholm <ari@tuxera.com>
> Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
> ---
> block/file-posix.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 53be0bdc1b..6def2a4cba 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
> static int handle_aiocb_discard(void *opaque)
> {
> RawPosixAIOData *aiocb = opaque;
> - int ret = -EOPNOTSUPP;
> + int ret = -ENOTSUP;
> BDRVRawState *s = aiocb->bs->opaque;
>
> if (!s->has_discard) {
> @@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
> #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
> ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> aiocb->aio_offset, aiocb->aio_nbytes);
> - ret = translate_err(-errno);
> + ret = translate_err(ret);
> #elif defined(__APPLE__) && (__MACH__)
> fpunchhole_t fpunchhole;
> fpunchhole.fp_flags = 0;
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block/file-posix: Fix return value translation for AIO discards.
2021-10-18 18:07 [PATCH] block/file-posix: Fix return value translation for AIO discards Ari Sundholm
2021-10-19 2:57 ` Akihiko Odaki
@ 2021-10-19 3:40 ` Philippe Mathieu-Daudé
2021-10-19 9:27 ` Stefan Hajnoczi
2021-10-19 11:09 ` [PATCH v2] " Ari Sundholm
2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-19 3:40 UTC (permalink / raw)
To: Ari Sundholm, qemu-block, Stefan Hajnoczi
Cc: Kevin Wolf, Emil Karlson, Hanna Reitz, qemu-devel, Akihiko Odaki
+Stefan
On 10/18/21 20:07, Ari Sundholm wrote:
> AIO discards regressed as a result of the following commit:
> 0dfc7af2 block/file-posix: Optimize for macOS
>
> When trying to run blkdiscard within a Linux guest, the request would
> fail, with some errors in dmesg:
>
> ---- [ snip ] ----
> [ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
> driverbyte=DRIVER_SENSE
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
> [current]
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
> terminated
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
> 00 00 00 00 00 00 00 18 00
> [ 4.011061] blk_update_request: I/O error, dev sda, sector 0
> ---- [ snip ] ----
>
> This turns out to be a result of a flaw in changes to the error value
> translation logic in handle_aiocb_discard(). The default return value
> may be left untranslated in some configurations, and the wrong variable
> is used in one translation.
>
> Fix both issues.
Worth including:
Cc: qemu-stable@nongnu.org
Fixes: 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
> Signed-off-by: Ari Sundholm <ari@tuxera.com>
> Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
> ---
> block/file-posix.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 53be0bdc1b..6def2a4cba 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
> static int handle_aiocb_discard(void *opaque)
> {
> RawPosixAIOData *aiocb = opaque;
> - int ret = -EOPNOTSUPP;
> + int ret = -ENOTSUP;
> BDRVRawState *s = aiocb->bs->opaque;
>
> if (!s->has_discard) {
> @@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
> #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
> ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> aiocb->aio_offset, aiocb->aio_nbytes);
> - ret = translate_err(-errno);
> + ret = translate_err(ret);
> #elif defined(__APPLE__) && (__MACH__)
> fpunchhole_t fpunchhole;
> fpunchhole.fp_flags = 0;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block/file-posix: Fix return value translation for AIO discards.
2021-10-19 3:40 ` Philippe Mathieu-Daudé
@ 2021-10-19 9:27 ` Stefan Hajnoczi
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2021-10-19 9:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Kevin Wolf, qemu-block, qemu-devel, Emil Karlson, Hanna Reitz,
Akihiko Odaki, Ari Sundholm
[-- Attachment #1: Type: text/plain, Size: 2549 bytes --]
On Tue, Oct 19, 2021 at 05:40:13AM +0200, Philippe Mathieu-Daudé wrote:
> +Stefan
>
> On 10/18/21 20:07, Ari Sundholm wrote:
> > AIO discards regressed as a result of the following commit:
> > 0dfc7af2 block/file-posix: Optimize for macOS
> >
> > When trying to run blkdiscard within a Linux guest, the request would
> > fail, with some errors in dmesg:
> >
> > ---- [ snip ] ----
> > [ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
> > driverbyte=DRIVER_SENSE
> > [ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
> > [current]
> > [ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
> > terminated
> > [ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
> > 00 00 00 00 00 00 00 18 00
> > [ 4.011061] blk_update_request: I/O error, dev sda, sector 0
> > ---- [ snip ] ----
> >
> > This turns out to be a result of a flaw in changes to the error value
> > translation logic in handle_aiocb_discard(). The default return value
> > may be left untranslated in some configurations, and the wrong variable
> > is used in one translation.
> >
> > Fix both issues.
>
> Worth including:
>
> Cc: qemu-stable@nongnu.org
> Fixes: 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
>
> > Signed-off-by: Ari Sundholm <ari@tuxera.com>
> > Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
> > ---
> > block/file-posix.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/block/file-posix.c b/block/file-posix.c
> > index 53be0bdc1b..6def2a4cba 100644
> > --- a/block/file-posix.c
> > +++ b/block/file-posix.c
> > @@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
> > static int handle_aiocb_discard(void *opaque)
> > {
> > RawPosixAIOData *aiocb = opaque;
> > - int ret = -EOPNOTSUPP;
> > + int ret = -ENOTSUP;
> > BDRVRawState *s = aiocb->bs->opaque;
> >
> > if (!s->has_discard) {
> > @@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
> > #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
> > ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> > aiocb->aio_offset, aiocb->aio_nbytes);
> > - ret = translate_err(-errno);
> > + ret = translate_err(ret);
> > #elif defined(__APPLE__) && (__MACH__)
> > fpunchhole_t fpunchhole;
> > fpunchhole.fp_flags = 0;
> >
>
Thanks for the fix!
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] block/file-posix: Fix return value translation for AIO discards.
2021-10-18 18:07 [PATCH] block/file-posix: Fix return value translation for AIO discards Ari Sundholm
2021-10-19 2:57 ` Akihiko Odaki
2021-10-19 3:40 ` Philippe Mathieu-Daudé
@ 2021-10-19 11:09 ` Ari Sundholm
2021-10-19 12:02 ` Kevin Wolf
2 siblings, 1 reply; 6+ messages in thread
From: Ari Sundholm @ 2021-10-19 11:09 UTC (permalink / raw)
To: qemu-block
Cc: Kevin Wolf, Stefan Hajnoczi, qemu-devel, qemu-stable,
Emil Karlson, Hanna Reitz, Akihiko Odaki, Ari Sundholm
AIO discards regressed as a result of the following commit:
0dfc7af2 block/file-posix: Optimize for macOS
When trying to run blkdiscard within a Linux guest, the request would
fail, with some errors in dmesg:
---- [ snip ] ----
[ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
driverbyte=DRIVER_SENSE
[ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
[current]
[ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
terminated
[ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
00 00 00 00 00 00 00 18 00
[ 4.011061] blk_update_request: I/O error, dev sda, sector 0
---- [ snip ] ----
This turns out to be a result of a flaw in changes to the error value
translation logic in handle_aiocb_discard(). The default return value
may be left untranslated in some configurations, and the wrong variable
is used in one translation.
Fix both issues.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-stable@nongnu.org
Fixes: 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
---
v1 -> v2:
* Add Reviewed-by, Cc to qemu-stable and Fixes lines
block/file-posix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 53be0bdc1b..6def2a4cba 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
static int handle_aiocb_discard(void *opaque)
{
RawPosixAIOData *aiocb = opaque;
- int ret = -EOPNOTSUPP;
+ int ret = -ENOTSUP;
BDRVRawState *s = aiocb->bs->opaque;
if (!s->has_discard) {
@@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
aiocb->aio_offset, aiocb->aio_nbytes);
- ret = translate_err(-errno);
+ ret = translate_err(ret);
#elif defined(__APPLE__) && (__MACH__)
fpunchhole_t fpunchhole;
fpunchhole.fp_flags = 0;
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] block/file-posix: Fix return value translation for AIO discards.
2021-10-19 11:09 ` [PATCH v2] " Ari Sundholm
@ 2021-10-19 12:02 ` Kevin Wolf
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2021-10-19 12:02 UTC (permalink / raw)
To: Ari Sundholm
Cc: Stefan Hajnoczi, qemu-block, qemu-devel, qemu-stable,
Emil Karlson, Hanna Reitz, Akihiko Odaki
Am 19.10.2021 um 13:09 hat Ari Sundholm geschrieben:
> AIO discards regressed as a result of the following commit:
> 0dfc7af2 block/file-posix: Optimize for macOS
>
> When trying to run blkdiscard within a Linux guest, the request would
> fail, with some errors in dmesg:
>
> ---- [ snip ] ----
> [ 4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
> driverbyte=DRIVER_SENSE
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
> [current]
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
> terminated
> [ 4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
> 00 00 00 00 00 00 00 18 00
> [ 4.011061] blk_update_request: I/O error, dev sda, sector 0
> ---- [ snip ] ----
>
> This turns out to be a result of a flaw in changes to the error value
> translation logic in handle_aiocb_discard(). The default return value
> may be left untranslated in some configurations, and the wrong variable
> is used in one translation.
>
> Fix both issues.
>
> Signed-off-by: Ari Sundholm <ari@tuxera.com>
> Signed-off-by: Emil Karlson <jkarlson@tuxera.com>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Cc: qemu-stable@nongnu.org
> Fixes: 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-19 12:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 18:07 [PATCH] block/file-posix: Fix return value translation for AIO discards Ari Sundholm
2021-10-19 2:57 ` Akihiko Odaki
2021-10-19 3:40 ` Philippe Mathieu-Daudé
2021-10-19 9:27 ` Stefan Hajnoczi
2021-10-19 11:09 ` [PATCH v2] " Ari Sundholm
2021-10-19 12:02 ` Kevin Wolf
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.