From patchwork Fri May 19 09:34:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9736809 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 D73DF601C2 for ; Fri, 19 May 2017 09:46:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D84E4288F6 for ; Fri, 19 May 2017 09:46:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB7CB28904; Fri, 19 May 2017 09:46:53 +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 47E9B288F6 for ; Fri, 19 May 2017 09:46:53 +0000 (UTC) Received: from localhost ([::1]:57526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBeUl-0006nP-UP for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 05:46:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBeJi-0006rX-0g for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBeJe-0006ot-4N for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:26 -0400 Received: from mail-db5eur01on0116.outbound.protection.outlook.com ([104.47.2.116]:14269 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 1dBeJd-0006oZ-Q1 for qemu-devel@nongnu.org; Fri, 19 May 2017 05:35:22 -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=WLysj9Mdd6U7h6/5A7w+Gxyr3mHjtrVZeIfZxugRYF4=; b=X5NHANXYBGGPW1BBK/ReljUwrQq+JxRDM0Kgc4kE8WQgXNn8M/lJuoyYHlRYkYgCLe0gx5Mgs/+qv3VfetDFQwVU7GeQyNS7URGZbCQumifZnUf87T5XnXEdYYTm7MArKiq2uh0JWHjqO57nZgm1w2cSY4tUNnb7ZjsgyoA4aQM= 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:19 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 12:34:37 +0300 Message-ID: <1495186480-114192-11-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: 7c2aa04a-c88a-49ea-111c-08d49e9a5d8e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM5PR0801MB1988; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 3:aQBanL9+wsh/gqb83BDiRpnmkjBtSsv/m1BwXxFMnmsRcdlqbUqVlbdoS0K/KyIXMXroq/fctZhiiTZLug+AABqqwCQRqhu1RlS2dosu8s/7ZR/HpX1xAR0fe5/84feAz8n2Dp2/mYeXvQhqd28A1aCEmY6XGIGuIY4otKvyHFVv5OLcrPmej4KHhNd+/4FuenP1f76g7PF2HHe/caL1JD1LXWubwdJ2H0R5uJ5U8VzB8Iv2+8uSV301ChWdINfHyTC7t2UcSvj0gIWUhf74Rhc61ePAC3VPJ++3KI9uyJ6JOJXvS3Jwbs1y05wFvljkfaE/IBu245N7htp7xLBGJg==; 25:nwJf5xtWBFHz4B/NnSplG2OWfgYyBhISaMT1FS23V0zN70G75vGbq8cYxyGbf0h3wV2xstcmAdnpy+Z3aF3M+/q0WM/SFSd7z1oFvY88YpFekE7J0AteH7iAMWluZsGEuF+CnD16Hh1MZX4wzuo+pN/ckXWADGTlq3tyacCgDXhr23+hgyJqAx/qsiQLDDz9whUUeVlKtR2jQTY0HpsluBPJr4btQg9u1SlFlwg1QaAOyZVWR7p8rhSFCTTkr55HeBHvRCROfikrZSbuoZpLC2qczHua3y/HQp7KrbcbVCZTkBR/3eTWzriIsE/SWxzQI4lB4EzNU7Ex/F47+TD+PcoZ4yfUr1rwsvpgUP8nr9WN8yZUvVvhhalmwtqva99eBLnXFrRRihqZd+U+gAk+KLwGXXcEjQQTGkP565GzYO09kowyJsuOvIZessy7QvgAMACio0Oie7Bhw6C/MVxWhjqHAJ/PQSqqbNuVCksvD5k= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 31:Cshd6At8ogW9cA9BsEdFlGcIJubDaLa9iJjWpfhvw2Er/gol3a8rQR4BAj4XmcGfGi3TY2ItbhpgLaha0g21TVP5ELuLPXtiV0uAsTWhG7vgdeDU+A7qFdq2Rm/X6OI34bE1crmnxrpgpqkGK6vrXELHc1FypUqVYQfUsGI/Ntb1edyBxu/iDaCl9nz47yI/KeKmT74z58nJ0SxwLYlTpl7SAqU+ZA7oUXsLdqmFnT0=; 20:3kbsXn2dam717USYMWNwSg0/tmmSR8ez1RJ2sL59lgbAjXJ9uq89QH1/CRn/CcwXqv+4ML/X9GtnhMlNoTS6vM/E0QhMAJRRB2bj94bwm7NjHS3cQZ8YFz3eitjJE1BlXHgPWqLWhvds6OFlW4ToBETfsi9/tyryCEK+pvoCIvmEB8ElcRNTsSdIEURaWNToUT7PggCb1XRlDDj2F1e4ndTWw3bPEC7F9h/WiFoqa/iR3y1RV3MKPv9MrHpdlLYemEmYIZ5jhOZEzMvR3mBKK4hpiKNEDpfH51ieL922Qhp+Gp0pjFg97ln9NCSQbdPIF2RLcOegC1XW65FUYU91PSarWH4Rc0/f6lbibBbYcjvoELFpEpu+72cEycB7oDUZvBc+24hj+MKCLA/kdL/yfwByKEqM9UvN7eQ3YnI0HUM= 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:e5+J0FGvr2akvitquscdhOkpxPly/Yd83vm3R0QdL8kLBsLlEOnIHVjG7wj27s2YrZOq1RlV9AnJHfPekfMvMCadldyuky/bEwmMqcAVRR+BPKmYKLLg6/LKSDe9d9lTHPSD+ZM+eW5VIn7PJizM56yrAzU2QuRw2KXMrkL4ndA6wX1iM9ShmMFyCXFB4YSS3TZEI2z6H36tCsaJogjuUrhTteYAmxvI3GoCjQ9qsp5D4aRMXGtGh5Gezb5OPJh1Jn+/s5cCY4p1r6oAjDp+AfwmX4H9OCGGyTvgpLD1TSbGxmG22hY01L4vbOqAfYNp6VgzgTZJNp69F9ajXUuRnaO9JnnngV6JGtvZVWak6zKfHGHqItEW7ZopM92AgvSzGhIIoLRn9q8ZZJioFulZ0g5El8Wj4pHLj7FD/pBVGjBWZx9NMAkrTlKi0S4DRA9EaLkLqrT9GT4akVRTSHuPBul05UmYKmAQG1z+vXFeTgi4hYtoSq1D155W48p/EI5jaFCek3u6prOdGinZydMrUDb1+iV8B5faMXpZsHJSJf3VcsVgNFKA8DMZ7EOZWlu9U7qiIuiCm89lmgYgAz7XW+VN7Fqh+mdk2f+I6KweZW/PaEUD67u8ggspvUqtNvzEdslan3zdk/gjbr/b8RAOf7fnDhcyQN7XlRDbkIWGQGoZLjHtt+I6dMw8fKbtFt/CepPNvvEnLZJ8B9JGEH4GfP70kO0aOMLEdM4Y3Y16OyvN3jpX07wT8YTdmGf83zaXShUTTyX47t/WeAOquPCAXPCAfP6xyexIkug4mzwAarI= 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)(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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/ZLhMxNLw0OjeeRT07gVp5RchgAIF189MCSVzOpEi929/XxcE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 7:ra1YrJSyq/Xo4gpx8l3V7wLtnrBIczw541pknzwFsazMBK2DlXH4fJqkE+AZHl4L4gnxtEDm4UuyzgvrNPdIspVMRXGJCYpZByVbjofRjc2YudTDMmSgbViSDJbli65i6fNniE42Bhkd2zdnMfjWHX53jLrm1dyZwP6NLoVV5SJgXS/vZBfJRoIjQjljw3Uw5IAUVZo5u/2lUwg8P0mIbnPTSjfPvfwsiLCFV+lQ7p43vFG1tgQBdH/t5kUtFA4tIv5WaGhmnZPGymvgRf4yakJkeS18/zIAceqfd9rVEFCtkkbiUebAvG+501CQAq75grVG88ExQMLNd/LTehLJGw==; 20:8YmzPUeel/mqBmhOpXQY13xij/1i3uaujcIpu8vIRPB6ffUowisYqmAEHjWP7HwxEiY2No2W7/PtRtKs47jfe9Vxo96feQ8YMgdnfQdUk9veFHfAQy2GnoetxlHFM2vRc+Ul0JUsD5P2e0f1sBj6tvkVzPbBx+pRApnbTry3ogw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 09:35:19.1020 (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.116 Subject: [Qemu-devel] [PATCH v1 10/13] qcow2-cluster: slightly refactor handle_dependencies() 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 - assert the alignment on return if the allocation has to stop (at the start of a running allocation) - make use of const specifiers for local variables Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- block/qcow2-cluster.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 4204db9..03d6f7e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -900,15 +900,15 @@ out: * Check if there already is an AIO write request in flight which allocates * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. - * * Returns: * 0 if there was no dependency. *cur_bytes indicates the number of * bytes from guest_offset that can be read before the next - * dependency must be processed (or the request is complete) + * dependency must be processed (or the request is complete). + * *m is not modified * - * -EAGAIN if we had to wait for another request, previously gathered - * information on cluster allocation may be invalid now. The caller - * must start over anyway, so consider *cur_bytes undefined. + * -EAGAIN if we had to wait for another request. The caller + * must start over, so consider *cur_bytes undefined. + * *m is not modified */ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, uint64_t *cur_bytes, QCowL2Meta **m) @@ -919,10 +919,10 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { - uint64_t start = guest_offset; - uint64_t end = start + bytes; - uint64_t old_start = l2meta_cow_start(old_alloc); - uint64_t old_end = l2meta_cow_end(old_alloc); + const uint64_t start = guest_offset; + const uint64_t end = start + bytes; + const uint64_t old_start = l2meta_cow_start(old_alloc); + const uint64_t old_end = l2meta_cow_end(old_alloc); if (end <= old_start || start >= old_end) { /* No intersection */ @@ -939,6 +939,8 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, * and deal with requests depending on them before starting to * gather new ones. Not worth the trouble. */ if (bytes == 0 && *m) { + /* start must be cluster aligned at this point */ + assert(start == start_of_cluster(s, start)); *cur_bytes = 0; return 0; }