From patchwork Fri May 19 09:34:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9736797 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 7F4F26034C for ; Fri, 19 May 2017 09:41:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8086B286BE for ; Fri, 19 May 2017 09:41:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 753CE288EE; Fri, 19 May 2017 09:41:47 +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 B6C76286BE for ; Fri, 19 May 2017 09:41:46 +0000 (UTC) Received: from localhost ([::1]:57494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBePp-0002WH-0c for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 05:41:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBeJV-0006ja-5P for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBeJR-0006ki-8N for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:13 -0400 Received: from mail-db5eur01on0118.outbound.protection.outlook.com ([104.47.2.118]:9856 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 1dBeJQ-0006hy-UF for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:09 -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=LqtJGjL1Ekew8Sf2ltvs3vuPpQqmcx1KVwUgdsZCwXI=; b=Ze4GKv4tMZPxngqbWKvlRFcc1y+e01rrM7K6tbEnUnNNUHiWyROXq7M9YTnhxFSdf6m6HGVX0Ro7SHIMO/qCPHMMiFbgBFpR5DiiuqOmKxhwbfDJaPA0fY2PObVPSIP2GtpIV4sWoXBaFjRc5SDfNc+nCh4NbPeKXPzIn0eRLqg= 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:06 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 12:34:29 +0300 Message-ID: <1495186480-114192-3-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: 2089a94d-5996-429c-00fa-08d49e9a55eb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM5PR0801MB1988; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 3:4aGbjq5WvoNPEAVTDPS/Qzc3dVhZHyfQe65rnyXzUxE0wtuhDDOmp7L8R/ib0YGTWUZvxpj7e2/HXYeOfkHbK4/JhMXFvGFpWAiSibqJV3kw7qCp95pxeTH0OQy42rcO0B66T90cc7s9vDHI+YiY3BLeDw8aR0RhOupPspR+zgeljsCRRfECq5EZkun4HUvjZbLeH7xrmV1Ryap0HmUq9msJf1od4mhDMc5ibiFqsqZfMl9405vEW5NYpEI+eb7anzuZWBhqOsZi3r1/NVoTY14a+518LIrHqNLjRwqS3dM6XfOAs/Luzy07YKH91xkmgSLon8x8TF6mBGmd4zCkLw==; 25:6xpRlnr78/pZT2raqPzoPHNBibQzO5aelX8q8AECI2dObR/TELsrsbxrgFig//LgpQjRqsYLnLoWWH9gbS/9ieXagY+NrgnjPI8Nf+qymmLAUxovz9mKAy3t7gRiA5f5R5d+7CC0T7O7ifnTuX7vZPYdlzPpAHZ0ZHeBg7OFbZbFgJ7T9U7XTGL9wMoP10TD/SnYIneFrPlJMPsyFxCsIbA/ItYXOCs0852rVWsh9jAE6t69ghlv2cMd/Ba+3YXnW9baQOFe/ir0gzTyv511PEVVBTSbhzs3OaYbFU79X4CpjYualfNRXyrtl1Q5XlW9zbnM0nCUVyX1ncu0zeh61wX74dRDAHmn7j7X/QUIhDyFz9torrBxRxKR0K7uoigNsIwvkCuXA96osnVrs6qhBv7IiA3p0T+GW2AhCbNckb+d7JfzuhdE6BluEVv5BrH1TwWQ93yj44rBgd1UCiLec+DE7MCmfdeVlqBiLfv2uQQ= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 31:x2Ysg57VIxhqAV7wA/ywFX6NmUcp+IjlLLtLXlGTZDH4PtS952/d7+BTd6Ad6z0b1fvxnuonqnFVrTzoVjDwKNCELZtp4KILGi7ZgORdVbvil4vwbTmIaEPqkPXORreeMCJoHOulpEfnnVc4kvyrMSx9xB6mH6XEE9Yyr7yKRehsinglGHdaVLqukcgQikhqm3+OxN8AYBgGWtOq1bp8UrtL7d8fJAftVKtXuCkgapZVxtosYpU3uzdpzoVBYf2T/at9pO4vURlcrV6k2zDE7g==; 20:EnyhVaqHK7UfB4qxBnINqiMHAUDQsFOpby6ze6zimlbyvdYPFmxTPe4nR0idcdjCEzN8afUma1/g3X0AUJ6CrOBbWV0JDfYzu83mjiYy86Uk8HAU6KDmrZEFHoPPjXDUBYCuXco+cigNnU6LOIQzBfZIgrkTmKQo3ZrHECIVZybj54nSUsuXZWAp4CvU0u/ofIvdwHXPIodxKNMaHLFL0wpCJ+6/F6fWzxC99GOJwQSgWJ5Jp+YwOQo4m77HEk3GJ19KrFItmogTagNcOBes/VYkWmbr1Z55dKfKwrD7kwSAILvNk4/ptlWb9jTJBOyX8gbytgkWlJ6ljD+Zy0naAue5vEyLzxvn63EOJevR+NxEe/g6A7ehXtWK08Uo61AnG0cBbu0eckUwzMgZxKZ7NJl40qFLU/4sUqc+AItxUKI= 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:/30/BE2jb2gai3ftfE4WwkyDr5OZIZiIvCo4nEcqLXS+9O4KyKlbzoBYIfuQjMuAkOTa7VsZ1ooR+Xc8kgb1tD32P9NfyXoYf1k2u1wXsqq6ByRT0nVCFwigSjpw7OX5FskF+1uDpnbzxn9YnWa02IyOyDHbrL9zVmx4kagUK91j1jzyKgUf3gxEBj1ZmNtOMQ2SjeQaenKEh7D79wAoeeTH9Smiw/tns/zrjtSJ3xxDrl0V7+j6gbuRcTtcIbojbOFZrM95eKzWeUI2eTT9sOYycBoMgXGwD9CBSlZ7f3YDKUi0jF1o+WiKXC54jwU4Kg3+IbbiMt1LxNOOGLCi9k4oHeMAr0Sthg+yokx7B4gPAcCFT9GP9yK11r/yT3L6UR/Ogo0i6ijCARB8gdPveAd/43MUZATvXPB0r6cenoQ5WsdYHevam78r8yqw+tlJcBbzXS2htUC97F7S7JLpp6dFYtNduhcc1lvdGnPGkSFfwzSGSmzRLHBYMGEOo7crwRA+xv6JHOVGXxJOu8G2K/mNvvuGERYxYL2HbyDvhnndJT/o6n/M8oAjqW4CLYtgY0DtlLgrGnXkNZJm1MtbHgdhMnCtd7/58wLc2Qtat7qZAWs0Jmln6pXkXblgk4cW51WoWDckpmwd4dI3/F8MsJN6aEmkoNxAl6t48pG2hcHmmC3ud+pv5fNlDdrn4pkwMOVm9w9HjeG5p7/AESYhY9ai3zWH758cMXoXN4BcJTXsPw4k3pTfmZhXAr7KIVfpvrBddg/hM0REq521zuwqAszfBJ57mkmm7O6s2AvZi74= 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)(21314002); 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:1DEP6EUIldErGrBuLR4o+w5CuB76Fov6IgPvjkN?= =?us-ascii?Q?/xjMC8TNIf049lcz20wGm/u4kKXtXGLUKdICtnYs37dqjY3TILWxoauwtw6R?= =?us-ascii?Q?2IXyAlP3jaE5T0TULaW8phJkZJiC73OihsZaDQlqfYqzC41B2iGShicKm8R3?= =?us-ascii?Q?UhXnfBhR1AKVLESJGCUz4TC9ZXqNW+YzK5V8NYuZhCwJbMQ3nKhd0Pyp8kMj?= =?us-ascii?Q?W5DSHYIvcO3lmTzXs6O8HKSYm8QHP78uHxIiFT7COEMA/4rSKslSPGtzTW/7?= =?us-ascii?Q?LZmIsIbUbuQo9Oa6h1LmoPs6J46Md1Y9jo+HfGRtIRGzfvSQzCbOP7gmKM0/?= =?us-ascii?Q?JieBN28k7NtMsKeWuxh/4EUWhKRbcFAsUWrSpPWOlax8ck6Vl+3vlhwz+1Sp?= =?us-ascii?Q?H18IVxPMkxZAm9xKLbO7xcUstK8Ac9zHQX9tehyaKBfnhojYO9KIf9G4acHC?= =?us-ascii?Q?cBtG211mAP4dc/+q6AKLIKhX4XLy2R0F19T8On5GCB5cuXJ7DIAWsLn+/VtB?= =?us-ascii?Q?QA5T9bMStK8omGpdAYUfL23YrUOcT67W2EkSn1nYpJ3/Nz+50yum03HWMbBY?= =?us-ascii?Q?mu9YLx2KpHH6UF8d4Xcit9fP6N8+ellVsQexHrnZiMtwN5h+ONNvx56Wq82n?= =?us-ascii?Q?oFfjyay3atdb5b3UBgJserNXLQu4/0YpOUYVAAz95SJ/10bBZXflusK10lzY?= =?us-ascii?Q?v5BCZVdxsQ1fv40cvhYDlQNZD8awU1U9lCYcKkYVE0kCYW6d2ytScWaLZxEv?= =?us-ascii?Q?uHj7FogxAZBh4oU2g9/b2q/AkrqXGpkv1PKhR/9qGuuZ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wpJPNIDjJD+JNLMDJyTVzz2py/OkfLx+t3T7IDpw==; 24:ZOEzmBEFLfDN5Zp0e97J+BNRm1shMgkkVILjPt3yPQ9jUrAHJBAGtVWZ4mdDlNRZzt0VqzjDLyiT75AWK8qFQMSwxY+bhfjUbRsSEZpGGHY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 7:TkSXY1vH/r3khEPWzurlQ+tXyCxQpRcpji65z0ufec9EBQc7hkUJv2IReKI712XkuxQmh+Ev1LB3iS6iMuoswBArB5m6713w9VLZoxIrtfEdXOiIhFno1J8Lwmmacoi39mMhPMCVq+FLDrEAMJmR/GS9jUAEPnYJWOaIWy4bkIgf5NE3z7DAJScOEV2wQm4mbOZzlp4QBV+wHw5pBwIA6jZJvdFCfoy/6ZOOioaVedhHTbdahFk8wclcz+binur0/Zd4dzCT01JBdYb0RnaMW15tMRayQglM1ZdoE8hbhmngv9P1V85u0aVpYGURjb9cG/g++6/a2zjQT1RgO7wlRw==; 20:8IqLJhObr1/dc9PcxNGEgoRWBF+Geo5lp/g2BfiWI0w+fklQgTTY541sgTk9DbSQ2+4+3AMOku9VawZNFhEE+KeCIJlb8hKATiUs7JvbMiIWR3pcOjioauEsHsWQCse+6ubGVmbmXr+ZHuO1Lu07XKaOG/b5ZZqCOt05/J+utAU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 09:35:06.3724 (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.118 Subject: [Qemu-devel] [PATCH v1 02/13] qcow2: is_zero_sectors(): return true if area is outside of backing file 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 , 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 in such case, bdrv_get_block_status() shall return 0, *nr == 0 iotest 154 updated accordingly: write-zeroes tail alignment can be detected as zeroes now, so pwrite_zeroes succeeds Signed-off-by: Anton Nefedov --- block/qcow2.c | 6 ++++-- tests/qemu-iotests/154.out | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2e6a0ec..b885dfc 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2482,7 +2482,7 @@ static bool is_zero_sectors(BlockDriverState *bs, int64_t start, int64_t res; if (start + count > bs->total_sectors) { - count = bs->total_sectors - start; + count = start < bs->total_sectors ? bs->total_sectors - start : 0; } if (!count) { @@ -2490,7 +2490,9 @@ static bool is_zero_sectors(BlockDriverState *bs, int64_t start, } res = bdrv_get_block_status_above(bs, NULL, start, count, &nr, &file); - return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; + return res >= 0 + && (((res & BDRV_BLOCK_ZERO) && nr == count) + || nr == 0); } static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, diff --git a/tests/qemu-iotests/154.out b/tests/qemu-iotests/154.out index d8485ee..259340e 100644 --- a/tests/qemu-iotests/154.out +++ b/tests/qemu-iotests/154.out @@ -322,7 +322,7 @@ wrote 1024/1024 bytes at offset 134218240 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2048/2048 bytes allocated at offset 128 MiB [{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": false}, -{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] +{ "start": 134217728, "length": 2048, "depth": 0, "zero": true, "data": false}] Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134219776 backing_file=TEST_DIR/t.IMGFMT.base wrote 2048/2048 bytes at offset 134217728 2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -348,7 +348,7 @@ wrote 1024/1024 bytes at offset 134218240 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2048/2048 bytes allocated at offset 128 MiB [{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": false}, -{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] +{ "start": 134217728, "length": 2048, "depth": 0, "zero": true, "data": false}] Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134219776 backing_file=TEST_DIR/t.IMGFMT.base wrote 2048/2048 bytes at offset 134217728 2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)