From patchwork Thu Aug 25 13:44:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9299405 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 CB6C260757 for ; Thu, 25 Aug 2016 13:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCE2B29278 for ; Thu, 25 Aug 2016 13:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B16882934F; Thu, 25 Aug 2016 13:55:51 +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 6D2EA29278 for ; Thu, 25 Aug 2016 13:55:50 +0000 (UTC) Received: from localhost ([::1]:56402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcv8H-00051C-Jb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Aug 2016 09:55:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcuyp-0004Z0-Rs for qemu-devel@nongnu.org; Thu, 25 Aug 2016 09:46:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcuyk-0002KE-UC for qemu-devel@nongnu.org; Thu, 25 Aug 2016 09:46:02 -0400 Received: from mail-db5eur01on0111.outbound.protection.outlook.com ([104.47.2.111]:22138 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcuyb-0002H0-Iu; Thu, 25 Aug 2016 09:45:49 -0400 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=TLjSeIE8kFyFTsJNnk17arHejp+kNlL0r8+6TfXg0w4=; b=A0b2uGvum9jiePd/C6ob8uflAp0usCoNkJakJ+Da9E76o+VOHtqJCzlGOXhE407CgQexWHzl0E8nLDU5kz2Z12O2N9m8ogYLcymeZFykDyFdYfQCpGkaBPnhJB9hsXBB4hcul+0VDSuNKGcnLAdI34obFATMOvyzJySgDUBg0Do= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by DB6PR0802MB2549.eurprd08.prod.outlook.com (10.172.251.147) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Thu, 25 Aug 2016 13:45:47 +0000 From: Pavel Butsykin To: , Date: Thu, 25 Aug 2016 16:44:19 +0300 Message-ID: <20160825134421.20231-21-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160825134421.20231-1-pbutsykin@virtuozzo.com> References: <20160825134421.20231-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AMSPR02CA0013.eurprd02.prod.outlook.com (10.242.225.141) To DB6PR0802MB2549.eurprd08.prod.outlook.com (10.172.251.147) X-MS-Office365-Filtering-Correlation-Id: f6943dc6-892c-4599-85b8-08d3ccee1ea2 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2549; 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Q+eLZCj9JQg/M0i7sT5KKbtr5/grT3+DcFzG3hAAbp+oy0zxVMhwJv86xP5W007GS9P9ShA==; 31:WIENBGZ/n+ewTIeiNFtKfcgONiRunVc5/bKffWH94uaTuylfZe2/wNr3N947Z+YIamfz3CuQCbRc2SGl69iYr/7XeIbsutF9e/NpxJsUOd5lfO/NBxF+WeEwAOVjDDxO3CaYt5WAIscKrV9QcShEU4sMTQWDJkc7tXLpGufRClhAU9LT/gkR1/waZuCuNhGcB4hpDGih88EspHibtESv+4emNltwvyCIhByreUfZU4E= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046); SRVR:DB6PR0802MB2549; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2549; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2549; 4:nBvJFZS2xBvN6XD28CDIBTfmnAPgBaQKrLo7RVBE7uXriUBjpsk1Xq4TX7awUZqLERURJYU6zQjDJu2PCiZbLZbEBwQqcYH4PaiG10qIDUZNBysw+R0I0wj2aBWq4wT9TAE1qGlbYkH43c0MacSDj8Co8zvcKH68fDj9mAXzq6bYkAoxsWNIy4KEzFT6P/uwvCPvVKljn1O/ehDKwqfGSeE7XrJA8ufrDm7UNZTDZUwBN8dE15mWLDxUhGCcN1PXq4Oj8yBmIBK8PXyBIOf2+sKYAvd5ajrlMd1V7hdcn1MYc2pluc4czGbPQ+n0Gz2ADo/VOHC9mPaeGEd03j6yW1K/y1KaTJI1BLI6TkzYWDrR0KZbAMRDPWWRoHN/XWHYvCu/7i1MtuWTIvmI1XmamDSD1aeN3f6BnBQplHXVba0= X-Forefront-PRVS: 0045236D47 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(86362001)(33646002)(1076002)(69596002)(5003940100001)(42186005)(68736007)(189998001)(92566002)(66066001)(106356001)(47776003)(6116002)(3846002)(586003)(36756003)(5001770100001)(97736004)(2906002)(4326007)(2950100001)(5660300001)(76176999)(48376002)(53416004)(105586002)(50466002)(81156014)(8676002)(50226002)(77096005)(81166006)(19580405001)(50986999)(229853001)(101416001)(7846002)(7736002)(305945005)(19580395003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0802MB2549; H:pavelb-Z68P-DS3.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; DB6PR0802MB2549; 23:P3C8WsepP8ErjkihgmmI7uigAM0WP3Wfd2WB5J0?= =?us-ascii?Q?H+tTgEiJi97Gdzz1RbSLQiNLDK5CGCjn19rjJMOq6bglswtMuFLfM/rHtJ+o?= =?us-ascii?Q?0EGsyj6VcrTXSLhKk/Fifx0vT913tRKliAIoNUL5s515kpT0guLqPg/A3s8D?= =?us-ascii?Q?U0GPfP0EltBL/deKFp/iccBihZahZtwh2IDRIP3wvY4JX+q9N/W6Uf6gzof4?= =?us-ascii?Q?7Wye9D2Eg1IdDIQDDDnuKuTKGYZq/DeOgb1QWblOcU4jqJKEXpxCScZtg8Zi?= =?us-ascii?Q?HSVfVzWRBw0H4moz7X9PALNXuk8djCY7+iIlM82w2ftUcFaEshStLkNSFs1h?= =?us-ascii?Q?ur/04dkpqmIWikPLB6wFwKB9WMI3PPhAIE0A1tQU1etfz4FpRgS6trVkfleK?= =?us-ascii?Q?kfNOPrV2nO2W4ZsknoA9aUjQoFggpCxoYX51jCHZaHiLGHeHLQzQE2JyBCbZ?= =?us-ascii?Q?5VawjrhZPzuRcLnSbVOGLdY+4jx6tnbFTH+5vcIFAAw8Etzcou/Kr+EZ5iDZ?= =?us-ascii?Q?Q+pw6kR0VrnyZwS8j7RKEi+JLi9hx1SYsdpKMUm+Vvy7h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743Y/IG/guzvAvmQi2B2AuIAdVQvrd8FvXKloGxA9JkPUQQTKjw2ImTWj; 5:bd553TNSE82tlJx3luQkTpXd5+wvSRk0s9r97Y7amXhhsTCTTTnnWix9i0xfaWAY3/L1pCIDKZFZADaaM3eNEigUqyG6sFG9CC2Og8XeK10G4UQPfmxoi42M+SsozZctVRvPSlmfwF5+trgRv3DGMw==; 24:UzLH7YTHR0OaaR+m4T0xnWSqLaR0KK5vTv9WwAQw8FV8w4KBmmhfhiFcN/mmdWV8NxtqWe19Y1qVzG/xOsRla/4pwMQCP8jW0VoGBiHOQv4=; 7:p2a/qbWPtgjvY7antxwlwjs4Z8S5Q++9YzhvvNvQkMAgy7JL+I2VLs7FuOPb4hM5E47GFzB//RQCXisDn4hFT3kQe3seYwBgqSC8gYBh/eap6VOgAi+xa9uh8+hjp7wjAClGx7xr9a8+3sraTqhnSoD+U0ojKex3c0a2aD9bZ3n9BIivQzJ057ly3LCGlE9VyTFw3o4+EG+U8cTkYuQCTrjFjLiZ9HxjlTvRKeG8CopP/ZS07oZoNr31B54JFvia SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2549; 20:o0OY/jOqzT+hwCKOZ5mH3xsrXl/FfeGMzURZOFnWSwdIE96WJIkIZNuTB4y1YL4DnUINgqLxZw0NtTBV0tgj9dAJtg7vbX2ZPtAr7mMqZ3CfTG7hvKhfnXNH7flk3qi2uDrUbGUkA79aB5WfmTDjx40Kqk1VovlyHAA6udLXHnc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2016 13:45:47.0846 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2549 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.111 Subject: [Qemu-devel] [PATCH RFC 20/22] block/pcache: implement pcache error handling of aio cb 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: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Added error handling aio requests to pcache driver. If the request fails, then fails all pending requests. Signed-off-by: Pavel Butsykin --- block/pcache.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/block/pcache.c b/block/pcache.c index 7b4a9a9..c5fe689 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -683,7 +683,7 @@ static void pcache_aio_bh(void *opaque) { PrefCacheAIOCB *acb = opaque; qemu_bh_delete(acb->bh); - acb->common.cb(acb->common.opaque, 0); + acb->common.cb(acb->common.opaque, acb->ret); qemu_aio_unref(acb); } @@ -696,7 +696,8 @@ static void complete_aio_request(PrefCacheAIOCB *acb) } } -static void pcache_complete_acb_wait_queue(BDRVPCacheState *s, PCNode *node) +static void pcache_complete_acb_wait_queue(BDRVPCacheState *s, PCNode *node, + int ret) { ACBEntryLink *link, *next; @@ -710,7 +711,11 @@ static void pcache_complete_acb_wait_queue(BDRVPCacheState *s, PCNode *node) QTAILQ_REMOVE(&node->wait.list, link, entry); g_slice_free1(sizeof(*link), link); - pcache_node_read_buf(wait_acb, node); + if (ret == 0) { + pcache_node_read_buf(wait_acb, node); + } else { /* write only fail, because next request can rewrite error */ + wait_acb->ret = ret; + } NODE_ASSERT(node->ref != 0, node); pcache_node_unref(s, node); @@ -753,16 +758,17 @@ static void pcache_merge_requests(PrefCacheAIOCB *acb) assert(req != NULL); NODE_ASSERT(node->status == NODE_WAIT_STATUS, node); - pcache_node_submit(req); - - if (!(acb->aio_type & PCACHE_AIO_READAHEAD)) { - pcache_node_read_buf(acb, node); + if (acb->ret == 0) { + pcache_node_submit(req); + if (!(acb->aio_type & PCACHE_AIO_READAHEAD)) { + pcache_node_read_buf(acb, node); + } + } else { + pcache_node_drop(acb->s, node); } + pcache_complete_acb_wait_queue(acb->s, node, acb->ret); - pcache_complete_acb_wait_queue(acb->s, node); - - pcache_node_unref(acb->s, req->node); - + pcache_node_unref(acb->s, node); g_slice_free1(sizeof(*req), req); } qemu_co_mutex_unlock(&acb->requests.lock); @@ -799,6 +805,11 @@ static void pcache_aio_cb(void *opaque, int ret) { PrefCacheAIOCB *acb = opaque; + if (ret != 0) { + acb->ret = ret; + DPRINTF("pcache aio_cb(num: %jd nb: %d) err: %d", + acb->sector_num, acb->nb_sectors, ret); + } if (acb->aio_type & PCACHE_AIO_READ) { if (atomic_dec_fetch(&acb->requests.cnt) > 0) { return;