block/file-posix: Fix return value translation for AIO discards.
PATCH 1/1 block/file-posix: Fix return value translation for AIO discards.
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.
--- block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/file-posix.c +2 -2
@@ -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 ;
Signature · 1 line
2.31.1
Quoted 57 lines · Ari Sundholm
AIO discards regressed as a result of the following commit:
0dfc7af2block/file-posix: Optimize for macOSWhen 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 <[email protected]>Signed-off-by Emil Karlson <[email protected]>--- block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/file-posix.c +2
-3@@ -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
+Stefan
Quoted 16 lines · Ari Sundholm
AIO discards regressed as a result of the following commit:
0dfc7af2block/file-posix: Optimize for macOSWhen 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
Quoted 8 lines
---- [ 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:
Quoted 29 lines
Signed-off-by Ari Sundholm <[email protected]>Signed-off-by Emil Karlson <[email protected]>--- block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/file-posix.c +2
-2@@ -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 ;
Stefan Hajnoczi
Reviewed-byQuoted 51 lines · Philippe Mathieu-Daudé
+Stefan
Quoted 16 lines · Ari Sundholm
AIO discards regressed as a result of the following commit:
0dfc7af2block/file-posix: Optimize for macOSWhen 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 0Quoted 8 lines
---- [ 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:
Fixes 0dfc7af2b28 ("block/file-posix: Optimize for macOS")Quoted 18 lines
Signed-off-by Ari Sundholm <[email protected]>Signed-off-by Emil Karlson <[email protected]>--- block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/file-posix.c +1
-1@@ -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;
Quoted 12 lines
block/file-posix.c static int handle_aiocb_discard(void *opaque) · line 1835
Quoted 11 lines
block/file-posix.c +1
-1if (!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!
PATCH v2 1/1 block/file-posix: Fix return value translation for AIO discards.
In reply to Ari SundholmAIO 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.
---
v1 -> v2:
* Add Reviewed-by, Cc to qemu-stable and Fixes lines
block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/file-posix.c +2 -2
@@ -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 ;
Signature · 1 line
2.31.1
Kevin Wolf
AppliedAm 19.10.2021 um 13:09 hat Ari Sundholm geschrieben:
Quoted 25 lines
AIO discards regressed as a result of the following commit:
0dfc7af2block/file-posix: Optimize for macOSWhen 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.
Quoted 7 lines
Signed-off-by Ari Sundholm <[email protected]>Signed-off-by Emil Karlson <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>Fixes 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
Thanks, applied to the block branch.
Kevin