From patchwork Wed Nov 1 15:44:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10036663 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 C56C96032D for ; Wed, 1 Nov 2017 15:46:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C280928C06 for ; Wed, 1 Nov 2017 15:46:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD90F28C86; Wed, 1 Nov 2017 15:46:22 +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 8D61428C06 for ; Wed, 1 Nov 2017 15:46:20 +0000 (UTC) Received: from localhost ([::1]:56372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9vDf-0008Fe-H4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 01 Nov 2017 11:46:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9vCE-0008B6-JR for qemu-devel@nongnu.org; Wed, 01 Nov 2017 11:44:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9vCA-0006g2-1F for qemu-devel@nongnu.org; Wed, 01 Nov 2017 11:44:50 -0400 Received: from mail-eopbgr40133.outbound.protection.outlook.com ([40.107.4.133]:45238 helo=EUR03-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 1e9vC9-0006ec-LP; Wed, 01 Nov 2017 11:44:45 -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=L5uY0TZAUtpXEiXgP3dxH97F/yXH60DBOGtkmb0EOtQ=; b=G43yTu3nqvreCMeQ6Dznjxf1yNTt8/QL4uUOHukxdIRjFhS8+qEc86ifZ8WN3L4IfZCRLs0IazyukzbLo8+Oxg3wKgJ9I/FMfjJznYt60oRBh8krY7YWf2GqokAYA80YJ3Ar0LmmKH65sNZo/j+nsfSX6M8kAo4zk70MCkDgmXY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by AM5PR0801MB1987.eurprd08.prod.outlook.com (2603:10a6:203:4b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Wed, 1 Nov 2017 15:44:43 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Wed, 1 Nov 2017 18:44:01 +0300 Message-Id: <1509551048-129830-9-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509551048-129830-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1509551048-129830-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: VI1PR0501CA0017.eurprd05.prod.outlook.com (2603:10a6:800:92::27) To AM5PR0801MB1987.eurprd08.prod.outlook.com (2603:10a6:203:4b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4d7f3f6-b7df-43ec-15a8-08d5213f7928 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(2017052603199); SRVR:AM5PR0801MB1987; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1987; 3:r2Y3LP1SsuaF7qEpqCC3gLA8/EHF3GedS0i4mKUWq5+EtyOQiHFAleQDJBImg2yfljtyydePj+mCgXXJIbovoClUh41ssC9PiEL38x/8CfYV8CLm4AMSPk+oRR+Nz/mX/Us3fMRBao9zXQkqZ63wEDArV6iWKKiB33HdgIch8ajex5HizHOtqojo63r2L1uPhxMyINln+SNzuqPiLKHSC46t/kMo469DCCZDT++Xy0oOi4QHvE1zqQdhqw3lU2LK; 25:in4KY/lKupGDQlKVkoUZ4EAB/N3p/USrUI6uZsPBXIYVApdnYXqxzJ6wL+mhSbnKwCivudRvwyLsDMVEMsAcy+A1+eSqqZXgBGkiOPVCIM6rV4Ct2kCuUrh0cngvhpt4/GVcsvexcu8RhiVaBkx3Yfy3Vi473cDfTuIHMEZMTNUelkDLqlgNoLSizaM1IjutnKkFoFMs3P6nkdjEUhpqa3DVGw+EFrQQpra+BVnslvvpHI/4RZ8EkHCNoGmdByzh7JSAzRyx73l7gdjHbLkLtGUmM8RIpkBFzxR8kpWLJDv7JLyupG8n3sUNpW3E6VzPqN/640J31eYlGrfMvLp7QQ==; 31:NemlA80TtAk6yK5dfxJH2IEnnwa4kQm2r9/CTWijNLmlCSds3wpzjKBemd52acuncDPGizu/5y4QyPPyznnhvLjPMNwrTYTbA4mWb+/jQCuu5BM8QV0FItYf0rigOuA60/9uKOus4JDQHT6UsUwIUg7E4AYmHl2MnLyX8glkMFGACdwh9VVvisoUqfYrcRwci0mrD1JJcuBNvmxUidSvQkTUeI/HP1eZMycVuT3isno= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1987: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1987; 20:ukR2DspeuSnLebGK2+PiPMlp+Id3FQ0odbU4ejJjHYKUeEVPJDCjoaoNMUrahgjHe+//n6ttwJHG1+GWFHX6WHn//P+DTkzol4BD31aiBbdKzGmBnVT1XJ/cPvqVQm64kxDdNSHXD6IjfXDF5kmcl7ATeJjKV6tyeYt7bnFv0N/hDOQR3PKsxWccpNCk6Uz5s7MvXLyYE1ntD0gLSlGMaYWDiJIIl3Hl9E1aO2zUow1vcqtRZeMlpbL6qRB+cSGIRmt8xwg9UYdq6znwzh4QoaqxTctbpy2mezCRMjkMtCtwHL9piFLe3W2drnQYfMFVgt4hJoGVWccAQu5ZwttaNkshUqj2sndemSr1p15pcKjl1ljO8gqxz7TR4M93cLCUcp70jmcIQ+5Cef6pky3S9goTyt/PdQhHGzDZI8EIlBY=; 4:6DjU8f1b6IiYvcLvTBMGhrwpZXi5kczsh5mezQvJkjtWARWhL/qWa1TuJvCZOeYigauX7NcKb0edGF10ymzadSKUQxr2AvgkPbf9th7u/dJ520JESxREtDefoQiDCNe3WCGo7+VRtl6F7tcy3vickKCyoOohqVnDnFvRvbseNpeYqpGaz9cOqXJdr+gQ9BU3+5linqa8pSaP9hDHFeff6xCnOR/NPjO0gkDOJXaefS5Nu4NCVFdONQYGfwmfO7epfEXIzW42VjHxDz+/GCg3/g== X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231020)(100000703101)(100105400095)(3002001)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM5PR0801MB1987; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM5PR0801MB1987; X-Forefront-PRVS: 0478C23FE0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(979002)(6009001)(376002)(346002)(189002)(199003)(6666003)(16526018)(53936002)(107886003)(48376002)(86362001)(6916009)(2950100002)(3846002)(6116002)(101416001)(575784001)(50986999)(76176999)(106356001)(69596002)(5660300001)(25786009)(105586002)(316002)(53416004)(2351001)(16586007)(2361001)(33646002)(4326008)(5003940100001)(478600001)(66066001)(36756003)(50226002)(6512007)(47776003)(2906002)(8936002)(6506006)(97736004)(6486002)(68736007)(305945005)(50466002)(81166006)(81156014)(8676002)(189998001)(7736002)(21314002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1987; H:xantnef-ws.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; AM5PR0801MB1987; 23:Jdnkp7mNTvh23ztulBRMBgGXnZ7eb3l1YUyy1XS?= =?us-ascii?Q?7O5m+4U87w/WDWy/zyMaCgtAeCVNLU3I6Dre3uQrgaJED8C8FjgG0Grlneyb?= =?us-ascii?Q?Ba3NmUuNuMblyJF4Ne7nTm/1RPiDwmZqZYU29Nz5CfW643k5nJnmIy3fVYW0?= =?us-ascii?Q?o2AXusFM20x1K51g1XGw6BCp/g6SVZfPAw1GvQ94H6pnSFJgbTkhoFnBoHOG?= =?us-ascii?Q?TawhxjmUuAfsraHncnsXHrjcWaeq7qCaFILDp4GLHDIFsUxilhfddU3pZDNx?= =?us-ascii?Q?vboeTmYWOqGfMjqqyhjv8+5Ae2PXmyDRI8ket3+spSD61HhX7FPYVFmIjMK3?= =?us-ascii?Q?Whey60YpxQIUhKrAXbhtVAdCwCFyqGpXBNzVzlNVfG1ZlEVa/6xVh12qxrJZ?= =?us-ascii?Q?BC+Ag7WXR/K3hOEvlTH9T/yKw3cJJml15N3thG2ceE6Kav/Qh+CVWA0vfm31?= =?us-ascii?Q?9ntxdTaAqqnrV3znbG5LfBK7X2S67Ud/UiSKyjuyA0DmuJu3A+rO3MBQjDVx?= =?us-ascii?Q?YcxmolTWIGnKeS42431/8vZ40W2gah6/9F2eqrWSH7lNMjuknBhhQTe2KLXk?= =?us-ascii?Q?auaPpM2ZMsObBNEDIiqQmwP7vWoX+hVM9N18Q8rPWc+jqkJF0J7duMIU67nO?= =?us-ascii?Q?r/7boRAXH2m2OQXuTwnb9cA17qWi28yOsWYsuStbr4YT+ejgi52t2SNEl9iA?= =?us-ascii?Q?N7SfVSGX+shborsv+XlxY7ymMSC8jWqbgGHH+lrEOwlY1wqvSyqLrh1Qzl7B?= =?us-ascii?Q?m+3F57TlAorysFRlIX3/M5cdJHsZhbBrpUFJf81GVJfZOSRz+PRCerosd/qu?= =?us-ascii?Q?3LTKazOw1ln4TTWzakWY1eTLhXAU1BhZh7njred1mmROZ/uLzXHOog1OjTv1?= =?us-ascii?Q?fI3/Bv3r21EDQkHKmD74txAEzN+QmUPyqpsEokDzL+fRDkXhEzbvHOV+L3nu?= =?us-ascii?Q?6ZQeVauMvylCMjkGQKaDIom8vpfxwrzS7TU9OI7C2tGoSy/IR30jUJJIDSgq?= =?us-ascii?Q?JxkN3aAv+vKH83G1YeFQd+lqT2CQrZ4JCAvK2aSqtt0E1geEGuCXQIPSiMEP?= =?us-ascii?Q?fEhq6wzgJ7MXR/DYgPhTysIQDBG5JOSGNBU8G2dAcaZuBp8nLymF2AnjHUVU?= =?us-ascii?Q?hMs6IhBBhlWVy1JHrAlSvi8UPgD60JtGKovg6O8GbNhnfodaDaFRet9a30sS?= =?us-ascii?Q?PwVxuuSOP3RSsjT6GBPIgZoGms8eNin40Ai1GIdYPWIZK7an5sGp1UBTKZF5?= =?us-ascii?Q?fjlhrW7wiiipTf6bbRDetBqFVt6NVYgcO2xwHFafpf92Mz8MnASU5VAbfxKM?= =?us-ascii?Q?KtXeHlj5MDIKNQmGE7jxRh4M=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1987; 6:8RF6CPymHwfe9LsaVwgPzU94gfhj180+Pss8zh0LNF9uZ+bcG6K/rwL0PxMwjyeAgkz+QpeLhzEW50KWTJpWIZCdWyMJjuUSe5sR51VbsBOwFeMAlu/KiKxJ898wXFd2Y8mjws0+JDXlAG1l5C+FTvRSOoakofwXj7bnvjKzQeooAZGVCUE59xon8asIYO1y12RIo8VajFyQAzdtKcJ+Z6T+RGj5EahncosyS2Tt66ZiVOQPUTBFucakb+J51epwXBHjGbr3coKnPTkdWU4Rcnkwm7NXPrcrRTfQHsbl/BiCMykeizEXesofonIwg2fWVIB3m6t2fOO6zvM53geFsAONqAohEkI28V0AWs4oTAA=; 5:vnzLcl7BePf6HEoRHCMfu4lvz5YkfkMJ/3GHGfj3zKrDLFlbhbXhVD7gXplbEpiSDMZQOrWAhD4GFQIFjAcOSl03GOEEbOKLFJ6IVW6UoIiwFVFMXArrCBJJFbf7gJXSUo/cEAwfhYEHZmDyM/NE4hYXGvC1lIrnDB5hwkVs/wo=; 24:xB7DM7y5LG2xcjTK1oJ3M7zFY4LGA4nIgRgzlEy9kE4CJp51T7Lw8Ild6XL6RA3lts3W2B2C3JM1zD45q7qJiWu/y543uQGwk0t4QWSqW7k=; 7:75Bkv/d65NSS9qDB8xhEHWBLWQzkTqg6Rme/eCF5Me+/QpBNd5aUpR4123h5TUY0J+a+9htbnq6YOBz3JxarTCGBRdmbe6JRXxHfutARJm9380nnHkQKxn/4tHCJRRUiLEHF/ncFNhF0UaRnyjOSssi3JOftz+BP6W96IdxaP87sYpovGu7C6LcuCR3qCbM7BTkR67W0BAiXvKsdgMsGgIyPrj1sAhJmIXQEJv0AFo04Ud5QeroVJOTWHCki913P SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1987; 20:MqaRBGPoC88RzGWuGgR2qDW5X1q9oi3XZAwfKt7rQ3xArx+2HN2i/oLAo1SZ7iPZE5vSTmk27UO9kEcyp2CSeivqTZWP5mTWBbuSqOWAQBUb22FEQFbAKtEXB4A4UAhdV/NqEkw9/H8LFWbvsBw2OpFFZFvHo+73eSZsycSDod4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2017 15:44:43.3838 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4d7f3f6-b7df-43ec-15a8-08d5213f7928 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1987 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.4.133 Subject: [Qemu-devel] [PATCH v5 08/15] qcow2: skip writing zero buffers to empty COW areas 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, Anton Nefedov , berto@igalia.com, den@virtuozzo.com, qemu-block@nongnu.org, 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 If COW areas of the newly allocated clusters are zeroes on the backing image, efficient bdrv_write_zeroes(flags=BDRV_REQ_ALLOCATE) can be used on the whole cluster instead of writing explicit zero buffers later in perform_cow(). iotest 060: write to the discarded cluster does not trigger COW anymore. so, break on write_aio event instead, will work for the test (but write won't fail anymore, so update reference output) iotest 066: cluster-alignment areas that were not really COWed are now detected as zeroes, hence the initial write has to be exactly the same size for the maps to match Signed-off-by: Anton Nefedov --- block/qcow2.h | 6 +++++ block/qcow2-cluster.c | 3 ++- block/qcow2.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-- block/trace-events | 1 + tests/qemu-iotests/060 | 2 +- tests/qemu-iotests/060.out | 3 ++- tests/qemu-iotests/066 | 2 +- tests/qemu-iotests/066.out | 4 +-- 8 files changed, 80 insertions(+), 8 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 782a206..e312e48 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -377,6 +377,12 @@ typedef struct QCowL2Meta Qcow2COWRegion cow_end; /** + * Indicates that both COW areas are empty (nb_bytes == 0) + * or filled with zeroes and do not require any more copying + */ + bool zero_cow; + + /** * The I/O vector with the data from the actual guest write request. * If non-NULL, this is meant to be merged together with the data * from @cow_start and @cow_end into one single write operation. diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index fb10e26..e364116 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -783,7 +783,7 @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m) assert(start->offset + start->nb_bytes <= end->offset); assert(!m->data_qiov || m->data_qiov->size == data_bytes); - if (start->nb_bytes == 0 && end->nb_bytes == 0) { + if ((start->nb_bytes == 0 && end->nb_bytes == 0) || m->zero_cow) { return 0; } @@ -1383,6 +1383,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, .offset = nb_bytes, .nb_bytes = avail_bytes - nb_bytes, }, + .zero_cow = false, }; qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); diff --git a/block/qcow2.c b/block/qcow2.c index db759ce..827058d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1856,6 +1856,11 @@ static bool merge_cow(uint64_t offset, unsigned bytes, continue; } + /* If both COW regions are zeroes already, skip this too */ + if (m->zero_cow) { + continue; + } + /* The data (middle) region must be immediately after the * start region */ if (l2meta_cow_start(m) + m->cow_start.nb_bytes != offset) { @@ -1898,6 +1903,57 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes; } +static bool is_zero_cow(BlockDriverState *bs, QCowL2Meta *m) +{ + if (bs->encrypted) { + return false; + } + + if (m->cow_start.nb_bytes != 0 && + !is_zero(bs, m->offset + m->cow_start.offset, m->cow_start.nb_bytes)) + { + return false; + } + + if (m->cow_end.nb_bytes != 0 && + !is_zero(bs, m->offset + m->cow_end.offset, m->cow_end.nb_bytes)) + { + return false; + } + + return true; +} + +static void handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta) +{ + BDRVQcow2State *s = bs->opaque; + QCowL2Meta *m; + + for (m = l2meta; m != NULL; m = m->next) { + int ret; + + if (!m->cow_start.nb_bytes && !m->cow_end.nb_bytes) { + continue; + } + + if (!is_zero_cow(bs, m)) { + continue; + } + + /* instead of writing zero COW buffers, + efficiently zero out the whole clusters */ + ret = bdrv_co_pwrite_zeroes(bs->file, m->alloc_offset, + m->nb_clusters * s->cluster_size, + BDRV_REQ_ALLOCATE); + if (ret < 0) { + continue; + } + + trace_qcow2_skip_cow(qemu_coroutine_self(), m->offset, m->nb_clusters); + m->zero_cow = true; + } +} + static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) @@ -1980,24 +2036,31 @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, goto fail; } + qemu_co_mutex_unlock(&s->lock); + + if (bs->file->bs->supported_zero_flags & BDRV_REQ_ALLOCATE) { + handle_alloc_space(bs, l2meta); + } + /* If we need to do COW, check if it's possible to merge the * writing of the guest data together with that of the COW regions. * If it's not possible (or not necessary) then write the * guest data now. */ if (!merge_cow(offset, cur_bytes, &hd_qiov, l2meta)) { - qemu_co_mutex_unlock(&s->lock); BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), cluster_offset + offset_in_cluster); ret = bdrv_co_pwritev(bs->file, cluster_offset + offset_in_cluster, cur_bytes, &hd_qiov, 0); - qemu_co_mutex_lock(&s->lock); if (ret < 0) { + qemu_co_mutex_lock(&s->lock); goto fail; } } + qemu_co_mutex_lock(&s->lock); + while (l2meta != NULL) { QCowL2Meta *next; diff --git a/block/trace-events b/block/trace-events index 11c8d5f..c9fa596 100644 --- a/block/trace-events +++ b/block/trace-events @@ -61,6 +61,7 @@ qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" qcow2_writev_data(void *co, uint64_t offset) "co %p offset 0x%" PRIx64 qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int count) "co %p offset 0x%" PRIx64 " count %d" qcow2_pwrite_zeroes(void *co, int64_t offset, int count) "co %p offset 0x%" PRIx64 " count %d" +qcow2_skip_cow(void* co, uint64_t offset, int nb_clusters) "co %p offset 0x%" PRIx64 " nb_clusters %d" # block/qcow2-cluster.c qcow2_alloc_clusters_offset(void *co, uint64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d" diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 8e95c45..3a0f096 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -160,7 +160,7 @@ poke_file "$TEST_IMG" '131084' "\x00\x00" # 0x2000c # any unallocated cluster, leading to an attempt to overwrite the second L2 # table. Finally, resume the COW write and see it fail (but not crash). echo "open -o file.driver=blkdebug $TEST_IMG -break cow_read 0 +break write_aio 0 aio_write 0k 1k wait_break 0 write 64k 64k diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index 5ca3af4..736dc30 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -108,7 +108,8 @@ qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps blkdebug: Suspended request '0' write failed: Input/output error blkdebug: Resuming request '0' -aio_write failed: No medium found +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) === Testing unallocated image header === diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 index 8638217..3c216a1 100755 --- a/tests/qemu-iotests/066 +++ b/tests/qemu-iotests/066 @@ -71,7 +71,7 @@ echo _make_test_img $IMG_SIZE # Create data clusters (not aligned to an L2 table) -$QEMU_IO -c 'write -P 42 1M 256k' "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 42 $(((1024 + 32) * 1024)) 192k" "$TEST_IMG" | _filter_qemu_io orig_map=$($QEMU_IMG map --output=json "$TEST_IMG") # Convert the data clusters to preallocated zero clusters diff --git a/tests/qemu-iotests/066.out b/tests/qemu-iotests/066.out index 3d9da9b..093431e 100644 --- a/tests/qemu-iotests/066.out +++ b/tests/qemu-iotests/066.out @@ -19,8 +19,8 @@ Offset Length Mapped to File === Writing to preallocated zero clusters === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67109376 -wrote 262144/262144 bytes at offset 1048576 -256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 1081344 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 262144/262144 bytes at offset 1048576 256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 196608/196608 bytes at offset 1081344