From patchwork Fri Mar 2 17:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10255217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A15F460211 for ; Fri, 2 Mar 2018 17:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9223D26419 for ; Fri, 2 Mar 2018 17:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84CCC2654B; Fri, 2 Mar 2018 17:09:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04E5F26419 for ; Fri, 2 Mar 2018 17:09:12 +0000 (UTC) Received: from localhost ([::1]:36450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eroBD-0003PS-VS for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Mar 2018 12:09:12 -0500 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bIFpSqPJisLNX4Fovs5DDAsadNwzEnUh08DY5QNaQnE=; b=N/NoVOP3NZl0+nga4dU+HV5rMyqnIwgAMVDl+N26KmoE/S9jiXX4aSM88z8kZOVKx7JBv/b9ZHAeC6ZRJMC5oPN+iNIEZAlLc+VQHuAXY6KXvnYCBXGik32xNkv2XyY8QCMk7064AOkCotfMpTuea6lUZJFVA41wcOatpQdV2d4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Fri, 2 Mar 2018 17:08:23 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Fri, 2 Mar 2018 20:08:15 +0300 Message-Id: <1520010495-58172-1-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR05CA0237.eurprd05.prod.outlook.com (2603:10a6:3:fb::13) To VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54f7d184-88c2-4450-b221-08d580603549 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 3:xv6CNI8+mFLIfi/3WJHITS/h1uArbLTJv+g0y4pLiA2dljoI3Neraw1BOC6mVte2S1VK7+B6fRcJm1x3UxhuD7N4npwLMQEoKLDMFtDpSTfuChesN/TR6SwPm1jigcLKfwI51OWuS8UcCZJCrKNsnZQYymiZkAwOqf2cJrZOYRPFK08XBJFICfRLusJC/IcuchQb88W/7dWJF8f7uVF6TM7N+TmLg6yZcaaQTko6PcoA9Y8sxWe/rZ5jM4Zjrocj; 25:zw/l9ywodPuhwQ3xYkkLjdvxoXxLmQKKzyqipkvv+MLPtavoMvUrTTXjVayJf/MREN8iPUWPLpp3hA1TnwATiEU8Hy92T+sF80CIXUrR8JCX0/FSui77xVYFd9SHa5PuCfHmTUmnBO6BXzmUpkHv+xpQaXNvY+SILW6XHdN8367yM/pn6SqfMc3X+qeQ2wMcH03usuz/ExFtvDIKY8RkTI4DHcZkUPZQ5uNPcKZOJcAYtYkO+BOrAOfKvXNiebyeMbcmo1kMIODLMvGDixyuDp4eIy1j0VoYSNXgpCn6Gwq5Kpl5hUS0GW1G/ioAOcQ1EjZEs4S3hdGVgo9IqTGm0g==; 31:ZExdLbXHNyc5jBPk4qPcJb67/tibMcYuv88Oen26HmaJa48P6uXuELobotI5Fv3rnSWWFcYRxTlCMZC5YcBtaWm8H2qTNf2QkpaSDzvjcfNOdtBd2BqduTxA/V3wagVpc6wrD5oWmVCQxHr5Kv6ggQPoRXroTfcyl6vZm3lDYczYLSpJG2r9N8eCVzGvZv+C9ZbTDjV2ore9PKha2SzBcecPb83qA+9tpU2tCo4AWrk= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 20:lec5puRZpwqjKc+uamcI1ly8uJ0/M/5uarAfOtoPvpPbMTJoOWv0lOVPxNl7HF3gvo5s1aWvIVSGsdEM7pMdBWIB9X0qkzG1wAiop3g/N+Hz4lpDCmPM2MLJlK4zbN3iXsI0DCkKpjJsLbsdxjramanrqpMOU9zz14qIx0H3CJGyykiFmvGi0fgZcMEHJ7F15fde59wouHQHHLq7xuaTJaR/PWKL7L8YLvOi2Ky5Dl2wP3VpJ8ClXdfoe5OFGSPQm5P6JFndcd1WYFz0pTreg16LB+eAu4R3IUDcyIJ7OQBFRLfw7E/v7eGtbgwzx3Vk2MhRlVc2mXFe6OiM/a3pZwvPQ3a+9TbQ+fiM1X7JwSjAUynM22S2bIF5qOy16KJjb84gpI8nb8aO6hA3n0jr2AFqrvx6w6G4qx2ElNKnz5hB0TrxBxsmDKg1kkOD5H1Ia4Gj0yQsQ6uBes3NV5mBhf5I1qPBLQpBOZAADS3jBWZSPAbKx7QpoyykjAvojrm2; 4:bTSvl8NrQLyn/50p66MV8BFFRRY4gGJ84lxoSyDCTY/PScZ6463o/aNxZXs/ffvteDjFYp0Gm9GGug46+jtGJA1WDUmtACmYv+u2r+7gl6HNKs/i2ANNKcpXIAwYIOnSlSk7qFGsnUSCjTemXGStA+A1/Ms4znqpdL2/hLnSzRuHrxKgx+BIFO1VBLKowdMEaESK6GRSu3uESJWhplBTxnoNLlJ4hZfG3yWArXnLPDZ802QRtPJg1TIU4SSCRulxBNQAa8ODZe4l0bhwOMaPQA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231220)(944501241)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:VI1PR0801MB1999; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1999; X-Forefront-PRVS: 05991796DF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(396003)(39380400002)(39840400004)(376002)(346002)(189003)(199004)(66066001)(105586002)(6486002)(4326008)(16526019)(386003)(25786009)(16586007)(53416004)(97736004)(6512007)(36756003)(305945005)(1857600001)(7736002)(47776003)(59450400001)(478600001)(86362001)(186003)(5660300001)(26005)(55236004)(68736007)(2361001)(106356001)(6666003)(6506007)(53936002)(3846002)(6116002)(6916009)(2351001)(2906002)(52116002)(51416003)(316002)(48376002)(8676002)(69596002)(50226002)(8936002)(50466002)(107886003)(81156014)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1999; H:xantnef-ws.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 23:YJivcuGJhuUv3v/cpNUkI/iu7HblloR5W2QUYZp?= =?us-ascii?Q?vgBWL95PsnS/spI+UXk9aC0YqyUpzzeyfvZmcwOJg5k14lxSbHxrwPGPbON4?= =?us-ascii?Q?msJ4ZFWLBYlvgkSmwuyDCkB3gb+Twx54UoCnuczVrcr+9A0Azzk3iPdXiNNc?= =?us-ascii?Q?xsieph+Qd3qEz7RiLWHqNfCqbqyQNFQsUo+isnSGIBO0z9gFRfoIFs4wGK4m?= =?us-ascii?Q?NUkGCbf21Ii49rfBx6xmfqq1C+3VD6+Kny1vwF+fQ3C9OofUjxQoC6m9yyJi?= =?us-ascii?Q?/vlV0IX1EnbQehHA3lTmtGJ1uAAEwLLK23YARX6gLIWv9T0SBJpx+fDwwgQJ?= =?us-ascii?Q?V27WZHDSDoWap727VHeXpNwsv3DYndFrF0Eb4NUs3NppFF2ksSptkVTNGrCy?= =?us-ascii?Q?CeBoiSLgtnxba3CQ4PgsnGuBdlFFTQMQMKmj6SyvKX3AhKmZqNRF7c68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Oenz54QgTD06EZRbKvIHZDKTLBxcM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2018 17:08:23.7968 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54f7d184-88c2-4450-b221-08d580603549 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1999 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.123 Subject: [Qemu-devel] [PATCH] ide: fix invalid TRIM range abortion for macio X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, Anton Nefedov , jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Mark Cave-Ayland --- 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;