From patchwork Mon Aug 29 17:10: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: 9304511 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 883366077C for ; Mon, 29 Aug 2016 21:43:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C1CC28998 for ; Mon, 29 Aug 2016 21:43:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB27289C6; Mon, 29 Aug 2016 21:43:43 +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 A246C28998 for ; Mon, 29 Aug 2016 21:43:42 +0000 (UTC) Received: from localhost ([::1]:45871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beULF-0003wf-2a for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Aug 2016 17:43:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUKx-0003tk-W7 for qemu-devel@nongnu.org; Mon, 29 Aug 2016 17:43:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beUKw-00022U-1f for qemu-devel@nongnu.org; Mon, 29 Aug 2016 17:43:22 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:16960 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUKq-00021K-Aj; Mon, 29 Aug 2016 17:43:16 -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=fi+yHQjO6v+9/CJdtN+JRSwfDd0qDyskYh9WZ8kyslz3K80Iw1WzodOKXEjaNlgDeekW9aIGXzDe6EqSNECK0gVGRZuuVqQO2meg8hbIGJS+e9G9KpSweJGqtoAvDFVueyuSBcXC20tYqAFS2lI7DVXlNyS97SBJc9CCfqgFm8k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by AM5PR0802MB2547.eurprd08.prod.outlook.com (10.175.45.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Mon, 29 Aug 2016 17:11:31 +0000 From: Pavel Butsykin To: , Date: Mon, 29 Aug 2016 20:10:19 +0300 Message-ID: <20160829171021.4902-21-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160829171021.4902-1-pbutsykin@virtuozzo.com> References: <20160829171021.4902-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0901CA0011.eurprd09.prod.outlook.com (10.164.186.149) To AM5PR0802MB2547.eurprd08.prod.outlook.com (10.175.45.23) X-MS-Office365-Filtering-Correlation-Id: fa208135-a68a-4607-6bfe-08d3d02f85e8 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 2:lN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cMyqOr2ggm9bnTO2V8ZSw5LGhVUVe28OjwpQmp1DFwoNY7XXadxNcME3B0HbzgtFIYiCg==; 31:BVbtmuPgqigD80a4dX+wsoCvsLBr3ABAzYaHpRqSXuK9ETbyew6fMydjL6mW+O9UBCXVaJvGHkhuOROWtehHu0QQPJvH62ky6XO2eUe9W9FxP4fnlQEInbjEoQJ9rpZYyqYo6uk+wAZGJPkB67TiBP+10pxqfPwvBYpwcnOpBZfe3qhI/r3n1hcnGm/BKbP/HACo2SZ3q1UBtPk4M+EXdcnyJi/GuyRqtrnr0DmDoVc= 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)(6042046)(6043046); SRVR:AM5PR0802MB2547; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2547; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 4:hHTqVmtQcNLW0LL0sAGSV4Xr/O+0RhDs+zdoGFEIoIwgE0g2ZD/LgOpCdEvzdNsfeGsDnn8nCzZOkAJgQYI/Ork8Xoh0OU2iqJONuk8tUJ4AfM4+oolSJO1o5bEBbBdQC9hn4mMMBAsrty3+oX/YAcWWtAkJLzYJir0r6sWtN7OL02kqlCmTQ0/HBgPKmwmdt2k2IGq/pF0rBBFSMOi1dMREyX8UiweleNHRH3q0KdoZ33HdUATrocBekllZgh4itoCo6tVqEuGL7p0muUwSBzIJ65J54pesQBv6KozKo/eyz7XNYxkMWvGi6kyXqjmXyMlq/qpMVe/my/ODN7XQWS+TRNjlka2kwWXIxaT3mLYk3ZEfrc6MI71Ehn/F3HMIv2AC6v8DXeHiTYT2PEiI/9BmTXb3/LP/+WmiM8zdcnk= X-Forefront-PRVS: 0049B3F387 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(3846002)(305945005)(77096005)(86362001)(1076002)(53416004)(92566002)(68736007)(42186005)(97736004)(5001770100001)(47776003)(105586002)(2906002)(6116002)(189998001)(50986999)(4326007)(48376002)(586003)(2950100001)(5003940100001)(50466002)(66066001)(19580405001)(19580395003)(76176999)(69596002)(5660300001)(229853001)(101416001)(36756003)(7736002)(8676002)(106356001)(50226002)(7846002)(81156014)(33646002)(81166006)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0802MB2547; H:pavelb-Z68P-DS3.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; AM5PR0802MB2547; 23:4PQUemd9rU0myS3qGWtcwazyWy4dPnx3hjvtR6D?= =?us-ascii?Q?2DPh4uXRPapiagP+XX/hwaHWVmBfVQZhTtBuGGFAEblmN8hb2dJOjqttvJtq?= =?us-ascii?Q?0UXWQ8K0WyB+Nw4eeOOASKrndHdUbAIpyKaXf1Ku0Fa6XBe/v+I3mGBJh6aO?= =?us-ascii?Q?/DClunWbSwpobJ4tR++mTTyEtVfZtFjTcA4vsckmvIrdlZSqCGQILL0oQhQm?= =?us-ascii?Q?SnpcecM9tZGGVldHpZfUAUC3W1Hr0j6s6JXOFsknuSratL9CgT+qlG6dlL+M?= =?us-ascii?Q?EYSMxsdWfGWOB4n83w+1xUavvuM+TTtKwE/k8jTtSBOPJREpdfXqq7JA/f9P?= =?us-ascii?Q?y4MAF2c7wzNwc+1izFR8K/Ha/+C9JA0aO5Q4uRUKb6lHrtzeZWy2+yFuPwYv?= =?us-ascii?Q?xPah0jg1IOrTCSCp5XaRIbUR9Rd3BCfLgVpRTbRL41svo4Sm/z1EwRyaySH8?= =?us-ascii?Q?SPpmhx4eSEUz1OmyhU4GFa/5eXjrAkKcF/jwydzG+t8uWi1jvwDQS6IKgdPV?= =?us-ascii?Q?OJS1drEZY1iZDodB59b25aTYmlkvW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/fGjEkc0zeVi4QUIGLWS7CkXDVnutohMow0dzNtq3mvLraYWmkAsfQaOYmllsFE83Tv++zG; 5:ejPCkpgpM0Ykwh3DqeS7bGaTwzujhSSEy+/6rEAny8elmL5pwB7mZeuCvVyTJTivXDHkZgYVM3zbFd3qLkSy4/jguz9PTPdVyT9mTP/ERL+QB2QUMohHeG7n9v3Dz+JgC5lJDA1rkCixt8wqMCVsBw==; 24:PL55OAS2IByRkxS+SCdy50F0r0Tvb6Y64eBI6bdFUL9kgPf9PCOGYPUf7NmZjwfreeSlzCKVkO/jhTQ3k9H5dcyTJt0hJsc8qyqNu6SetL8=; 7:LLb80z/9ze7STYVrjOEdc+hpEVdzpO9VfxjQmyC2cfxdixw/3mR1scjXzMZBFJTUDG7gpqWOOu4SAzkwLLIbIAxPzZlngTAByKzvXVqVDgqdS6vwfipn0d1Jlkc9G4PBYSb9OZ6okimT4/gEfcppiX8xaYnk2WXUrdKzk+SEciOctNbzpzxwwYjy/1HLSndmJm2tqeGFmLl+pCUrYpNOHkQbLoGWhpz0QyHhZMXpgztZSSCf0FbeEBiO+nAYkb7P SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 20:aFTtd9LIZGw4xpalPQP1/98/KXoIVyJq+dLOngOe+5sHo+FXk55ZwduaJDgi2swS0D0zK1h/nohj1PFo5Je9v6F65rqzdEeZECbUUJ8ctc2IGUMaBtqFAJVX/9lWGydZazRJq7kYEcl7rHtcS3AaK1a0N33EcL0NpwmteWqrq0k= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2016 17:11:31.2559 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2547 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.127 Subject: [Qemu-devel] [PATCH RFC v2 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, famz@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, 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 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;