From patchwork Mon Aug 29 17:10: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: 9304515 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 E02766077C for ; Mon, 29 Aug 2016 21:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42C628998 for ; Mon, 29 Aug 2016 21:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C41E5289C6; Mon, 29 Aug 2016 21:44:49 +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 4369B28998 for ; Mon, 29 Aug 2016 21:44:49 +0000 (UTC) Received: from localhost ([::1]:45879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUMK-0004qG-9Y for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Aug 2016 17:44:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beULo-0004g6-RN for qemu-devel@nongnu.org; Mon, 29 Aug 2016 17:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beULm-0002J3-Mt for qemu-devel@nongnu.org; Mon, 29 Aug 2016 17:44:15 -0400 Received: from mail-db5eur01on0135.outbound.protection.outlook.com ([104.47.2.135]:47849 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beULe-0002Gj-QP; Mon, 29 Aug 2016 17:44: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=yRhzSkbbKlR8rVeZp0bY23vaYucENA0hSk+ZtuRWmHg=; b=hiKe/S5DpSiyBYQ5UMShROwWs626QYKWXGeZ2pu2a+nRIp6K7oZ5tFBWfjWJxLOIh9caaFxyW2prvrWG9dl+sAcR8R0FClbI9cuLJAK6LdRV2XPuQjLAFn4zjImUHKHbbzVkGUlIQGE262bYbHZ1jPLACKAt6CyyD98QnGw4idc= 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:16 +0000 From: Pavel Butsykin To: , Date: Mon, 29 Aug 2016 20:10:01 +0300 Message-ID: <20160829171021.4902-3-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: d71b60ef-fd8e-4055-ef94-08d3d02f7cfb X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 2: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ZBOAxRg3OcMM9AuSzlE3WMqbsTxnbyaKVkvS7aGRCgflY7vAtlbsxnt2GbXp450g5veda+Q==; 31:iPxuPip9Rs4Rq+PI08re6NwNXVgL8p/sfCaC+ZCa6cp0bWQYjhTf33iHhj4KD0c7IGRAaKftMCWovez061jWRAo5GXORVsNdbBFyU8NNhFRSNJa1oNSmBQ1gUct4SclzclKH0YOiKkQiG7pJxdU6THZdoPvBRj384AMAjcGdMkCHbLtYlIptDfEIqvdVO1WMt5SBhSQwhp0QKfhapUutfpKGuVpB51m22BwDlXH9mVw= 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:xTlPTfUKvNKTt8QgK7zsh6MDJHu0wnqDo/RpXa1XOmYUuUDNuz142s7ZMVkKoomYeflzVmLa419Z4gubeHct8zIQj2aRF9VmKfeGZxx2/e34FlJlteRCACTeHr07cXn4IApqYk62mw1F9+mtrRHvI6EXEk7CXsmo11IKBkIbZ1SmrxYgVU+9dNPkY2V7ZTfCaUOhgMmg933SNIt9WW3vXWj/m2ciOtoY7UmV/L+c1pem5VysS+C3N+CiA/iVFGN5lzD2xNUaHgnSI90I5WaepmVpGFLf6d/65FSLeX9g7lQN5Dlxd3GISRrrUeqXUV3o/w+TT/VvIqt5xu/SBGJeOgsNCJIgBTmsLr19NgmaS0aRnRDpDfaBzVg+ogkRp91zzDQnUrzNPaLjiZP4fXtWEhOxcguExdKak2Kp8lJ2OPo= X-Forefront-PRVS: 0049B3F387 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(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)(969003)(989001)(999001)(1009001)(1019001); 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:gR+m8G2qw8jajlNTHzd7ndi3urzb7zftPYsYNLS?= =?us-ascii?Q?9sGJ/Rp4kFhBKtT2rC4rnLvs4xU8zBV9aLnHUVvqWMufIAH8c5DXcEkv3aGC?= =?us-ascii?Q?3xBpei+7tlhWoVGjtQnlC+GxjhALmSFWbvrrJmXTUhInzUaPrsqBQOYSKvls?= =?us-ascii?Q?ZBohPBu/ceVqLAWiFIHfhuGc+aRyw/kHR/PXXgI9Bdejyn71sP2wr96Q5Tkk?= =?us-ascii?Q?G9ElAAtkE8FGWh0FZzaEhM9npMRwsed1Cp7fsjcSr2LH0FWWUhnyzvh2D8RE?= =?us-ascii?Q?Bv/z9hED0ZA1jxJQQaC9uMZc0QQUep2BuwQt/x9OmN025B/ZPRzD35x56u+k?= =?us-ascii?Q?4zfDGMSKj4IK6FwdT0vv8KGdeRIXz/DODL+OD17jKXlo4TNMrWx6lv7JI3EM?= =?us-ascii?Q?EGMMKzjugWvnAgsIe8N+LWfdfpCmscn2fqOZcrO++2mPcjo2zYzhfcxeUmt4?= =?us-ascii?Q?RqaIYeKgcB/+ZXcdsJJcXjZUsR5Lzit6l4ihAdYvxYBu8CsFVX1WPXQgHAQO?= =?us-ascii?Q?A7wyVG77OaD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FXLjcXjSZ/XXvIFC2DnB7HwyPZZavQ8kAHnr19mMbVni57HnuTszK/EFRrXOMqKcyqQqNlhkTlWGnzit0GfkFbxnFzUKJqgMbKuDYm8QMKzLihSda+0pg3IFvj4laDp1Gbdv+Q+j2HkBEwvkBhf3ajEGNxNy5dYb9qJtRipEXysRsETejIVEaG7EpbJ82JXP/2CbXSv; 5:nCB+ElZYiBhIc0sl6+UereOYQqsn/YyyqOrn7U0qPyncrHp+re1SlwzLgVnOhZ0FqW1EtjI2PFIapChYUACcm4bh61C7EGyUFHU3jUiqIq8f3lZ0urS9A9ur4d8tx6P++yB1YyG431rkFP0J0/IPhg==; 24:rFv7G2uUn4hmqFqIJ84mbG3o/K4dMAKgufpMdz5qwnyhWLiuGhoO2DudEqh5eoe1c+amONfHKJCWkQQ/vGj91Qqh877MbY85SaEZ/jIKuQY=; 7:5CZRpGlI7NQxs1UerW19vwm1ifnuPZjBPN5GiqCeJKgrwxTK6bYzEHHVsQj/zPXpcKGJYrj+rMF8Tz2AK11u4DyutkozMaAqnSM7ZDInvSU3SplWQUO5Mzos4srz/bqOGK78E+Dv2upVv7OOykv0BKaC/zVf2P+s+OFwVs8Y2oOKCF7aW2tMNdZWBQRhSaYnyhqylNuPCavHSJ3QGSRL/qtFUsHaVifhXw0NyOialWleqdbRDm4JoI80+X+RQnho SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 20:LZOEezgPrn6Uo1POFVKQ8Cu6UBudB+XiWil6D20S0/MnmJgnW35y3/Whfp2qwqBVaVVIcxqAuaUe/zrI/st5OmeYzaDyUcfNGa6QNo7BDbIUUXvSpBRcMZqn3635QiFylMwr1uRlVbbg7m1Mi23f57ure2Sng/+bTtvS0f7+CNQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2016 17:11:16.2853 (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.2.135 Subject: [Qemu-devel] [PATCH RFC v2 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, 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 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,