From patchwork Thu Jun 1 15:14:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9759867 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 3DEA260390 for ; Thu, 1 Jun 2017 15:23:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E294284F1 for ; Thu, 1 Jun 2017 15:23:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22E45284FF; Thu, 1 Jun 2017 15:23:10 +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 9B5C6284F1 for ; Thu, 1 Jun 2017 15:22:59 +0000 (UTC) Received: from localhost ([::1]:45210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRwA-0005nZ-ME for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Jun 2017 11:22:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRom-0000T6-DY for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGRoj-0004nU-7q for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:20 -0400 Received: from mail-db5eur01on0122.outbound.protection.outlook.com ([104.47.2.122]:10425 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 1dGRoi-0004n4-T3 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:17 -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=Bn5mHdiM9c6Je1KgGWvpnXjzTZHTCmJLSBllWsAP+64=; b=gIDeDDJsrp+JAOVZyox/HbEI8aiCey39rNnvxTRJ/FbfhURVEfuH0FzLYbnsgw7pqthc3Z/fyzqXd6KMPjOV7vAwLPMUTF+81lOUX8cHUXs7t0UGquPow3DcqC6v9O9UF64oz4VAWvPFyHOsz3xnjMTuA2oQctt1ARZRe57oH/s= 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 VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Thu, 1 Jun 2017 15:15:12 +0000 From: Anton Nefedov To: Date: Thu, 1 Jun 2017 18:14:31 +0300 Message-ID: <1496330073-51338-14-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496330073-51338-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1496330073-51338-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0005.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::15) To VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-MS-Office365-Filtering-Correlation-Id: bb8d6b6d-cc0d-4586-f0af-08d4a901009f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 3:uMRdQpn6s+l6nn+f17Q2zlHu16z8cNljwA4UuAL0XTSQdR8oS8uvRPVE85JoiFNOZqmMlMFWPeyo6YInxvTFtCEClZFEN5W9yDbtqQOOtz7BLLSXL17v9ONjsmB2xMWEigXXD0YzBd5RY0X5lrUxIryGEx9ow5v0dTsqT5oL9h80M94PqlccVTvOvcmMMD2I099Y2utQQO3P1n1iTE6jGrEgDsy0RM1APc+GnGG2KdumQChJY3nT5d3xs56M74AJ1TPZox4cj02iNT6SuDngz3c443Mx0neOLSpiHtVRpEngnd3T3IzpLvVwtqtYE/tDO/axim52As7o9ac0f+ATpw==; 25:paWCdfJdgi5mRU8ROD9+e7TX6dPlx+gr7CGkAo2r3cl6MP/emojeqfJbsI5+X+jIhaBwr12zaXud+/1SMBhKZGLqS4R/sATFstq7YQ4Qh95CDlIHyzUQUCZ4hqu7GBA4EgTRTQ/v7T8iFwaAawSQgrlrt3VyhKse4wfyBgqOQoMZWVbFSAfTR1scxHM3az7Bv6YeI9yVX4kY9F8G7FL6kPR0hIMEIlw4gzzMLyloYC4cihUFjgoMoBziCsLTbdCOU3NuDsrlpJkIX/eJzb4L0zKaVfyWBTnk1Art4FiLLSQsAHvxEISPgRLsOkgGdWldjihMAchvdIOpxmiCp554DnAox5d217Z/kivSs2U4MeFjJTfbQmU9OtvN7Ak3IGQSgEE83QSe2nbo2ctDPm8fjinxUqmrfOt5VwRfHxk7i3UKrRsMbNOZUUsRfe23J0lkkG2WcYDnBWh8lwCrLlGjejYvcsHbfVgLgAtqziYtQU0= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 31:NLaPUmiKKSbDbOFS22roQNwgPUmAANkRAN0pmVtjzLKndHvPu6WbdgYqe6Hm5r1aWJlaJtLYG+HIIYswQtuR62OZatcjgln05KB74uV/tRJTQxEMHn+cfr/RXiWDd8rKCJ2N8g7a9kLsQriwy7jcXN8ECU4lnu4EJS1UCLjunAQul3tWmWyODKjtb83n8LL3gJ2SOfv03dca/M9ePwXfpWMoW1198VoGjoMCR14JQi6pdUGB4PdyLe5ancCvVBWLzQ/+4oNSevxM/IcJA4ivEQ==; 20:g3ZcVSOY7NhLCl05f/12X3Z/U57hHFvJKRL8PvogbdpbBqSbeUajUN4AfnP7lEHjKatKCgBOqmHfEiLdr/D+sd3eGkLJ/bGP8Np5gnrmPENFws1awPnzgZLtjW2/R62vsVqq0+UCtvHL3sOqiTq7o0FWg7E3lEFnu7vMYBuzEnsgzdwIJlCZn+CLR70TX5HhePGgtZBCC9Dv6YyTwiQXUWuMkqNmV+5OqWKgE+WBeGIoVcobMpG7GUO+kudo04A9XKwHbqP8tHwzL/IvyUtr3iOFdCRvJpum9MypZl54F7xZdwioKqqdsyBhKe9GdOFzQFQCEh+SJCz7GY6godFv5XMi71ouFbbxZi9gx3lv7nJqz3p5GvdHpeVJ5nlvUlfcdGhPQji2oNkJEXeYRlqzxDibH+J6nBkj8Uw8eZiKjnU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0801MB1999; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 4:m4U3t/3YN/CX4rabVh//iMju3lJtJbtm+aFb0pTQ?= =?us-ascii?Q?hNeHKx+6CjnhJZbDH7rw/Po9YTjDSYyEgIofzZDWcwvmATT/TYtO7mhaAzD+?= =?us-ascii?Q?ok/SJg3FKzFrDy/F/Sw+OMmheTk2O0KCCuw1LzDMHrD5bSO4niJ3d02zTsDK?= =?us-ascii?Q?5zD6N3oHZ2rVhits8p4K6S29PjPvzfsMojgfDJ4y+kkFb0PnIhl4+0mrftAe?= =?us-ascii?Q?CIkHkcgz7rggW0zl20UjiV4zo+S1OjfHsj2HeX/rlAwR17yNsCweqozsfsos?= =?us-ascii?Q?D5QADL+zNQfP/GW5b91AEG9EG5eqYgRkG6DQFwOUkaDFv5Ay9AponSlHpyZ9?= =?us-ascii?Q?o/QEUQkp/9Ma01FaXSJ6mL0HGkv+O6rwwCzke2F/47EnUdn3NpZV11gXEndC?= =?us-ascii?Q?aDy1B8OgDwBurcXnE7wnseUupiNtGCNHIBqzCJUYcIr1k7JBIF8dU/9Y7Y+t?= =?us-ascii?Q?f4bhnXyEJiLNBTRirvruzGh8L/OnRPEFxuFhNIELXlzVawrVFXTNiZg0Yk6W?= =?us-ascii?Q?Dv57t3se905MZJSnwkDWa2UgLVn2C8CcMJEqnjs3E1liw9SVrkQo+Z0fHoch?= =?us-ascii?Q?UthL/5HPZ/aZmkS+OUTWF7nIrAVxDmmwAKnQEBOsnAg4RIuy9i5wWrHpbG62?= =?us-ascii?Q?AB3bLadiLd9PH7g1XQ3wSE6+ma4pgI+7W6PemHFTEmc+QelWZo1eBfkta4lC?= =?us-ascii?Q?4WwgrRD8go9I0m8U4H/NekPf/Eac2ygXF4K27iQQp2nEj1546O9r8gs3nOVG?= =?us-ascii?Q?dfnpV5639X1BNXM0Od2wBkfMNfAJ5XGVDk+Isenb1biAMYxAT2IK7SuGywMy?= =?us-ascii?Q?SV5aG99XaL2PQ6oKrZTnYrk8p6/nM5jyXT4+G1PWnmVJflCWfWViCABVFXxR?= =?us-ascii?Q?Hj54fFwmJ/ZVAG2fX0hIOXxiVKd6tSOYty3X73+w9+rmD4lmnuwSxFsvWRTw?= =?us-ascii?Q?GiFi9C+y7oFrnVKDItZe1F9R3cKauhcvCHNEqcR3+uWtG9mfkjW+3+wrFN4d?= =?us-ascii?Q?w+sc9LOjMg7qJ1gdntfG+Pq4mWaMhD4G2uHmvB2t0HcxkFwU6LgUr6fgv82U?= =?us-ascii?Q?v38Jj64NgiQq/j5nRZhLGSosld5e7/3W7EmR75aGQ8I6+INboUHlwCTPhH4w?= =?us-ascii?Q?KEmIyQcBv19lMt/Tbh8unXNyjJMRqSXc?= X-Forefront-PRVS: 0325F6C77B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(6009001)(39830400002)(39450400003)(39410400002)(39400400002)(6916009)(6666003)(6486002)(7736002)(478600001)(5660300001)(305945005)(54906002)(53936002)(4326008)(6512007)(6506006)(2950100002)(110136004)(107886003)(3846002)(50226002)(8676002)(66066001)(42186005)(81166006)(38730400002)(25786009)(6116002)(76176999)(50986999)(47776003)(86362001)(5003940100001)(2906002)(2351001)(36756003)(48376002)(50466002)(33646002)(53416004)(189998001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1999; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 23:VVnNS30C8mmGJUxhxegog039DqrtG3lw1/fXmzD?= =?us-ascii?Q?6TZ5JAqsjBLdXwxIoqw+tItFik2DcnnNDMzqnx+6ueQNdEz/GUZOsE6HZydA?= =?us-ascii?Q?yco8pngVmdMMO+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-OriginalArrivalTime: 01 Jun 2017 15:15:12.7719 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1999 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.122 Subject: [Qemu-devel] [PATCH v2 13/15] qcow2-cluster: make handle_dependencies() logic easier to follow 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, "Denis V . Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Avoid complicated nested conditions; return or continue asap instead. The logic is not changed. Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- block/qcow2-cluster.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 95e8862..2fa549d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -926,32 +926,31 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, if (end <= old_start || start >= old_end) { /* No intersection */ - } else { - if (start < old_start) { - /* Stop at the start of a running allocation */ - bytes = old_start - start; - } else { - bytes = 0; - } + continue; + } - /* Stop if already an l2meta exists. After yielding, it wouldn't - * be valid any more, so we'd have to clean up the old L2Metas - * 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; - } + if (start < old_start) { + /* Stop at the start of a running allocation */ + bytes = old_start - start; + /* ..if there is no other conflict, keep checking */ + continue; + } - if (bytes == 0) { - /* Wait for the dependency to complete. We need to recheck - * the free/allocated clusters when we continue. */ - qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock); - return -EAGAIN; - } + /* Stop if an l2meta already exists. After yielding, it wouldn't + * be valid any more, so we'd have to clean up the old L2Metas + * and deal with requests depending on them before starting to + * gather new ones. Not worth the trouble. */ + if (*m) { + /* start must be cluster aligned at this point */ + assert(start == start_of_cluster(s, start)); + *cur_bytes = 0; + return 0; } + + /* Wait for the dependency to complete. We need to recheck + * the free/allocated clusters when we continue. */ + qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock); + return -EAGAIN; } /* Make sure that existing clusters and new allocations are only used up to