[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/12] block/file-posix: Fix return value translation for AIO disc
From: |
Kevin Wolf |
Subject: |
[PULL 01/12] block/file-posix: Fix return value translation for AIO discards |
Date: |
Tue, 2 Nov 2021 17:05:17 +0100 |
From: Ari Sundholm <ari@tuxera.com>
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.
Fixes: 0dfc7af2b28 ("block/file-posix: Optimize for macOS")
Cc: qemu-stable@nongnu.org
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>
Message-Id: <20211019110954.4170931-1-ari@tuxera.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.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
- [PULL 00/12] Block layer patches, Kevin Wolf, 2021/11/02
- [PULL 01/12] block/file-posix: Fix return value translation for AIO discards,
Kevin Wolf <=
- [PULL 02/12] block: Fail gracefully when blockdev-snapshot creates loops, Kevin Wolf, 2021/11/02
- [PULL 04/12] ide: Cap LBA28 capacity announcement to 2^28-1, Kevin Wolf, 2021/11/02
- [PULL 06/12] file-posix: add `aio-max-batch` option, Kevin Wolf, 2021/11/02
- [PULL 05/12] block/export/fuse.c: fix musl build, Kevin Wolf, 2021/11/02
- [PULL 03/12] block/rbd: implement bdrv_co_block_status, Kevin Wolf, 2021/11/02
- [PULL 08/12] linux-aio: add `dev_max_batch` parameter to laio_io_unplug(), Kevin Wolf, 2021/11/02
- [PULL 11/12] block/nvme: Display CQ/SQ pointer in nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 12/12] block/nvme: Extract nvme_free_queue() from nvme_free_queue_pair(), Kevin Wolf, 2021/11/02
- [PULL 10/12] block/nvme: Automatically free qemu_memalign() with QEMU_AUTO_VFREE, Kevin Wolf, 2021/11/02
- [PULL 09/12] block-backend: Silence clang -m32 compiler warning, Kevin Wolf, 2021/11/02