From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eroAa-00033d-3l for qemu-devel@nongnu.org; Fri, 02 Mar 2018 12:08:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eroAW-0006Uq-2r for qemu-devel@nongnu.org; Fri, 02 Mar 2018 12:08:32 -0500 Received: from mail-he1eur01on0123.outbound.protection.outlook.com ([104.47.0.123]:51289 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eroAV-0006Re-E9 for qemu-devel@nongnu.org; Fri, 02 Mar 2018 12:08:28 -0500 From: Anton Nefedov Date: Fri, 2 Mar 2018 20:08:15 +0300 Message-Id: <1520010495-58172-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] ide: fix invalid TRIM range abortion for macio List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jsnow@redhat.com, mark.cave-ayland@ilande.co.uk, Anton Nefedov commit 947858b0 "ide: abort TRIM operation for invalid range" is incorrect for macio; just ide_dma_error() without doing a callback is not enough for that errorpath. Instead, pass -EINVAL to the callback and handle it there (see related motivation for read/write in 58ac32113). It will however catch possible EINVAL from the block layer too. Signed-off-by: Anton Nefedov --- hw/ide/core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 257b429..54510d4 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -402,7 +402,6 @@ typedef struct TrimAIOCB { QEMUIOVector *qiov; BlockAIOCB *aiocb; int i, j; - bool is_invalid; } TrimAIOCB; static void trim_aio_cancel(BlockAIOCB *acb) @@ -430,11 +429,8 @@ static void ide_trim_bh_cb(void *opaque) { TrimAIOCB *iocb = opaque; - if (iocb->is_invalid) { - ide_dma_error(iocb->s); - } else { - iocb->common.cb(iocb->common.opaque, iocb->ret); - } + iocb->common.cb(iocb->common.opaque, iocb->ret); + qemu_bh_delete(iocb->bh); iocb->bh = NULL; qemu_aio_unref(iocb); @@ -462,7 +458,7 @@ static void ide_issue_trim_cb(void *opaque, int ret) } if (!ide_sect_range_ok(s, sector, count)) { - iocb->is_invalid = true; + iocb->ret = -EINVAL; goto done; } @@ -502,7 +498,6 @@ BlockAIOCB *ide_issue_trim( iocb->qiov = qiov; iocb->i = -1; iocb->j = 0; - iocb->is_invalid = false; ide_issue_trim_cb(iocb, 0); return &iocb->common; } @@ -848,6 +843,12 @@ static void ide_dma_cb(void *opaque, int ret) if (ret == -ECANCELED) { return; } + + if (ret == -EINVAL) { + ide_dma_error(s); + return; + } + if (ret < 0) { if (ide_handle_rw_error(s, -ret, ide_dma_cmd_to_retry(s->dma_cmd))) { s->bus->dma->aiocb = NULL; -- 2.7.4