From patchwork Thu Aug 25 13:44:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9299399 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 262B660459 for ; Thu, 25 Aug 2016 13:51:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 175B82933E for ; Thu, 25 Aug 2016 13:51:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9C829341; Thu, 25 Aug 2016 13:51:06 +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 7B65E2933E for ; Thu, 25 Aug 2016 13:51:05 +0000 (UTC) Received: from localhost ([::1]:56377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcv3g-0000Ka-Fv for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Aug 2016 09:51:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcuyW-0004Et-Jv for qemu-devel@nongnu.org; Thu, 25 Aug 2016 09:45:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcuyR-0002CA-AU for qemu-devel@nongnu.org; Thu, 25 Aug 2016 09:45:43 -0400 Received: from mail-db5eur01on0133.outbound.protection.outlook.com ([104.47.2.133]:34146 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcuyJ-00026u-FN; Thu, 25 Aug 2016 09:45:31 -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=yRhzSkbbKlR8rVeZp0bY23vaYucENA0hSk+ZtuRWmHg=; b=XPCwQBTcDf22Cz/fk3fIS1Px5BU19bA/QT7kKdgXH3a8Ae5uH6xjZYIrszsKju8QKNXng1JyBs+o/GjtBmYZTXRckla/GzDUz5sKjpwZ2KENPvknX1iAaHRyCY6L6BU1a4MUQRuV9w2e0a/4AuCZCgX0hCTi/idsfou4Nz2ou9k= 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:28 +0000 From: Pavel Butsykin To: , Date: Thu, 25 Aug 2016 16:44:01 +0300 Message-ID: <20160825134421.20231-3-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: 5e328c56-4d5d-4bfe-0c63-08d3ccee1351 X-Microsoft-Exchange-Diagnostics: 1; DB6P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+7cuX0uWskVVMNlhcxCxkRwFI//0A3dmfJjIhoz2XJOXbHrlTdjQiBNXNxsmCFvOd91FHkkC3wso4uyXhw==; 31:w1UQBtWgF6cHuUXNYp8xeDuuG4NO/RFtNlHBNoFm+6rypQ40/u+2smG3uA+6jxJ294iBnJGgWkbFdawTbGv2wKPaYZj0FaaNkCbss0hKdDrL8iR6Vz+YlVqyDD60SQIzDbAoJFgJN9hQkQTaCwOXK8CoCqb2NgnFPS0+2TQCMITFyF4fnDATQ5iQ2XL82hZdB7rUWQOGoeW7zlXaqoifw59sitn4cwQy1tkwDnj1km8= 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:sy2OMm+d7BVeux8SPYkts2k9iMQ1H+QZZ6ZGnQf0yNevYgH+UFPQnwHzZdAm/O265U/gqpPXQr0SEmTzmvKUeiuLerWkQxRxEpYJuEZPBoOC8nxPlAjd2MZZ8F/Bz6ImzNgAtbrBxYxqUHy4YmEHJHGooodnOhBXG7wUz7eBFrrFNUsZtAq0l4344HWRK876g0dzcuc31/ybj93MijLvqsglWKsvgDHZ8JiDyTVibpROO2f9IAvQBhuiV0QBkFW6MtHdXMTWVxOzp64mwoTM7uoi064Ok7jgCr9swkcMXYUYGzC6ig8nEdbT8WVsab+kEeH0xzKMnvVCuv8m4Pj65205+0cuBH4hPGJb14hFxTlHat1J22HmOISdp/okMPzN7zNby8E3+ijqEkZwgZ+k5UO4hfhbsM8zc56QVg4sFA4= X-Forefront-PRVS: 0045236D47 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(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)(969003)(989001)(999001)(1009001)(1019001); 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:Ou4w7VdbRyLrErnU8mhuvW4G8eM5VuTmHIZI3kF?= =?us-ascii?Q?Rq0IQjDDjtzEVpUbq1H/COzN7bpdz7OXAfhnbgmvVfuI8WKpDGGuZmTNH2M9?= =?us-ascii?Q?B/gRK1/XYJHqriDvi3PMxyjvbFE/2mXUXhc2Kk2kbTJgHgr40CwX8GYrVyu4?= =?us-ascii?Q?tFkicwANzjOe0H7uq+XbJz4enD/AdNEQLxPRFS2owerLnoRN5Cikos8RdPIe?= =?us-ascii?Q?tbWNfdbpUjnjXTlwqG17SYXlTDdco4HI5vA5bqsV/5XsYmKIX83AILLrctdh?= =?us-ascii?Q?KDSJ5Ze6+p6+4vx0wLvs2bb74450YPozvpKq8inwdRGFnSkvNR/pTi8GXu4/?= =?us-ascii?Q?YRyzziXPBUqQO5sKS5ME01sr4WcQsxfmzUSezxhJvUxPD6w/zN3bvPIrVxPZ?= =?us-ascii?Q?uPUeh0tHBz8eYSQgr3pwyDvnzai9sYSqX0M1+sMBofcPtgx+B10ITMzYU+tn?= =?us-ascii?Q?BA2MRC377PrSeY/YqFrdfc1QJ1kUuf3BI7bRY8TRWTOzNIz4wN8svW54hYP8?= =?us-ascii?Q?BwaPP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qnl55dsqDAibe+upMNfB/ePjjcpQ8+YRWJHzZmV5Op0bEaY/eE8jXz+V9nW9ihXSgtdbgm0EdTlu8hZanNvC0XCyXf9jQ9qh38hOULtboQHi3QcWpOawsB0xZJZ/zs/fRa3q53j33v5hJX+KLCe98/69zSxYTuG/bP68P1U+/hChguELLg3EVAksboGZvJhTvtogAkiX5sxALjWznfvzUjxlW; 5:Zd90H5xHQddsaIDDQNTFAOU2AUalVl4Ocn5iaz6JsLTMG61ClqCYuswGuaJAwkq+BWxoI0eDpoWl9puI6uo2ATDUxenqUPozQwiaXVFtNdf8IGFB9m+JeEbtmm1e4GzSub5SMU5Lvl8iJX+MzZ+yTw==; 24:9ARm1aJRWs8HpvWBAZO9ukWunBZoUbmCM467emsNTlR6RFKjIrG7rJAp43I4akOPIRnY777VppcgJjQ4bkSIcRhw8x/B+UK6zLG7pqVbXfk=; 7:FkbJGoxdkzpxf4S/t4pKS/9NGQmX5LMJPneyHuV9WXSa1rbOqqbcCEFTMPNHWw6kWMiuuOmhTs02wrBe6xUMN8tG90mmkcep6G/UlqqylGHcs7wWskaYXA4v+VNSAv3+dyE40vjhZh8od1B88LnONV4arn0mPck5ivqGi7ycTOW0ApLI+Tl7w2oh9lkKLg5nm8Z/CGu3kVnXd8wsQYwoH3JSR5FPF1EOkywqGoAi6hEdKV0Ix8bMU+bWO7FOCais SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2549; 20:FemKPga2fVt6rsKR4ZaT8d2TmIbgZqjtDGac9LG2bILArfqPIU8+8XMe7sLWGEGevC3paLuL84CnkdrM/AdccrCQTAoGgpCetM+uD4oU29iuqG3CwSYzPflPROBih1CjeXDTeFGUuJ1NRa+Sa43nT+MC7NquPAH6NVwMsNrGHIY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2016 13:45:28.0737 (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.133 Subject: [Qemu-devel] [PATCH RFC 02/22] block/pcache: add own AIOCB block 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 Signed-off-by: Pavel Butsykin --- block/pcache.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/block/pcache.c b/block/pcache.c index 770bbc0..74a4bc4 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -24,12 +24,22 @@ #include "qemu/osdep.h" #include "block/block_int.h" +#include "block/raw-aio.h" #include "qapi/error.h" #include "qapi/qmp/qstring.h" +typedef struct PrefCacheAIOCB { + BlockAIOCB common; + + QEMUIOVector *qiov; + uint64_t sector_num; + uint32_t nb_sectors; + int aio_type; + int ret; +} PrefCacheAIOCB; static const AIOCBInfo pcache_aiocb_info = { - .aiocb_size = sizeof(BlockAIOCB), + .aiocb_size = sizeof(PrefCacheAIOCB), }; static QemuOptsList runtime_opts = { @@ -47,14 +57,29 @@ static QemuOptsList runtime_opts = { static void pcache_aio_cb(void *opaque, int ret) { + PrefCacheAIOCB *acb = opaque; - BlockAIOCB *acb = opaque; - - acb->cb(acb->opaque, ret); + acb->common.cb(acb->common.opaque, ret); qemu_aio_unref(acb); } +static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num, + QEMUIOVector *qiov, int nb_sectors, + BlockCompletionFunc *cb, void *opaque, + int type) +{ + PrefCacheAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque); + + acb->sector_num = sector_num; + acb->nb_sectors = nb_sectors; + acb->qiov = qiov; + acb->aio_type = type; + acb->ret = 0; + + return acb; +} + static BlockAIOCB *pcache_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, @@ -62,11 +87,12 @@ static BlockAIOCB *pcache_aio_readv(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { - BlockAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque); + PrefCacheAIOCB *acb = pcache_aio_get(bs, sector_num, qiov, nb_sectors, cb, + opaque, QEMU_AIO_READ); bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, pcache_aio_cb, acb); - return acb; + return &acb->common; } static BlockAIOCB *pcache_aio_writev(BlockDriverState *bs, @@ -76,11 +102,12 @@ static BlockAIOCB *pcache_aio_writev(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { - BlockAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque); + PrefCacheAIOCB *acb = pcache_aio_get(bs, sector_num, qiov, nb_sectors, cb, + opaque, QEMU_AIO_WRITE); bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, pcache_aio_cb, acb); - return acb; + return &acb->common; } static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags,