From patchwork Mon Aug 29 17:10:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9304623 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 AF41D60756 for ; Mon, 29 Aug 2016 23:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F066289B1 for ; Mon, 29 Aug 2016 23:41:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 914DD289C3; Mon, 29 Aug 2016 23:41:32 +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 EC6A7289B1 for ; Mon, 29 Aug 2016 23:41:31 +0000 (UTC) Received: from localhost ([::1]:46206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beWBF-0003YX-7n for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Aug 2016 19:41:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beWAy-0003XT-Vt for qemu-devel@nongnu.org; Mon, 29 Aug 2016 19:41:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beWAy-0003i5-2W for qemu-devel@nongnu.org; Mon, 29 Aug 2016 19:41:13 -0400 Received: from mail-ve1eur01on0120.outbound.protection.outlook.com ([104.47.1.120]:43667 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beWAs-0003gV-2L; Mon, 29 Aug 2016 19:41:06 -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=dHrouZFQzkltDZQN9nBFRHxUu7vnvzT520yLatzTfW4=; b=er5bnXX2T6SwAahZXT8vqmrYSqMhyVSOtrxTRIevVnBUjDQ5YnVIJcSWuLlELPsc+LOI4EdquDSfKCFjI8G/r+m+SIy4cE5Y8pXW4d+7yLazMd5OdLH/sstGpPdqfN1IbPHz5Vybn97ilQZ/eTnmlfRCsPwUzLWF9FvWTga4kDM= 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:25 +0000 From: Pavel Butsykin To: , Date: Mon, 29 Aug 2016 20:10:12 +0300 Message-ID: <20160829171021.4902-14-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: 6d8b1728-1a18-4193-5114-08d3d02f8278 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB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sVW4XzUmf8fYi0kX0pwq0hoIpJ9WVX+WpCc1KPUTXfkTXbChVFDx2dOfq9OGbNbx9D7bD/thA==; 31:vyco7EQFkeROQzXSnPxKNwgOcr7fOjZ9+A7R8os7a/Dpouy5oE5GWXyWo/wYeJWT6hipdgTJlEI2zQkXJWFWHoa154h2u2TMytsc8F2IF+eMksy9rPCwyl5Jdu2iW9jhxMOVPs7IQwE6BcAh02gwfVGLpXSY/7B1WykgeSo1HmIfY4s0HCMYp94zoqqtK8QRcZTqsVf1rPWJK1ytxN+ZhQJW6O0GgEkNf0Ri4apfCAY= 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:K3mvtLGz01SL1yLHxGop1AmSGlL3wdoweWFfDYZb+K5YMZQcPsIY5B3F2aR41E9HQM7vMYz5h+52CgayuhY+/3Mzy+wEGlX+fnd12LSOsp+FasH01iepQp+oarNxoHAET9sBny8dlVqX5ajBSsfmhD3kD4Lne15KeBRDf7JhIbU6ngMugfTvyVsUcthTnkxXAN2eIfDUgMXAjOjHRB5+taGCn1H6baepGwCBidKyg+jGG0Eu7ZxQ7iuornRkOqximNRMkSobZATu+G8T58hgs9hWTyQB1MpF/7+LqViqAwTAIuDuiF6oba510St70tGPaQod8WfKLRYeI95p1AJaavwr8oi2M1QvuUtb9EttNku7NeavSkzBW72Vt6s4wIJrZ0qyWoRITEZq88uLJIgPDXk/HhFwfxqZOeVOx9LQ8Bc= 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)(41533002)(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:hihhBFFbUbBKuIStOf91oEP1OMtA0AyM8C/2CYR?= =?us-ascii?Q?UsBmj5GbOj3X07Od1mTUow209LijC7/i7B8ag5Pe2tlGEClKuMhVM6ghdAz5?= =?us-ascii?Q?SGYL0EBU287i8flzUO9FzjIHBTPP+Bq/6DufBOZPNn3S34rXkzGiFkpGmX7i?= =?us-ascii?Q?/4TQTVUFPKJNpddcqa1BdmQhAkdEAUR7PgaMeHn2mrtseGVVWomdFPkHSV/W?= =?us-ascii?Q?iB+rcQ0NCa+MOwAXUFdx1aatrfr0SVOCNjqrOfgAv8UGWrryOK3vca4P1yat?= =?us-ascii?Q?XZ/orxZT6k0H2CaEnvQ+/8b07JWKxf1JuO5P03JlqUswwIgA+Z4FpQoSbi6h?= =?us-ascii?Q?RxXRnRJfDiB2OZedI501AhGy8lnEPaQhOPToT7bZomDF016qdLBzxtKX2fe/?= =?us-ascii?Q?qkRj+KzxtmGFVWYmWEn2vBJDO/XvxX9J7tIEp+KXPD2AA9af6PNlKtx6uze8?= =?us-ascii?Q?zPoAKRnTv2+yqJ2yfX//rcEgSAFTCx1GgI6J1ICmYe+tXmstpYngMltJJ74y?= =?us-ascii?Q?pShOLLNukPgsSnurysPjcY0O0wGXtaZ35gfVPODaHguBIbzqZjXHO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QuLRicgXVM6TEpqzrIF2OxOGdUmlfGiLizp2LU6HR0iZDQiE/6qO+zMorzR3mNq9K0F8; 5:hoLAgRJSPtKHeRZWBty4/gOJT8gkp7LvpyU9Qn/liOfsmff+Kqtjct4nG407T1UM7ARorce+ZDQZL0W7QzPCBg7tRKBq86325Kh1sk9V9IrMfnbIjN7SBovWfQX06dGwv0suQwTtYZfLAQhD+iEDDQ==; 24:dqbhC5QXZP3DlnicVm3IjjEqMj6UJr5T6Sa9ty8oMTVnsR5bQM9dpHm9EpACYQlTQ2CGf0To9XN21gz3xmJfJrw3s/TR4pt+OXdXhD6TWhM=; 7:fNNGVev0YSLOnok/w1RQYk8a/9D4ty/7ET6u3lsNpOtbOX3rj9stRAw6s8W42WG/DdV/fN5o8rc2JJVqTDve7z7lZo3JTgeLRfKL6gkMUMrzhR6Tgp5Z/aQVQhB5yPumZbOULtgLdnClwJX1gP2noYQpiaNxBck2wh6FmnvcJe8p2jNBsCz/wG+EZUx301tbTwiY6ICYiqZ304lcNjGvS4Ha1Xoc6HJrZXtN7GlLjMdxb/zEMdeDtlqT2fRcjdxW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 20:OFCXLd8igql9t+y97AystodlvjjsuNAIOMd8QPbaH31jz3pqjXn0mEtBeIAG7bH79j2bpsWOU2BsYb07G4pLtsp3IAfxdO8L7lIusRZtjOA4mYser6CyFVV0n6xFL3Tk6UI29rZVpvsnTdujUX9E5UD/wk0ymkzzPMAttNfCEgo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2016 17:11:25.4910 (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: 104.47.1.120 Subject: [Qemu-devel] [PATCH RFC v2 13/22] block/pcache: add generic request complete 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 his change allow us to generalize the completion of all requests. Signed-off-by: Pavel Butsykin --- block/pcache.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/block/pcache.c b/block/pcache.c index 435f2b4..1ff4c6a 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -105,6 +105,7 @@ typedef struct PrefCacheAIOCB { CoMutex lock; uint32_t cnt; } requests; + uint32_t ref; QEMUBH *bh; int ret; } PrefCacheAIOCB; @@ -505,9 +506,11 @@ static void pcache_aio_bh(void *opaque) static void complete_aio_request(PrefCacheAIOCB *acb) { - acb->bh = aio_bh_new(bdrv_get_aio_context(acb->common.bs), - pcache_aio_bh, acb); - qemu_bh_schedule(acb->bh); + if (atomic_dec_fetch(&acb->ref) == 0) { + acb->bh = aio_bh_new(bdrv_get_aio_context(acb->common.bs), + pcache_aio_bh, acb); + qemu_bh_schedule(acb->bh); + } } static void pcache_node_submit(PrefCachePartReq *req) @@ -585,9 +588,7 @@ static void pcache_aio_cb(void *opaque, int ret) pcache_merge_requests(acb); } - acb->common.cb(acb->common.opaque, ret); - - qemu_aio_unref(acb); + complete_aio_request(acb); } static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num, @@ -603,6 +604,7 @@ static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num, acb->requests.cnt = 0; acb->qiov = qiov; acb->aio_type = type; + acb->ref = 1; acb->ret = 0; QTAILQ_INIT(&acb->requests.list);