From patchwork Fri May 19 09:34:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9736807 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 3B966601C2 for ; Fri, 19 May 2017 09:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CD4B285EC for ; Fri, 19 May 2017 09:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FF74288F6; Fri, 19 May 2017 09:45:20 +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 6CF58288FA for ; Fri, 19 May 2017 09:45:19 +0000 (UTC) Received: from localhost ([::1]:57515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBeTG-0005dy-9t for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 05:45:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBeJd-0006nf-PR for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBeJa-0006nx-A5 for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:21 -0400 Received: from mail-db5eur01on0113.outbound.protection.outlook.com ([104.47.2.113]:18800 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 1dBeJa-0006nb-3V for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:18 -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=RcXwTaae17+WK3OqYf3r5Ecx9niurG/NM3KK+0a2s+c=; b=dom5FXXfYKFGgiBdBtKJDHNN+xomwKfmjYcfF1lynHncifUcf+MYfyJ5HDJtYCw8eWwz7Yyfs4Tt5hKY4A3mOgtNQ0WOCHmbCbx4qGfbXuBJEtC5wMhGjhS3NogHt74nGrd/c4LtaWgwj4LaJ9fkPKcyNBcF136a33FlBQlVaVI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by AM5PR0801MB1988.eurprd08.prod.outlook.com (2603:10a6:203:4b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Fri, 19 May 2017 09:35:16 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 12:34:35 +0300 Message-ID: <1495186480-114192-9-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495186480-114192-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1495186480-114192-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR09CA0073.eurprd09.prod.outlook.com (2603:10a6:7:3d::17) To AM5PR0801MB1988.eurprd08.prod.outlook.com (2603:10a6:203:4b::15) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM5PR0801MB1988: X-MS-Office365-Filtering-Correlation-Id: f71179a8-78fa-45b7-a141-08d49e9a5bc1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM5PR0801MB1988; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 3:GhTSkt6XxDT9I3CA6AO0mJ+c+ABqk9aR/TyJGMkjMXvGW9z8oRNHbaao4U7mVs0MP7rqcbnPAOuev7lPgsCx0DAt1JVRp8FxIGEtxWBTc3fz+nWPYQ0D2MbU9fYcKRZ5n9e1Cfcvh26ku9pxxT9xSMHHZD3bK+LKg5a5e7jXQSf+MyX6miQkbeWGcQBXQxVEETz7n2LHdKdT0RPv64P4QIkdZsinWzLdt08HQ5abNylrRo7K9ccFDVQ0xn7neA3Z0de2FDZJWG2jvmi2dV0CdED1fbEqcT0BrQYxE9NLGKTFn5XoZTk4KJDfcw3YKY8i6IXqqwnX8wII7NsVPJeYeQ==; 25:cPC+gf0AvtCnU9Gq/Fl/1TOLCXQ26IQUtY2KMejRUOH7TkUE6dAygXSi8I+/BIKT/306Pq3oMHjlYURPBYV+Vs6Y9ahOCUsH+HADg9nX4NmWE0ym0xQwSWIWvotw8PVjtJuWRS9Tq7GDdH6qeDWjRMevneRpemQ00FToXsuj8GOlRoQwCpzyi6OyrdS497xAjl3m0GYu9YtypSiDFFZiz3jsqoiuzpLQ5iBV6y36XZaVd1WLPFWz9ID0a7iwOdtuASa/KPpFDTn6wiBZqo5Z4yhfi61Lw3/8JYA6AgWM0SxDoU+46EEbXf7NR+FBtaK7TIrtS3F9aSCSOO9PMa5bmYXfSRkW6oOSB72XvFue4Q12FoIjkEWCx2QsSFpH2pLADHV9M/wWXpQlZ7LdhbrJRj4egO9g5t60vuDYqt9m4/SP9eRp0yxkDnr124ZYMytHCqfjJUPJzvye/6MIHPHuf7BKSwSawxQuyMxaIL73fvc= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 31:1NatAd5+rZ68W0dAyfWQbXJiQtMvybPHSh2uz9mtgkozZwmixDTTvofKdEdZ0miK6AEwkAS264g2jXUh+Yq/7VCP5qiOrc5W1sCOTSDT9xMYgPCLhsg6ubtEAfQSlgt+NBIE4fYKfw4dxdASkult4qo29/PVaJeQOoX4b8gjGSGY/Ytem5E/vSDzDmqLZb7sjD6PcQIDC8+nCS5h7MmKCDBKN481Llv0jZTD2FF35io=; 20:7c/EIybbfosNZuA7oJAFR00snq6yoBBQDRI78gLrERVD8sEp+yGhXgoR+9cYf6SGD1YFqrvIuDwGHkPjP9x1ZXKA6vgqCs+HK2UEuth3clq0CIq241kuavb7tDAokojYlppAetSiHRaBB/zxypP5xuZnKTFRjr3Gv9WmJJYRLzSJUOhZe3LOgoX8TFVjEoMsn/JYh86HQBO7E7plzxE0HioUwxw+8qZiLLurwkn9/GNMfjHBFupPpcusxRYluYDAoQI48IRnuvDG45LkGqGw8lzeTDk7SFVlnvq/Kw9HpFnXQTjJIMWhXh5EA0iHcSqS/mgCzuJ5Kz1Fj0dkfWxRmXfJcQCT3lAvx6+qOP2JvUFDNwnzFFV5dEhQPpkCUw/j4LDhAnDWN/LKR6ZiD+qyz5qJ9YdQ4XJXEDnAP1JGaac= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(6041248)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:AM5PR0801MB1988; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1988; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 4:1bbJMEk1U+bT1Lw/0O9ceuTOkrwGwvdHimlDx6xOdOsTO8eEvUTMj+3+1PGEvFcyiT6v5/z68Y91QfGupjxj7n0j2IhBJHcicGhOWkVyBrK95FYzo6Bv1DZQJAWhgLdGjr/tgJR0sSBWI9gXbn9j4UX8bqtyeohB9NTXhCdUgJICbphdulsOrkg0+mwcEbAUtXae2qYa9aB3Z/4RqvUp39OmiMPWvv7DJ0CmWubR1CdpCEn5Bkpd2pI2xyjGLw6JaANyL46kS6ryNH6DXqqTSSiTmZraY5L3SIErO2Srv4+g1wB7GKVFZRSxvSP3sZbfx1I1SRZJZBX6ufmQGIUZkRmYc96kSZZ9Hw3uSBNvfBQJHb2pLgQVR2gqI7Q+VjNQzVVeNZjJ2H36/+nhgIS+UXm/rXQgIhyy9Gj+C2GEIiG/0+Rg7BuNFZVTDw7H+n0Wi6WakhtaQGHyb0RtNMC19rwyThNPtTAK2Wi9K3pG1y9DTD97JL+F48ctbvhMvQH3OFpghCyJ029PqFhwUw9KH3N7zrD67m18cJIZkurn9tX2XduEA2a6+8D9Cz7tIVW6M6vEk1EJrC4mlBGiJXvFm8Cq+XHLnQJ1ZhG63g/d3G/sOF42/PKo5xBNYNFaQ4cjkbEDMKInYOs8Dsc34TYnNZgY2CPqwtsXZVqfgnUolQHtmx2Xvx3XOWnIXjpV/fQ7BFaZLbOqlz7Fon5t5PNUkIuxexUlGtAFWhIpivUwHiCdq1rcca8y3uJlGp+TTZ4nOSidU3cM7r4XR4Y6K1YFEgA9Em1o94xcnThw7RZM+qo= X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39450400003)(39840400002)(39410400002)(39400400002)(48376002)(8676002)(7736002)(81166006)(53416004)(305945005)(50226002)(33646002)(5003940100001)(42186005)(3846002)(4326008)(25786009)(66066001)(189998001)(50466002)(2351001)(2906002)(478600001)(6486002)(6506006)(50986999)(575784001)(6512007)(54906002)(36756003)(5660300001)(86362001)(53936002)(2950100002)(110136004)(6666003)(6916009)(107886003)(38730400002)(76176999); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1988; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1988; 23:0TVTkgieQCkCqnzedUULziEYhV70RM8AZUxium5?= =?us-ascii?Q?UMgomEg3/tST8zui9ISFhUutgKPvxaYe9BJ/vypGQvl/0s4Eq6SGKv60/IYh?= =?us-ascii?Q?rt9/MM+Tj1nEnTwRQoWZrJeRbK/3EooRF2z+7Y5sX4AGALU1nNAEyk0CgGMN?= =?us-ascii?Q?64GTD3Y4Yi7OIfZSM93yYYZcXWrl4oRHVcrLeggpWDFU66BCsOTOFFOepmxU?= =?us-ascii?Q?Ak2NjKi3nKceqAYbc2PXjzXLkdxtZ3jTnR729J5CiNvx3xDfVoyEDBxVwC6b?= =?us-ascii?Q?iOH3LpI4k5+xZXJqGXmmI86YxM85QjXoWDueCW8jr2/B1EFqpxFH7+CDu9Qc?= =?us-ascii?Q?lW4/YZq3NLIbOE2vXLm6ZhrUmOjv4SdsrIpkQCJM55QU7cqMLnVUh2eQ24Ee?= =?us-ascii?Q?4Y89uaQbkU6XBe8XwKManYalpvbmPA3rGPQI0xytM3GamRsUFx8/Xu4vdPrS?= =?us-ascii?Q?1xKFwyTnkJYR5u3dZK8UbyIcbUE4JYi3uwW8ifSf2LnGZtqk+K8WYVhn0qYK?= =?us-ascii?Q?TApaTL1zWY3xtLIPjmPr2YXHNUBZL/QcXXDLUznfR3dxzRbuTWyeMrJdhn1x?= =?us-ascii?Q?qKnjeXJ9v6HbQutF1YzsJsRJJLuz5zsoTfopAWXGLjA2CHgzg6wm3QGxt87N?= =?us-ascii?Q?qr8uGQ9Im9MJ9qNaz2pB/cuj8EuxEzSRblVjdvdYIqEzWmjgfVk/nAZdvwob?= =?us-ascii?Q?oNQeHqXWlCwYmN+3KFcwhuuFoNHCiD1lMiCV5gbLlbXYvuNRNtdaATi+7/dy?= =?us-ascii?Q?/JoexOjlk+mGPSkgkjHNNIpw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WEAaKTL5sdZc074GS18jRqnA==; 24:87I/y+iGY9+x9UEtjG1cS69r3e12ON595yH1iuUSys0k/AvwQPijAxM8XVI3EcqfGkFMgcNeQjPi+YlAgkUEMzZEWAxEYSq+MjFM4yOBArc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 7:TzV6GlsdcTbr66yOCe7zUWAhH9ds81XKyxYl1FSz+tIly8WSR4iaw5bmd24mPWZLr4LxjNkqQt9f3bSQhMNhNpqGLLwi7Jkh9fyA/WDj+/ezRBcIM4lqg76Iv5haoD5Fx17xkxyIjRWzlsJJbtE6cmrnUFa2RWxb+qnNkpoE3wwMVcTSj5IxoKo2dMWkBiZq8MXhrNRHZqvnmYWoJ92YZ1dw5Mb7tFUeax8e3TFYOzE3KWN/fRmfdYy6WtrTzPrIpSRnJOWS3TpSb5L8+1xYUB7mketgU55QxHS2dmtLsKVjQtGw+qrJbvJ3ccwinniKAyTQdO6wpOY1TVNdZC2t1g==; 20:z4DieyxMjcub7BVnv5pV1ArGyaRimAxLnJbdA0i/AWdVn05uJvATBV/GYCkLMukxFg/gxDqNF7r7Bp6OPlghrxYxtAouzccttf5+oueXv6V3p/QVoxo+RJm0x2BZpYGj1ohXrvKunVvd6t47/C5Vt80yAMQ1AMyGTMRcCX+PaIk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 09:35:16.0845 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1988 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.113 Subject: [Qemu-devel] [PATCH v1 08/13] qcow2: handle_prealloc(): find out if area zeroed by earlier preallocation 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, "Denis V . Lunev" , Anton Nefedov , den@virtuozzo.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 Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- block/qcow2-cluster.c | 2 ++ block/qcow2.c | 8 +++++++- block/qcow2.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b2879b9..25210cd 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1143,6 +1143,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcow2State *s = bs->opaque; + const uint64_t old_data_end = s->data_end; int l2_index; uint64_t *l2_table; uint64_t entry; @@ -1264,6 +1265,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, guest_offset), .nb_clusters = nb_clusters, + .clusters_are_trailing = alloc_cluster_offset >= old_data_end, .keep_old_clusters = keep_old_clusters, diff --git a/block/qcow2.c b/block/qcow2.c index 503f0dc..97a66a0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1684,7 +1684,13 @@ restart: if (end <= bdrv_getlength(file)) { /* No need to care, file size will not be changed */ - return false; + + /* We're safe to assume that the area is zeroes if the area + * was allocated at the end of data (s->data_end). + * In this case, the only way for file length to be bigger is that + * the area was preallocated by another request. + */ + return m->clusters_are_trailing; } meta = g_alloca(sizeof(*meta)); diff --git a/block/qcow2.h b/block/qcow2.h index e28c54a..2fd8510 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -333,6 +333,10 @@ typedef struct QCowL2Meta /** Do not free the old clusters */ bool keep_old_clusters; + /** True if the area is allocated after the end of data area + * (i.e. >= s->data_end), which means that it is zeroed */ + bool clusters_are_trailing; + /** * Requests that overlap with this allocation and wait to be restarted * when the allocating request has completed.