From patchwork Tue Nov 15 06:37:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9429495 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 5F2616047D for ; Tue, 15 Nov 2016 11:19:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EADD2898B for ; Tue, 15 Nov 2016 11:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43492289BB; Tue, 15 Nov 2016 11:19:29 +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 0EA7A2898B for ; Tue, 15 Nov 2016 11:19:28 +0000 (UTC) Received: from localhost ([::1]:45595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6blv-00015K-6W for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Nov 2016 06:19:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6bey-00049H-8k for qemu-devel@nongnu.org; Tue, 15 Nov 2016 06:12:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6bet-0001Yr-KK for qemu-devel@nongnu.org; Tue, 15 Nov 2016 06:12:16 -0500 Received: from mail-db5eur01on0138.outbound.protection.outlook.com ([104.47.2.138]:30064 helo=EUR01-DB5-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 1c6bet-0001YQ-AC; Tue, 15 Nov 2016 06:12:11 -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=UTjJLf2jlgD8ENQHgUmzMEbG8lohrw+GxV8W97kAbko=; b=AmpezOFGLOdo5O/InI9ezV3wokomTgmpGgNpVbm6W3HqBL6AlvGZ7wKFm1z8xQ6HV0L3/K4AAOQZimH1kmcnq+vyRsNBZ0yamUFNfCbj0GeOc9/HzSPz0c0tEPJm4MOFtnLzrCO2l8Gdn+XZnaDJPmLv92E1s8/ApsiEvypoWNg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Tue, 15 Nov 2016 06:38:25 +0000 From: Pavel Butsykin To: , Date: Tue, 15 Nov 2016 09:37:08 +0300 Message-ID: <20161115063715.12561-12-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161115063715.12561-1-pbutsykin@virtuozzo.com> References: <20161115063715.12561-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0101CA0010.eurprd01.prod.exchangelabs.com (10.169.240.20) To VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 2:sOjIQEElSEN0u+2ZjCyyPR8BWKuzya6ptVxw+QPFyluR2FT7YgI8Ihp4qdWvcEdRLyN1lVgmzMcptUPHOHl5t16FCq1XkHxr63MP7sstbWgjaHuJ2ExPXBaAkpz+OD2QLp4KF4sXOqNyYIfiqsTDJx/cp331QaRqTRBw9olE+j0=; 3:8ut0nXbtFrqPdkZd8RkuOfP1k28UROS6JIr9MidxbyIe9OZFFL1/jhF4cWY/YenitV5mSvS+VmNBs2Uj60XVwOczCTjZamubhvFYloQzScbd6gpR261s8iuhyFsDMyuRmoSb7rCDx6kqrehg6xWX3OGTD93YKW0eqUmB1Sxzt+Q= X-MS-Office365-Filtering-Correlation-Id: 812b1b68-1beb-45e3-0eb1-08d40d2200b8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0802MB2558; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 25:jMtuANCEtq8n32IbVSukcvykzsbJNAU5vDpdhW1LGzc/k+1HpyZOJoNV1dCBomKY9aFCL3il6hvDYO5HpT8XAG8Fql47IQtT5Mr/KTZPH0vWNvfsL0M9ye8JcL0XxbdAbf7bDcj7Q3DfFYVPnodM+ghHoGLdOnORRoDrnVxhkBxz0EvATUBfiQ8aUv0ixsC6FDId10gWjSkmbyfLIcyoAhKbDtGJAwP4jQ5A/aixPhFvBltrWXCQIBLC+eeNsOBeAEWcAX8UTzodUGy1qaxOHHrAuAVXc0qRC/+bdcqqbvjU6V+ahINRFZv+g/W2tHKmvYmkWptcInUoh1CyG7QQ3UM5iOyVxu/gn72UEaqLMxCHUrovLva1iBQGKkrzmRWMUXJgYwp8IGoE2F5xOAho9izmvI94yO5v5ph2zWmqupbSsFEoiVrdQW9VrSaIw2ouoB0RnwOP7PToTFk3tFfQv0zpbglASayz0gWloGXHoFH5SZeQOqURacCsxG/K/GlDdmv+hjABZyU5JrDbn3LYBFMhsmR0eingOKFxDj5agQdIQhXxwpWyULkuLueBMafFK66Fn3vR+osVq72qDlM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X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6061324)(6043046); SRVR:VI1PR0802MB2558; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2558; X-Forefront-PRVS: 012792EC17 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(47776003)(105586002)(101416001)(1076002)(68736007)(106356001)(6666003)(76176999)(305945005)(4326007)(97736004)(66066001)(53416004)(189998001)(42186005)(69596002)(2906002)(7736002)(5001770100001)(7846002)(86362001)(48376002)(50226002)(2950100002)(50466002)(50986999)(5003940100001)(33646002)(77096005)(81156014)(8676002)(92566002)(81166006)(3846002)(36756003)(6116002)(5660300001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2558; 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; VI1PR0802MB2558; 23:jn5LtuHPQeBiOZUeOY7LO2jYZbsrOLh2QsC6aBX?= =?us-ascii?Q?910aUicYohs0Vz5f3ynQGW1PEAqTEgqnkFDi9u7NhUEiUrVrUtFotBTtklnh?= =?us-ascii?Q?3K5vU6jyARsLKpMvGyNg9vXlj3XldxKvgb0JpcrGqFCuANY7qQrS2wcFSQh7?= =?us-ascii?Q?UcB8oagzz6Ds45JB1jZr/Kmbu6WbGj0skqd12rJ2cSMpLZcOjyJH5athraxy?= =?us-ascii?Q?jYsMaKPdRedKZujywCD/lGsrn9eH15WJfPA+7RBGNWyGp1oo3wsUwsDZMJw+?= =?us-ascii?Q?toPM3H7EZlxfT4mFnebJv/5lzXXjc4UWwqi/TRWm3OXTOBpxH9Ro4aKcEp0t?= =?us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t8RQQkX4Yj1UGhJOgdGXDndBTxoI+fEElqBeuCFB1cUIo0Gm+x2Or/Je5/nTmOkIlpE9VQgY0z6fFYe3SXClW6BZunhskz0Un6E2KybfLgV7cs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2016 06:38:25.1328 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2558 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.138 Subject: [Qemu-devel] [PATCH v1 11/18] block/pcache: cache invalidation on AIO write requests 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In AIO write request completion we just drop all the intersecting nodes in the cache, it's a simple way to keep the cache up-to-date. Signed-off-by: Pavel Butsykin --- block/pcache.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/block/pcache.c b/block/pcache.c index 1f3800d..27ee6dd 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -362,15 +362,52 @@ out: return acb.ret; } +static void pcache_aio_write_cb(void *opaque, int ret) +{ + PCacheAIOCB *acb = opaque; + BDRVPCacheState *s = acb->bs->opaque; + uint64_t offset = acb->offset; + uint64_t bytes = acb->bytes; + uint64_t end_offs = offset + bytes; + + if (ret < 0) { + goto out; + } + + do { + PCacheNode *node = rbcache_search(s->cache, offset, bytes); + if (node == NULL) { + break; + } + assert(node->status == NODE_STATUS_COMPLETED || + node->status == NODE_STATUS_INFLIGHT || + node->status == NODE_STATUS_REMOVE); + + offset = node->common.offset + node->common.bytes; + bytes = end_offs - offset; + + if (node->status == NODE_STATUS_COMPLETED) { + rbcache_remove(s->cache, &node->common); + } + } while (end_offs > offset); + +out: + acb->ret = ret; + qemu_coroutine_enter(acb->co); +} + static coroutine_fn int pcache_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { PCacheAIOCB acb = { .co = qemu_coroutine_self(), + .bs = bs, + .offset = offset, + .bytes = bytes, }; - bdrv_aio_pwritev(bs->file, offset, qiov, bytes, pcache_aio_cb, &acb); + bdrv_aio_pwritev(bs->file, offset, qiov, bytes, pcache_aio_write_cb, &acb); qemu_coroutine_yield();