From patchwork Fri Dec 30 14:31:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9492331 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 041F462AB9 for ; Fri, 30 Dec 2016 17:06:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0EDB1FF15 for ; Fri, 30 Dec 2016 17:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1E79223B2; Fri, 30 Dec 2016 17:06:19 +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 2DAC41FF15 for ; Fri, 30 Dec 2016 17:06:19 +0000 (UTC) Received: from localhost ([::1]:40815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN0dG-00088X-Ak for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Dec 2016 12:06:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN0cp-00086j-Hh for qemu-devel@nongnu.org; Fri, 30 Dec 2016 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN0cm-0005qf-C3 for qemu-devel@nongnu.org; Fri, 30 Dec 2016 12:05:51 -0500 Received: from mail-db5eur01on0102.outbound.protection.outlook.com ([104.47.2.102]:64446 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 1cN0cm-0005qK-1G; Fri, 30 Dec 2016 12:05:48 -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=4yjZG4B7hlB6+7TD6iqvAS/VbTRnZ6Y9qnltlaiqtdw=; b=VRl32SCRvcIeI3W/u5edQtW0DugsU268GPWTReg0gJ45nFTeMk+GwAhUFV8h1Z3CpxAHhsZEZZ8oEVMNCQA0fYCwUfnbjVqDzleNKbaFHZvuZh9hewWzEHA1f1klbflgOwmJ+p7xQgGblEeueGqPZk8o53eshSz7VE0MiUKhNuY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.6) by HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11; Fri, 30 Dec 2016 14:31:56 +0000 From: Pavel Butsykin To: , Date: Fri, 30 Dec 2016 17:31:25 +0300 Message-ID: <20161230143142.18214-2-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161230143142.18214-1-pbutsykin@virtuozzo.com> References: <20161230143142.18214-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0802CA0010.eurprd08.prod.outlook.com (10.172.123.148) To HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) X-MS-Office365-Filtering-Correlation-Id: a256f458-10a5-4533-97bd-08d430c09b6d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 3:dSDS4U3rm/zWwNYFNJ1lOg4eLP6IIBqp86VMrsNzGWeveOWlywH61kr3rZMPE8EZSc6HqS7tmhK7hougM6btPjptOtTumlRnBUcVUpJu7AqhyVOAv+D+k8fECS/SvrHI9hKzlFo0L8iiBInzNKG36RLJcOKlS7/Owup+2Q9sYs7g+uYJX1nLX0r/iISZPLMPA+T91u+7Az12LMlHT9k98WTNTLBxjtVNj01R11E8W6kheIECDcWTO6xm3qabyO354CwneQ7dSLRmVzzY49BNgg==; 25:sgYh8lzgnU+KkFrRxlBrMCGhF2vQYCySb3oQ1X6WEaUG0JNyqN8Qy17yL6ZEdIhnh5xjotcQstqc+DC8E15WUZ1nOa4v2w2WbxoWINxYr4o8mgHgB/EkiesV6b1F9hlZ75kYg8opOkbGOyKO2QCncyck1RALUQ1bcywo2xKSd6Fa4NEd9Ne8QD8RNJ96FL+kh0iLsovV4DlX2zULR/PP0AkjnsXSlMjRQUye7TUHV9UHu+FTI5RP4YukvaxH5GPfzo0FF7mbY7R+WHxYxskOcOQlGmrI/PKwEaRnCHVuSUAqj2US5DJFkkThT5Y43qim2fzRBukUOprn7E8eKziz48DbbFlAcumctIgcN1dU/CZdVcXRe147vwn4lHtSg523zF+PGDDMEP62P3KSJux/VlNJzaMyBlCSgt/4euQ6MLWbTynWI0sj4XpvstSb0QhX0Dh8tMCVjKbnK24VpNWfNA== X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 31:tOxfCLXWlEGaA+8yDY+51xOZ1iadNvh/N2a43RQ+BLnsRfcS3jYkPFF7dfEnLOZFrDQ0iHfGO6sgXznuu5CUCmVltmuF2Vnvw3aMzvwKmt0Py1RIMdRO5A27QV1Md4MlmatvizWG8MnDzwBtAAlBpJteFV8RiI64ku2+KxNJwppQ3z3B5tPr5tUuQWsLBnH/BC18a/SALm6A3ro2H0GSnkO1TccmlIQS+TWGIeX6z8Wz117aAC4DOSphRzHUXMbR; 20:mkKFXjtdKeGY+gb6zoTCABoqRs6RElj3CuHWQoRf7YHPDWVFj9qLTAL1+GO4oAvLa6q8k820XqL5BgrXlkb7LOGYdt6J6i1na2zbxjLK9lvbw/WdGqDzdt8jztcgv8quRpAzgZyQTKdWaDQ3BfnyhPpnD1NAAZdOygd+Lrrwn35+J80/6N1Sfu5jnH8R1krMw31Ks3wyoY19zFPZpiH1SIxGUYUlg+x8X/jT+liADY38q556MBfrqdTZFp6K3P7C X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123558021)(20161123560025)(6072148); SRVR:HE1PR0802MB2555; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 4:bVyp9O+gmOHvU8AWx1oSaRgMdFvMKyKW/Gp18QHr4tAFcA2N2O5zgVTZXYlqETeAHS6CFKid3tiXCqqOTqIzmWri0JpqfrFLXioBF5fadn4KZtSuCOe7mAc1PNSfmuh61CV0kzrt1199BLn+jSFDTaSi448RJbC474jM0Eh0NC50PTUgaX2Z4aIPfIA1ahXOzx13c5xsndps95uHXI1AMrnSuvZSDvVOtk4t3OzyeLUQj2pRDdc8B1V9yfXewr/wDdFjcc9q4pYkX/NhT3Ovb2eBgrFfA6oTzY+NO/N+I1q1R/K+UpuhSQRfQt9tbEcg9NQ2D3rpRscVI2adAjtO5tYkB6UhmTG56Y+4Eczs7p8e8T634/dClkAPh4TTLn7hIhwJjHg/bsceH16hT56SdzDqYpLDG3o/iWUEj/3pKur4wvqWj3j1N5pTcg3X03nWLUGZybRn4ELYgfPPBkPCIKIiVLqH9hcX/sruFH+RA+wXHCllDj9wN9z9Meh8BuSwcek5IOfqxxxF6ejGYcy7yqhnuLmxV8gA9RNvOyeVHEPuoJcn2rIbKIOixFJ6pIv267C2mssCE/IA9t4gNC0IBps/Bzp715sGo9iAnQDmDgw= X-Forefront-PRVS: 0172F0EF77 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(199003)(189002)(6666003)(5660300001)(189998001)(5001770100001)(50226002)(81156014)(81166006)(5003940100001)(8676002)(97736004)(47776003)(66066001)(6486002)(36756003)(6116002)(3846002)(76176999)(105586002)(33646002)(92566002)(305945005)(38730400001)(50466002)(106356001)(50986999)(1076002)(6506006)(6512006)(69596002)(4326007)(2950100002)(25786008)(2906002)(7736002)(68736007)(53416004)(42186005)(48376002)(101416001)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2555; 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; HE1PR0802MB2555; 23:7q2apsfEC1ZhcW3xHIAJR9keXXDcD7s/0CRZlie?= =?us-ascii?Q?FaJ7+2jAhYUh8z7FJ9a0XEktlIsf90gS/sA3WOSVED8Vpu9PpNUtyqj2aZCx?= =?us-ascii?Q?jcOSIXxOUQJdG4NhAGi7uL5pOCIy/2kb1fT0j2p8WiXCuPwPFzJvsbu+NImn?= =?us-ascii?Q?sB9Ahl6jzrZr+RoMJ+k+VvrcIe3K01F/YBMcU7Vthal8GNyB/KrNNbYuwJek?= =?us-ascii?Q?tVTjfy+N47LTsvtLu84FUx3Ftn5M8RiVYHf6bqmmyyaVJw3DcscapRpwlGnI?= =?us-ascii?Q?hRFFrtGjLpflV2eWs6N7Cbkp2fc0KpWm+mU9XCP+qjo3kq51yB0KkKZcgZrC?= =?us-ascii?Q?BkNuSyvBbZXhlOcrLKSJeMs0QH6m/grm3qpCExhEJ0FvsrPPQkpysQo2aGLH?= =?us-ascii?Q?9JlAle8X03BN3m4xfm5kTtgyV21QEVqBJHABzmty6X0nMkrAt//B0FC6TWkW?= =?us-ascii?Q?mIn/KFThlv7VQMbjfsc2Auk6sWKTHBx5lRrEIQIz+rHGo506ldgXPfAIQwZt?= =?us-ascii?Q?msDuWImgekPim/AAQn8tEcv6vQpEHbDgJlEZO3fXTxInqcOLTOlkGf/0krb2?= =?us-ascii?Q?y+g86pRukBdZMv6iSWanjcM4Vfn7HBuaKvep42xXDVvXecf01eC2Ea0Cdw0Z?= =?us-ascii?Q?SKt2e9c9VxN9v6PDatOsYcIk/P1jZKi4hb9sVB3bEBDTxvIBdHXlEkbr4Oh1?= =?us-ascii?Q?Ufc1y5b1+ZkHHjqwzkXdgnu5NG0Npy7eU1/2RWSTqngq8EsJo44VuIR6teQi?= =?us-ascii?Q?vlhF1a6Y58CQb5JzJV0Sk01hwMg3IAmALjb5wflZzmZQzBqxHwHDg6G/gY+0?= =?us-ascii?Q?NkG7BdAs8gvmEqODzWV1QssKbZXl1GCDMKvy/wdYJGMZjE/n+scxSa8PoXUw?= =?us-ascii?Q?Viamhn8kldcTElPbFrzCbwfYIraj514Zx6qJg/hTecmImGMal1YxI+xg5FHs?= =?us-ascii?Q?yKUGF4hGpo6Q2vcajZnUa+pSCqGkuP85ZFSF/rT/MvXbtMowMgo36SgVM7bg?= =?us-ascii?Q?AhydXPQ6P/oZY0fOTo2EDyPat+9VflIKjYzh2y+8NfYFgwi3zjUwOXmp6RKj?= =?us-ascii?Q?5xOPZwaaNp4etcJ0OieDUmchC41/glQbjfTa6O7Z3d+2LsnvkJvgTZHk6NAF?= =?us-ascii?Q?WbE2LkM6TeE4=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 6:x39EvR/597wB2PyyZCwrcpDmnyKrYF9H58RKcIZ81Qeu1b02scth+nynHZrVDd1+WCCOvNRR2YAwkSLU5ct1G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k5thvhk6NDNjv93p1ij8WaLVsr0n6zmfU9/Mx2FQytaUMAenTaElUkiAAfvUDjX5kRRITSlALtzIcVAxvOby5EBLMnuA==; 20:gNAGwX1jd/FdS0u95523y5zDhzHuwVaYvMM1TjX9OUXbhW/98EJ/R+CVAjujAHs15i2SWTqiilyT8YSuYQW/sIfGPG9zGFTOS/CZ2uE8+OF7ZNRbtItf1kiL93coe1Tl0jfPUIQghc01K0Fu6Ust4Ftet2kW9hUvCGKIGV4TPvo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2016 14:31:56.3035 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2555 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.102 Subject: [Qemu-devel] [PATCH v2 01/18] block/pcache: empty pcache driver filter 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, armbru@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The basic version of pcache driver for easy preparation of a patch set. Signed-off-by: Pavel Butsykin --- block/Makefile.objs | 1 + block/pcache.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 block/pcache.c diff --git a/block/Makefile.objs b/block/Makefile.objs index 67a036a1df..0a024f4e66 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -4,6 +4,7 @@ block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-obj-y += qed-check.o block-obj-y += vhdx.o vhdx-endian.o vhdx-log.o block-obj-y += quorum.o +block-obj-y += pcache.o block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o block-obj-y += block-backend.o snapshot.o qapi.o block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o diff --git a/block/pcache.c b/block/pcache.c new file mode 100644 index 0000000000..7a67618408 --- /dev/null +++ b/block/pcache.c @@ -0,0 +1,102 @@ +/* + * Prefetch cache driver filter + * + * Copyright (C) 2015-2016 Parallels IP Holdings GmbH. + * + * Author: Pavel Butsykin + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "block/block_int.h" +#include "qapi/error.h" +#include "qapi/qmp/qstring.h" + + +static QemuOptsList runtime_opts = { + .name = "pcache", + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), + .desc = { + { /* end of list */ } + }, +}; + +static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, QEMUIOVector *qiov, + int flags) +{ + return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); +} + +static coroutine_fn int pcache_co_pwritev(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, QEMUIOVector *qiov, + int flags) +{ + return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); +} + +static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + QemuOpts *opts; + Error *local_err = NULL; + int ret = 0; + + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + assert(bs->file == NULL); + bs->file = bdrv_open_child(NULL, options, "image", bs, &child_format, + false, &local_err); + if (local_err) { + ret = -EINVAL; + error_propagate(errp, local_err); + } +fail: + qemu_opts_del(opts); + return ret; +} + +static void pcache_close(BlockDriverState *bs) +{ +} + +static int64_t pcache_getlength(BlockDriverState *bs) +{ + return bdrv_getlength(bs->file->bs); +} + +static bool pcache_recurse_is_first_non_filter(BlockDriverState *bs, + BlockDriverState *candidate) +{ + return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); +} + +static BlockDriver bdrv_pcache = { + .format_name = "pcache", + .instance_size = 0, + + .bdrv_file_open = pcache_file_open, + .bdrv_close = pcache_close, + .bdrv_getlength = pcache_getlength, + + .bdrv_co_preadv = pcache_co_preadv, + .bdrv_co_pwritev = pcache_co_pwritev, + + .is_filter = true, + .bdrv_recurse_is_first_non_filter = pcache_recurse_is_first_non_filter, +}; + +static void bdrv_cache_init(void) +{ + bdrv_register(&bdrv_pcache); +} + +block_init(bdrv_cache_init);