From patchwork Fri Sep 21 17:23:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E444D5A4 for ; Fri, 21 Sep 2018 17:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C83E52DEB7 for ; Fri, 21 Sep 2018 17:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAA372E35E; Fri, 21 Sep 2018 17:27:57 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 322302DEB7 for ; Fri, 21 Sep 2018 17:27:57 +0000 (UTC) Received: from localhost ([::1]:56721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PDg-0002wg-GE for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:27:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9g-0007nk-Ku for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9d-0003zA-Ov for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:48 -0400 Received: from mail-eopbgr730137.outbound.protection.outlook.com ([40.107.73.137]:65493 helo=NAM05-DM3-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 1g3P9d-0003yr-Hz; Fri, 21 Sep 2018 13:23:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l4jjVIBsevaP9knH/Dsm9mY+61Ao2JPKnEmZt7Jyl5o=; b=TY5xz3P6fdhgiOSgE4ooQHARtPcFhfOoBSn9qWx9ERJ34kMkMwt5F382xNmVPhFiKsu6ObAXGaxazzs43tfMCnPpXdH8wQR6OfbdbRKojEwAubTCJTPR0ZdIDdoHorXGE4DCV2WZJ0RUvqXx1qk0hsV9uPvovV28h2mhI878B6M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:41 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:02 +0300 Message-Id: <20180921172310.10068-2-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55a78682-5fb4-4751-f347-08d61fe6fb64 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:WhG/RzVnR9N07QiKIXdqxnWCi4ah8Azm+I2CrGIuOOQmSXMV7kbVEe8hhEz3OIeSKyDAmADScWwALV8l/evOxxBKjZRJ6yAL8HU/e0HTD0CoYX6XekNpwnONolH5utYDCR1gLOWjzJvR5Sxw3U1BToXa3Llw71C5j3lU45sBiAjPfIPlec1FVPAXaGJsZDNTeryFc4xaaoydXP7E2LvExGkYqmxcKZNyANrVZj1woZ9/wbg6ndJFe1Og3j1FYUJt; 25:7sKvf1VzeNdo3El9N/FfAYT+FdJmJhfLauzPeGekfbaEatQ0E+nwgJY88HDXyoSMPZiHU9Z5aLoF34wBmvvrtUtQoc7mHjyRofAYc9HXMPS8Uw5j4pWMBCMYNbSq3veHT88nGmnCuJtFqoyCacqHuO1wXqr/Dscuy7mWKWdXI7XnCDlF6wWoXL5z7ErfpnhaAHMTsiM+SLE8XkRe67q/x0OFS3aS1BlDFkvJdDvfMesvme6iXLwxuRCEd7LNZ9IgtahYsvgC85uxteE3+x1PNbG6KqOg3t/+eem5L4CEQv9ghHw1uOSR1qQ2U+xJQYOSq5Gj88X2tLiOukzRW9FXjA==; 31:klo+37K/0GHjbM6SKh4h/73SsodATQFylXx2bAJgeDo7uHvTSK5hqBhQHxr6BSBu5+f6iygNdcCUwF6UDSY2J4wZWJjr/sNV+UoMqx3fKtorzntbN+Ud6wPg1YFngQtSwuGW+ExgZamcg5mgtFzf6UKRXtxqepYPoG7S9JwAFUPFHgBd5homVArrzShCGyJv+vdU9bdoySzBJrDuwcDBpkG0EGyeYHfYBwmr9v61N6c= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:VY+LgxlSdDem7zbRDc59T8MTF1xHdDXHqNRo/lAYqVXOZgdqP2+XkggqFW2tOfxGRmGXOs5MqWMx0n5pLKlNvoiEaNbUXRbh5dVa5MZSsYLnVErCxdRaarfLDk4C6p5ZOYSvR9j2fBva37Lxtuh7TFqZXv4LwISybkvSe+lNgrRROYNoBg31Ol0d+LI0Shd70pyDYwiXEuykMS/90k6n9e8+ceXkb7h6TTFJARGqWQIy+cOyQY6/ph/8R4E/sVBMdK24M0OtIRSWiFKtdFySOQ== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(551984002)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:wn4B3IIzh4pN9BxmYilBDgwCmSowTNnlpvbRXteq4?= 34ZrB53oxdKT+9FlzqpYBwMGRB0J1lz4JJbDm3eLJ8x7UYQ5sd5SrE2FWMTST10Njqm4XtoOFXNm/G0I/8IuDkwYTKQ3fIFLPmNY9EholKgpqg2r7K3DUv1L1nlHnQPBuJ4RnQCANbcEQEF/jiQl21nkPzijPy0ovx5VmMZ14fLiiRqFQG1G+DA1vOouyTA1+Dz15/+zdTLAkyfVssLmuhEd+aOhVrlWJbtXZfFqEJIDhE8z98Il1/00A+b8/05mvbVByyTkX6ZoakEYsEMQjbuy3jQ2PzIfF3gqDThJei0ZVr07RgcUi1ZrNGjU1cKwfgaIYUCNTgOrhmntrOHkTVo1eb5Rz9ALfHmxvlfK2uGaz8eiZK8ZbFS3avjCmxhDFbgFqvgJct+3D4HajHtCwXH+a8xT23M2cxb7/EZmipmL3DNbdpaUgvj7S6Ev59Q/WjiqGb0dtP38p0TpIPdAQsDwU34Czq234qrkNlKeirNApMKpwe/0kt3z3dmzL1PvJpHfOPLS2BkhAY1/IGKGuA+xzzjTGAJ6Loy1ody8LMV3DRXx7dfaQI8eFmHFNJVuQ/B8qv/e/CaiYHdHJVoQW5PpnV/jOG1C6vj6YA0O5MZYo/yJa309LwLIfLAeIoheggp7vNfqEbCrKA4tlaDBIFmtvwX21dcZOtXt1/8okuivg9CRtvBRjjqgCn6aSFoMDNjUYFqmsrd2Uw1wllNlCLLdcqGYsqrCD+SHCjPt2ODN+fZ/6LVjjNaZhc3CLLpkAVodQrwsu1ZsLbXLU5ux9ypX1e8C65hQtWIbKqf1qI21/5KxiK/H0lSgf8mNjc5UnXDZBGlv4xoQ4j+NbSqQ+hdQjOrijRD+1byAj/7nGRtuMgHPr1TeUY7jIhiRYQUreBTg2YazR1j0Z6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iNiLm4xiI/pARhIR7rPdklwdl1eFv5IRP45BqjR1nJg8ToZa0m/njniRLB2PstrMzGKCMLZgJuuymuYuronC2yZFAT24R/t8aMRUvkOwjWdJh9VGKagBxaDLwdRzYXAVgFDsJcgZgXqUwFjto1sUafGy0UA9O5aVu7V3Gs+dZrgvBhEw==; 5:WGZfGaA9eOrPeDYe1n0Pm17a5JCbFqzvTS0KtVtRw//uxdVu6qG9yryGlrVN1Gv28tnJP0T6eyrZOKMWtsRTOnTsL6Btx+W9OjVgQl4TPQCvEC4hF7KSSVoU1wRSWUwCMY+Osk6/zwcojFfS+TC63MBctcXxq2MrYu0Bz8w0IOg=; 7:LRATAOITI2gjVQGDVOheoq8b+YB4CqJU1GMSBbSDsNjx7D3UmgrtDaAgFf1quGVcN1FbjkwQvYXzB+kr69rOrTW0xvekh6e2wk+1iZ+fpRadxRRsccu8uDKTsS26IZ/YYv8cFzzEeOWbq9XyQoagjyczoSVI8rKyxeaOJuA+h4OdcW4PCuiOk3xXcLptURNwsQJmwNI+hYjSYzJF0zP12wXHdPrKxZipU9+5LoYEL0ew8BtoJNKu7Uzm7HKIxEox SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:41.7796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55a78682-5fb4-4751-f347-08d61fe6fb64 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.137 Subject: [Qemu-devel] [PATCH v10 1/9] qcow2: Options' documentation fixes 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch 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: Leonid Bloch --- docs/qcow2-cache.txt | 20 +++++++++++++------- qemu-options.hx | 9 ++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 8a09a5cc5f..013991e21c 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -77,7 +77,7 @@ aforementioned L2 cache, and its size can also be configured. Choosing the right cache sizes ------------------------------ In order to choose the cache sizes we need to know how they relate to -the amount of allocated space. +the amount of the allocated space. The amount of virtual disk that can be mapped by the L2 and refcount caches (in bytes) is: @@ -86,7 +86,7 @@ caches (in bytes) is: disk_size = refcount_cache_size * cluster_size * 8 / refcount_bits With the default values for cluster_size (64KB) and refcount_bits -(16), that is +(16), this becomes: disk_size = l2_cache_size * 8192 disk_size = refcount_cache_size * 32768 @@ -97,12 +97,15 @@ need: l2_cache_size = disk_size_GB * 131072 refcount_cache_size = disk_size_GB * 32768 -QEMU has a default L2 cache of 1MB (1048576 bytes) and a refcount -cache of 256KB (262144 bytes), so using the formulas we've just seen -we have +For example, 1MB of L2 cache is needed to cover every 8 GB of the virtual +image size (given that the default cluster size is used): - 1048576 / 131072 = 8 GB of virtual disk covered by that cache - 262144 / 32768 = 8 GB + 8 GB / 8192 = 1 MB + +A default refcount cache is 4 times the cluster size, which defaults to +256 KB (262144 bytes). This is sufficient for 8 GB of image size: + + 262144 * 32768 = 8 GB How to configure the cache sizes @@ -130,6 +133,9 @@ There are a few things that need to be taken into account: memory as possible to the L2 cache before increasing the refcount cache size. + - At most two of "l2-cache-size", "refcount-cache-size", and "cache-size" + can be set simultaneously. + Unlike L2 tables, refcount blocks are not used during normal I/O but only during allocations and internal snapshots. In most cases they are accessed sequentially (even during random guest I/O) so increasing the diff --git a/qemu-options.hx b/qemu-options.hx index 654ef484d9..ab1a3b240e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -742,15 +742,18 @@ image file) @item cache-size The maximum total size of the L2 table and refcount block caches in bytes -(default: 1048576 bytes or 8 clusters, whichever is larger) +(default: the sum of l2-cache-size and refcount-cache-size) @item l2-cache-size The maximum size of the L2 table cache in bytes -(default: 4/5 of the total cache size) +(default: if cache-size is not defined - 1048576 bytes or 8 clusters, whichever +is larger; otherwise, as large as possible or needed within the cache-size, +while permitting the requested or the minimal refcount cache size) @item refcount-cache-size The maximum size of the refcount block cache in bytes -(default: 1/5 of the total cache size) +(default: 4 times the cluster size; or if cache-size is specified, the part of +it which is not used for the L2 cache) @item cache-clean-interval Clean unused entries in the L2 and refcount caches. The interval is in seconds. From patchwork Fri Sep 21 17:23:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 044DB157B for ; Fri, 21 Sep 2018 17:25:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBB9C2E35E for ; Fri, 21 Sep 2018 17:25:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFDC82E371; Fri, 21 Sep 2018 17:25:27 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 314662E35E for ; Fri, 21 Sep 2018 17:25:26 +0000 (UTC) Received: from localhost ([::1]:56710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PBG-0000hS-8U for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:25:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9j-0007p0-Of for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9g-000423-V9 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:51 -0400 Received: from mail-eopbgr730114.outbound.protection.outlook.com ([40.107.73.114]:39168 helo=NAM05-DM3-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 1g3P9g-00040Z-MW; Fri, 21 Sep 2018 13:23:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4ITiwPXiA0wzJuGRlzkcYaBkfzpPyrSztH1TkFh7aDQ=; b=Gr60uvXMpuMLlQvNwb9bPnKyLVvJGx+V/+/FqFkY3HuF7JcjGIvbiXVPJRPBMs/NrN/p4Oqu++lMcexMEoZm6xW2hSAVtiGM0opHW3rB5cghP17MTYwy7fulwEH+KE+XSPALqNu+YnGJRCd1pqG1X24+//Sj8M8Wdzq0WDPerRk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:44 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:03 +0300 Message-Id: <20180921172310.10068-3-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a56902c9-e675-4014-7e9a-08d61fe6fd14 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:BSr3Ik+uEOdrMLFB4atPTHGPKYxooZFxAfylQqt/ehJIYHpvqa526SUGlALnpW1Hpz9U2lSYSibIeLZoJbjh3+79P/PJ9OVKnySzu3Uftng7f3yEHQiE/z9EXrTZe9CDvtAjXEQ1pFn6joLjiB76bp7uwi8wI/iYDIBuR1Ht9xp4VTB71WKoUhsfxUWTZ8Da0IAAgaj9mngXOBtsULTGKOfx8b+CxY6/lk7m3zSkdCpXBJju+/JWlWi+6spw3VY3; 25:JnWz4zSekxXowu1imD93d8LxE34HtI2D9iXKIpbECkapNHKZCN2Oc2NuY1g6vEJl8DgP9AzyLjfZpSqbgS1dpLxo+Rji9bDD7JPoAr782NLP0nwx6SjTop243NltQVwBy2auXfbY86UyApCqjaDMBexKjiQ2PeXmdAxqosgmDcJfwpd2HDDnQVvxaeyR+swXFvvSmS72dJv1O+sANQ7BnSnHnRGylFp3qjgUXxP+0nRg30cjzPeBK3JZT9tkZ+llaO8FWHu/LjiP7shW5y4myFENVgqoSNMOIerLO0QV5BzaxQJY4I5xOFjVA/be1VQi9qBtOUZOMCTMf7YMqYtG/Q==; 31:x5N0OEs39M8Z6x19QcRnlpCHbo9Tt7U6Y79KTlTQRK5WLuPfui1gTIbAUQpbiZLqt+luOl2qH+Qwzh9wV5XUF8xnR5eIfK57tDRnyOnDpXZYQE5nFZ+5rnc4ivmDOdGFKskU2iZFSEEYDLEPunQwajkLJBdrvY9NFeaW5Qp0M/4tHG1GbJvi7KUevBr5i+AwKvPtLpX4bI2OO5vASZYyCefL+Ca9qLTs0C8GOelxflM= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:ES4t0KkQMSjQprdug4zPpZkLGZiALle+irLYWByPCRnU/RmPbnrALhgcy0ZMiETFjaMdSvxsE8a9dRUmGSq+sb6b1XKE2ciLHM4a98dcu1vfjcsaVL/yed5w122zk+lCbylF86C53heFtxKzLtpAPOH2BPWwEi3JKzWVHsaNYzjwNaaj5fqECnlySrF9vodnBjaOG3xztwh+CHBEdzHWt2inJEZ9n7gaqz5uSbYSYkbL6/jlNpePuq7c17OC9ms8va+Ydn+XpUnP5W6MSfEiyw== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:xRExAYx61Yz38uO1LRC40RuBKUkUZZmAVJDM86YxH?= wStkM6YeN2EmuRuaxso6Kk9kyND4md6dnJ5qiOsG9GxJcFzU7GvjSVBklvmlN0SG78Rfe4md3zSejKrM3WACI5cJrDJF0ph/YepPs8NbrIVmAd53eLLwZLeOltts+QfoZnXQfEKPAB2/B1H80SM7opMvWbWdTrR/pl37pH61hCFXlGprGfgSAaTbKgtaKGfB+1zv8y+1Qe1jqkd4shWd8IN7MVqlHKOB5ZIrGfDDAr+SmUSXxI+oQ/Af3ieXXE+tkDngD4OvX3Wy9yCV2FzrNP9dOTy1MRKI1LnQHYd+E9SuEi7+TGSsb7y+guu7FHGMw4Rwju1hFKWEz7sK/aJul4oMVsWFYblpyHYvDiEJ6Wzd3BX2jmKXscAiKXHR1q4I7jSZmPZErUHTiM+cY+NERBfptyX6dWKW3CzjHUOoE8SKpleV0s4t8L8dIrA16eTGpDgL25K80Bx1/KZ+OAJr9WBSXA3c4/T2gMcri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08Hy4iuhON/J+7GNI15HgAfY20Mogh1iG5gFyEBPC5XINcJ37NfnqR9E= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 6:siaKG0jNv6Qa4PwxdhFQjGFC3bhxUMUSHbDL5w+Wiye2vV64cjRNlPhpG1St6KEqsUbuWUVph+Q0BrzL74sPlSegn76sG6vpCYJ38oloqh/Jig+8aK6kjwByhPg78JPg8KMs5WY5DrnPaf+ot4VQmYk2IR+oZ7+7KqN0xdqqz+6AypIn8hdAEqNFLz5MvzEnEG03z9fceFCNtGLGeWMOOgeMZ2CYd8MmQEwSgQHEvTrX+Z16ZZStGWsY227bqU6c35q6LODIwk+iTZY97fhtqTSIoHxtSLtEetFyAFEvPwNA8qESq9uoTB6gU8oBYWrGctjB2nHxIyPvVrcQrz27pSffy5w1uqrKvccIbkrvISl4tDvBoSIFqYpQmw2pTwDNI8LWq3iNqTKI1p2h14EBAOjA4lrP14OmMtxFMc6O0H9uSbj/VDmCKU/zxHB3IkBwCPzKYsnhtHRSkJJevxgTjg==; 5:Ae/cOx8jMp82UDar+RoWsExwflBInxW/bLo8Q3IaGcINWRt37m6PcWUAZU7tDNERyigZACd/NcuTeeIJ3RLzleVidg8z69cbyoLSr5SL4253IwrFJ6FLeSka8mHzztE4JvrXC/ATcLhr4MRPwTg9sAmv49cJfYe11Vx4UvjfuvI=; 7:zxW7qfj+vBPsQtPfMrGggLg2cFglKeWmwfTIR452JhgXvxQqsxYCdJuV9mbwC9awtz9yzFOVcdK5hdkh8OQG+9+dnU56zOo0flTtvPhZtwEMg0yTpts+ExbafSEsgppYG7Qnj5v7ndcCJn8mT9S28ZXLr+W4CmKz+8+0fUdUZnSqhbLqaTIX/1PmemlEO6XfE7COdbIMrOfHCQQBjsZhRBUKj68Bu2J9ylNzA73maLU8bTI2bCcT1ZHIop5kkHjk SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:44.6077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a56902c9-e675-4014-7e9a-08d61fe6fd14 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.114 Subject: [Qemu-devel] [PATCH v10 2/9] include: Add a lookup table of sizes 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adding a lookup table for the powers of two, with the appropriate size prefixes. This is needed when a size has to be stringified, in which case something like '(1 * KiB)' would become a literal '(1 * (1L << 10))' string. Powers of two are used very often for sizes, so such a table will also make it easier and more intuitive to write them. This table is generatred using the following AWK script: BEGIN { suffix="KMGTPE"; for(i=10; i<64; i++) { val=2**i; s=substr(suffix, int(i/10), 1); n=2**(i%10); pad=21-int(log(n)/log(10)); printf("#define S_%d%siB %*d\n", n, s, pad, val); } } Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- include/qemu/units.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/qemu/units.h b/include/qemu/units.h index 692db3fbb2..68a7758650 100644 --- a/include/qemu/units.h +++ b/include/qemu/units.h @@ -17,4 +17,59 @@ #define PiB (INT64_C(1) << 50) #define EiB (INT64_C(1) << 60) +#define S_1KiB 1024 +#define S_2KiB 2048 +#define S_4KiB 4096 +#define S_8KiB 8192 +#define S_16KiB 16384 +#define S_32KiB 32768 +#define S_64KiB 65536 +#define S_128KiB 131072 +#define S_256KiB 262144 +#define S_512KiB 524288 +#define S_1MiB 1048576 +#define S_2MiB 2097152 +#define S_4MiB 4194304 +#define S_8MiB 8388608 +#define S_16MiB 16777216 +#define S_32MiB 33554432 +#define S_64MiB 67108864 +#define S_128MiB 134217728 +#define S_256MiB 268435456 +#define S_512MiB 536870912 +#define S_1GiB 1073741824 +#define S_2GiB 2147483648 +#define S_4GiB 4294967296 +#define S_8GiB 8589934592 +#define S_16GiB 17179869184 +#define S_32GiB 34359738368 +#define S_64GiB 68719476736 +#define S_128GiB 137438953472 +#define S_256GiB 274877906944 +#define S_512GiB 549755813888 +#define S_1TiB 1099511627776 +#define S_2TiB 2199023255552 +#define S_4TiB 4398046511104 +#define S_8TiB 8796093022208 +#define S_16TiB 17592186044416 +#define S_32TiB 35184372088832 +#define S_64TiB 70368744177664 +#define S_128TiB 140737488355328 +#define S_256TiB 281474976710656 +#define S_512TiB 562949953421312 +#define S_1PiB 1125899906842624 +#define S_2PiB 2251799813685248 +#define S_4PiB 4503599627370496 +#define S_8PiB 9007199254740992 +#define S_16PiB 18014398509481984 +#define S_32PiB 36028797018963968 +#define S_64PiB 72057594037927936 +#define S_128PiB 144115188075855872 +#define S_256PiB 288230376151711744 +#define S_512PiB 576460752303423488 +#define S_1EiB 1152921504606846976 +#define S_2EiB 2305843009213693952 +#define S_4EiB 4611686018427387904 +#define S_8EiB 9223372036854775808 + #endif From patchwork Fri Sep 21 17:23:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93D6F157B for ; Fri, 21 Sep 2018 17:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 772872E33E for ; Fri, 21 Sep 2018 17:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68B352E354; Fri, 21 Sep 2018 17:28:17 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 E82332E33E for ; Fri, 21 Sep 2018 17:28:16 +0000 (UTC) Received: from localhost ([::1]:56723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PE0-0003DM-86 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9k-0007pd-KR for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9j-00045R-MO for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:52 -0400 Received: from mail-dm3nam05on0717.outbound.protection.outlook.com ([2a01:111:f400:fe51::717]:20608 helo=NAM05-DM3-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 1g3P9j-00044G-C1; Fri, 21 Sep 2018 13:23:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17jCltmobbbrulmLbfYr2kRyJVbuhFZj/mJJi9sixuc=; b=Fy84bbvCHKgqYdp1H/xbhINpUaBO+ahieJlVd8Ixu4G4/1xkMm7oklRWM5O7WmKAT/qVJF2K6e92OyTdBwOBxT4diACsQXMQqbTnseK2WvlnQ8F2WX5uK/wKj1d3UbmAggXrcdtDtmjjXeTzS9c1J/BuBfLCl1y/Q0+vzP0ucEE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:47 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:04 +0300 Message-Id: <20180921172310.10068-4-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4a6f46f9-63d3-4253-09c3-08d61fe6fec4 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:EJZkRaJ6/CiArHa5bHjRqwszN7GVbgpoFtQqGf7bEXS9AFFPcGuwJnrn0l94AWnKxkmltXIfW2Gan/5mr/5ToR2SBfza8wrpwrRdVDa6NZSCbW0a03Cyyq/rNYrqOrOQXYzmi43IjH+h3EWZIjeWroHlTdTXEtjBiQJC0OrrkElWBpForAHM3ZjhemRP0TpshsfhkBYl/DR294Aa9i1pbwEUyyN+SfhfExiBbU6TA4SM9hlWERhSLzcFHrqSS/kd; 25:Vx2NOQAch4voJftrmy9ziY7v8CNIc1mNR/RGMchdrxH3ffGmkU3SzmoXD+tpQOG74onTbqqOfNrLOX6OyaF+Qur0BkdlLCdQEYPuT4UhBRH0XFFasvNAGx9NwBFdlHxW3VA1+ndeTUXZd3KTBoOPLiNYrxxwBHdvNBBuxqa8UHVzsQv7indxjtpQVwHay1K5KJeh/DhBSunln3gI55Gbd7cOSuOVkuQVA2w3FjFuegz6T20vHp3KTvuMzoMw/H0WmvRFAw0a0fvX1Wr3PO5TUYEuLOD+CbwT9dv/CISlzTCcKjA6YnEsxUZd46Z42QSL4AYKPjQvGXlhnFSKxeYwlA==; 31:KdQ03S1OLW2WILaXhn6kkJJ9n7oPraxM3VeDmLophLO5o8lbRVQmmCpEyycXegOzL5hGyNKFtRQ7n/fzDBD5DzxFBghzv1hyZ5Flk3gKsDja4DKRqLt4z8Eh9xZJ+p+hx5Xc/THYZyPwHs0YDaNjALumuqT5bUVPBzjbQpmxlj8Q+Hq/I/B3HxicfFmI1ruMkkP8c5Ce3IAOr50dprYH4zbTqFwogQigBpS+rinV6LE= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:Jgc8iCHcyTLzV6H4gI0YMYzikL8KXWpyr7FutWsnoJAnXj5HSZzsnJOM/IW4QKXC5VLBLGSlO8oTjzw9o7YrrhAPey2MwXNR0GaBHsD1E3K/fYWOJHDTdauG0NBEW9M7zgffHJiab+EfDKus0pcKxWisSw5hwWYvmUXybXx4PZzxzReA3y/WmA8Ij2YoA6JB8tjNULTOxBz4VI2dsuiDpBsh0ZjBXajfNwvv0Mtn+eE4lVl6Du07qrB2ZjhWmDuWvP/IXMlCQNT19Ku9G+8kzQ== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(575784001)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:Qe2q8GLjPwlGDYsokIjrdGrVvhkP/eyLNN8YlLQZm?= OzTH56tf2qhST7/QOrEBR6AGzqpmrtyX0UAomGsQ8+7rdlfbAKsDzdlwxybjOZoZNkhuVbXM7zVuxWEy8r9UHGrdckUTb07G53Oqwdr2sb7BaC0qNtJ1doSwG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hHfqvCFQj54Ju7MeoEL2e59sRk3PEM88ZYa19hVjuX+VZLTiVbCSwuNi1SM=; 7:UseF2TcN8u3nK9nDLx6W9tdsjh0DipQzDtuzmmjKsKLde9xNJdrnyHXhl7zrwUt3EhZK0pIzEIIRAKdkP9j9B0oKBxENJV0QiYRCHa96Dc8Zkbi8v/U3LGAMN2QNG+WU0E+m6R5G16MRTxm7R4neNs/TkiY2fqoYhsyp60T282FNVwHmtEIpaO84EXad3Z8liyswcyAtJp2WZ3P5IyyqYGGSqqJS0UJA/tdG4vI8m6lEUPMrh8W8MtjonatNSx3g SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:47.4359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a6f46f9-63d3-4253-09c3-08d61fe6fec4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::717 Subject: [Qemu-devel] [PATCH v10 3/9] qcow2: Make sizes more humanly readable 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch 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: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 2 +- block/qcow2.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ec9e6238a0..67cc82f0b9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -830,7 +830,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } else { if (!l2_cache_size_set) { - *l2_cache_size = MAX(DEFAULT_L2_CACHE_BYTE_SIZE, + *l2_cache_size = MAX(DEFAULT_L2_CACHE_SIZE, (uint64_t)DEFAULT_L2_CACHE_CLUSTERS * s->cluster_size); } diff --git a/block/qcow2.h b/block/qcow2.h index 81b844e936..a8d6f757b1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -27,6 +27,7 @@ #include "crypto/block.h" #include "qemu/coroutine.h" +#include "qemu/units.h" //#define DEBUG_ALLOC //#define DEBUG_ALLOC2 @@ -43,11 +44,11 @@ /* 8 MB refcount table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_REFTABLE_SIZE 0x800000 +#define QCOW_MAX_REFTABLE_SIZE S_8MiB /* 32 MB L1 table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_L1_SIZE 0x2000000 +#define QCOW_MAX_L1_SIZE S_32MiB /* Allow for an average of 1k per snapshot table entry, should be plenty of * space for snapshot names and IDs */ @@ -75,9 +76,9 @@ /* Whichever is more */ #define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */ -#define DEFAULT_L2_CACHE_BYTE_SIZE 1048576 /* bytes */ +#define DEFAULT_L2_CACHE_SIZE S_1MiB -#define DEFAULT_CLUSTER_SIZE 65536 +#define DEFAULT_CLUSTER_SIZE S_64KiB #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts" From patchwork Fri Sep 21 17:23:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A317D913 for ; Fri, 21 Sep 2018 17:30:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87BB92E395 for ; Fri, 21 Sep 2018 17:30:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BE2A2E39E; Fri, 21 Sep 2018 17:30:09 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 167632DB11 for ; Fri, 21 Sep 2018 17:30:09 +0000 (UTC) Received: from localhost ([::1]:56734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PFo-0004kx-1D for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:30:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9o-0007so-Gi for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9m-00048X-6v for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:56 -0400 Received: from mail-dm3nam05on072e.outbound.protection.outlook.com ([2a01:111:f400:fe51::72e]:43040 helo=NAM05-DM3-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 1g3P9l-00047z-W5; Fri, 21 Sep 2018 13:23:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SgiOymsmdHx6bhtvMdG/lVs52eoiAujl0mFWRdCPnwU=; b=eEiJUjXndbBRjhNqVkrfsEYCim0Y0G1y2owXsHLsWIt1QCVNVxic2orPT/BrfmMVOxN4TIQSZKU/oppkknjQqOlzSJTaUPDtB0jsWj4+sbimxx17CZfjRSKR1ADJhf/CiCPNhOfEMmTCX/jxca214neB0czKpfJlrk72MUx3LfM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:50 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:05 +0300 Message-Id: <20180921172310.10068-5-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef5b0563-95d8-469a-6dff-08d61fe7006c X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:xRmixEDVic1oXyRtbE+4E96nb4x+X2PIVE2WGdCx15+qhM5AjTZI86z5PAfN3AhOrBkGGCe7v+NsdJVotDsKGZddmk2yP7ZX3guDuBlLPinuAX4kLk6STR1sSHGSCjjFUEIna1owWsBzGDpeKVBC9GSYNXodOryzZO0r5N4A7vBcoiNaVIjG5JLL5Cdpnfmz+NHmCytZWgIJFb5tWC2deZ7x/0uO7j8oQLqS3ab7KpBCldAayqxeutBgmqoGo8+o; 25:wGHoLotppmM9gLsVyGrNtC/7/9Y0dhNDO7r1TAAZlPDVSoaJ6O1aW6DE2JjYrIteDkbQWcGAJiBl93lu40aJab8Z2N11Q5dady2spl3A+zNTCB8kwc7bR51SCamthbjdS2hnz93L9c23s3au0SrhVwnbCYnY0fxi9xA0vnnLeEuhazJ430qiqg5y2i+DyDqG7oPxmAk6RTmCnJzuzStFJsOKdKnFeK6U5tYpX1UMk8Ol0mPpEq6ukdSJfpaMMQ0B6uodooZAQHKDYmnPmBARA1j4HoaD3AZHDWrJobRiKBgG/QLlet1YZcHoP5QilHpo2K831B747HjJb2Y45BokVg==; 31:283N6kcdjFD3lHQkxEw9QcleZWCJcpG+Dl033QgJQsKLFZwyFVZF0Z93nW99qxCqHucekpj8Uq/Khv5jGyVGtGFlTYVdnD+UgJqoeLGYtIA/FPN7focl3+m4AeCo9QllVu0Bxjj8t04rJdf8qPg4ChU2yzxlREA+uRN2Ap0Nw8jmApdFm9LEnAruS/ua7dkFIQBarS7gDDdl6sXNCT+SxSfV+kzD5UFw1mfLfGALIdk= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:IR5twNwo7XStAmYBz8BRmifixbZLT/Dk4aOuRDk89CZjHy6Z4/xh0OrEvmKj00B1fDgS5LWG4QNXCUD2q0rMxYxKempoqQWFfLyoA2wx8JV6rID29FbERT8fSH6ZiUiXJVL9But2yKKpKU2lLm3beDA6YyG32F/eer0bVKJcNzcz4WrotycLyjkMPm0Cdyvp0uAY+au4Zxg4OlcTr+kxvce8Gti+Uwb7yx2pXLnRAOLA++p50H9K46wItnSKglT3+hoz317dUJXkiznPG6lRhw== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(575784001)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:IKCGeXxDkB0m4lMeTIap7twWOYzNUhmph+2dOvKKz?= l30JGrGoGIAVdzaTao24AaFXMFuno4aVVpJ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eoeHmLG+96/YE9487j+CgHxSzlmnu9HD1NZZfHFN7WSe3N7GyAKPRZA0Vlf6lw46vj9rD5JxAXETzKepkCi9UKyyEqI+YdrWQ+XB5Yk/eAEkVY4ZT0ZLyM/Ak54WHsXn2imYJfl0c+60x1a7pngkSN8=; 7:CgLN489JVeiMPj+Lf5n53vYvK1acmihh73qnyBKft5iJ1Q/bC8zdlQ2RniiLB+t3VPZqBOKHP4Oa9CZH/2H/+tlnQGpUzPGwACr4IL1SWt2ms+XTNu9pAB8SNRXgZCO/O8AdV9uQh9wiEbPjLRT059U4K4RxIAieaG7GFco1Z/cc9HORX1K5L1RF9Pc+pS9wwYgolIjW5Z9e0ckJyU+u2ExxfL5Pyiz2aCk4D/mbv70Oa2Fc+0DzY6e5IuZhvU3O SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:50.2172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef5b0563-95d8-469a-6dff-08d61fe7006c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::72e Subject: [Qemu-devel] [PATCH v10 4/9] qcow2: Avoid duplication in setting the refcount cache size 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The refcount cache size does not need to be set to its minimum value in read_cache_sizes(), as it is set to at least its minimum value in qcow2_update_options_prepare(). Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 67cc82f0b9..7949d15fc6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -834,10 +834,9 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, (uint64_t)DEFAULT_L2_CACHE_CLUSTERS * s->cluster_size); } - if (!refcount_cache_size_set) { - *refcount_cache_size = min_refcount_cache; - } } + /* l2_cache_size and refcount_cache_size are ensured to have at least + * their minimum values in qcow2_update_options_prepare() */ if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) || *l2_cache_entry_size > s->cluster_size || From patchwork Fri Sep 21 17:23:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 412EF157B for ; Fri, 21 Sep 2018 17:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24B562DB11 for ; Fri, 21 Sep 2018 17:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 181892E3A1; Fri, 21 Sep 2018 17:30: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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 3188B2DB11 for ; Fri, 21 Sep 2018 17:30:21 +0000 (UTC) Received: from localhost ([::1]:56738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PG0-00050K-JF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:30:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9r-0007vK-Mn for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9q-0004CL-CO for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:23:59 -0400 Received: from mail-dm3nam05on0719.outbound.protection.outlook.com ([2a01:111:f400:fe51::719]:21280 helo=NAM05-DM3-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 1g3P9q-0004At-4O; Fri, 21 Sep 2018 13:23:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qs1MPh164xPUs4EaVgCO0NCC3QzTumqPR5TQMhaWjcs=; b=ZdUUjL/WbKWQdCir8T/dgNcCr4XXgcExS0+CcbF7ngep9wwYi7cnUMXcvmHQJZJnAsH+DweAT9sqbqatdxQmQv0TSjdj//VEolnu+/gRa1zFw2URr74/xy3T9DUJBTvmrl9xE0/GjNv5fx8bzlqMVxN1sWHlG2sjqXAPd4w4Ojc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:53 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:06 +0300 Message-Id: <20180921172310.10068-6-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e74aa5a9-534b-4f7d-bdf9-08d61fe70220 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:OSzTxJLi4R5UomjgsWU1BRWJOQ00XPhv2WnHkF9jg+lwO7WRiZwoeJwaeKJO7t8Af6bsTid2unhJpTsAg558Mypm3SC4eycg/vhPKgAQbDEglhVqLWevqbl52gcTd2CVTxhEzw7kOn/j2vyqd8kSQLVtuvfhavHXgOlEJj3kYOxtCF0VrYcKBHF7sALY4WV87kec+Ct0WmGyK+Lh0Uo0mWEmFtdmiWlJSgJd+TOpep9OLpflMiCLI+T+NayAS+oV; 25:bSiSIQT4PA6iE0UjmFulgORVIZpaZH+ZCwZhQnE/1prP+ZeZLR1GiAFDZuQt7fb+iNVz9Qw3DsVn1A26JziOowni39iltf4tnVC/1N24XfvRej51JgJXu1Wnv16z0bzvG0go92zPuaPdCTKQ9wHKXq3MqwsArinxNN98mrgEQA5inWN+TalG/Ua5ridE9km0zfw9+Vd8U5aL6vYtyLG/0oEtbVd0Yfsa1juuqzWVhjAOjOK7OD4LFn8WR34YZZBJccSrb9JpfG1COIffn3U4zO61RMchhOo30fvs0tCtROmiwUkQKffbWAaVzMy8/26g/L6dQiPrSZTuT4jl2FV+ZA==; 31:aiPT1PW0OlwE3iIax6/Cs0Hs+N6sITylQhBxbdNgx16B9v+rZJIqX+x15R2kGaRCYaAq2jbyJ1hHr06Si/j0RcodELV+Q1K4fPzGSBN5ZdnLFe/io7M6vvYTFwqxB+5tujvZw/Am82eq9wOzNuVMqLu7shQbgMbRJa98I8bgc6AmUQOL3+2CNHnugne0UHv2Q1z3dToO9XauTaeeRPS71xxEuIyZ0k/yOYlq6CogMII= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:x/P9e3hKXiN3TBL3BmjOE9lrMnEj3f9XoCYyMapGYBi1EsTtQn7f1DLIj+64JF0ZezrZuVVz3jipVjJ2lWtIeQ43R3fO9KRG+dYzvAxApViuopIPj+unCXppTTsVx59nicaz9Qpf+/oRTfGwHvL9s4gVE0cxG3JX4+s1bg0aOfeKARUM8I8WEfdbQwM+lEjBMJRUVPHJ7QGU5C1Xc9dtAlcB9BJ6GGwHbblXgJXQ9wYRIa8uP75M10eyrbQjM64O1sAenqrjVOZ5kIn8zEGqQA== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(551934003)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(551984002)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:2ur4q+pYaKbZQXYPSFx06NPGJDTo1zNfnbnAuSYzV?= tfNriaEIjNKXQ0VxfqU530WE/TH+v3On+yuAMhZwwVaa2EOlfaVSYHkp2C32tWAaJrlfoAhZyhzljdzgTBtOclXfqAtu93WC16nu0lD+AjujYK7ixAl/F+do2yA42Sr8t00G2L0V10hn7TiOX0wCRbrOIHu881sel+N2uzGyMen5I3YoNgM6jd3++LeGblk5NXcCGT9koD4rCkxLA6SKy279lRItPJyirvjaZvlPZVkYvdZ2sFqje0bPVNwJ9ULn+t6D4/C2vBoIcsZYp8Fa4SvpiUx1MWfq2YGEejCFvRHHTBSJtqgDE3ZufuHrOMlOp5UznmFqHICyxrPaglvR6LvIft3aLYSPf6NXufqiGeZCAD6X0ywVXlfi+1O6nLeOxRTkE5Zt/UAzX7o3ZiXkSL/hXhVdFBmgPWf9J87O7lhoCqLjGqyG171OIdylBneQy/ua37uAWGkyY7jPo5BmpEWaOsRt0kvUjwmdAbwWtsorSus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osticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:53.0922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e74aa5a9-534b-4f7d-bdf9-08d61fe70220 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::719 Subject: [Qemu-devel] [PATCH v10 5/9] qcow2: Assign the L2 cache relatively to the image size 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Sufficient L2 cache can noticeably improve the performance when using large images with frequent I/O. Previously, unless 'cache-size' was specified and was large enough, the L2 cache was set to a certain size without taking the virtual image size into account. Now, the L2 cache assignment is aware of the virtual size of the image, and will cover the entire image, unless the cache size needed for that is larger than a certain maximum. This maximum is set to 1 MB by default (enough to cover an 8 GB image with the default cluster size) but can be increased or decreased using the 'l2-cache-size' option. This option was previously documented as the *maximum* L2 cache size, and this patch makes it behave as such, instead of as a constant size. Also, the existing option 'cache-size' can limit the sum of both L2 and refcount caches, as previously. Signed-off-by: Leonid Bloch --- block/qcow2.c | 21 +++++++++------------ block/qcow2.h | 4 +--- docs/qcow2-cache.txt | 15 ++++++++++----- qemu-options.hx | 6 +++--- tests/qemu-iotests/137 | 8 +++++++- tests/qemu-iotests/137.out | 4 +++- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 7949d15fc6..01c39c56c0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -777,29 +777,35 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *refcount_cache_size, Error **errp) { BDRVQcow2State *s = bs->opaque; - uint64_t combined_cache_size; + uint64_t combined_cache_size, l2_cache_max_setting; bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set; int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size; + uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; + uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE); l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE); refcount_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE); combined_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_CACHE_SIZE, 0); - *l2_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, 0); + l2_cache_max_setting = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, + DEFAULT_L2_CACHE_MAX_SIZE); *refcount_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE, 0); *l2_cache_entry_size = qemu_opt_get_size( opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); + *l2_cache_size = MIN(max_l2_cache, l2_cache_max_setting); + if (combined_cache_size_set) { if (l2_cache_size_set && refcount_cache_size_set) { error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE " and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set " "at the same time"); return; - } else if (*l2_cache_size > combined_cache_size) { + } else if (l2_cache_size_set && + (l2_cache_max_setting > combined_cache_size)) { error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); return; @@ -814,9 +820,6 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } else if (refcount_cache_size_set) { *l2_cache_size = combined_cache_size - *refcount_cache_size; } else { - uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; - uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); - /* Assign as much memory as possible to the L2 cache, and * use the remainder for the refcount cache */ if (combined_cache_size >= max_l2_cache + min_refcount_cache) { @@ -828,12 +831,6 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, *l2_cache_size = combined_cache_size - *refcount_cache_size; } } - } else { - if (!l2_cache_size_set) { - *l2_cache_size = MAX(DEFAULT_L2_CACHE_SIZE, - (uint64_t)DEFAULT_L2_CACHE_CLUSTERS - * s->cluster_size); - } } /* l2_cache_size and refcount_cache_size are ensured to have at least * their minimum values in qcow2_update_options_prepare() */ diff --git a/block/qcow2.h b/block/qcow2.h index a8d6f757b1..2f8c1fd15c 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -74,9 +74,7 @@ /* Must be at least 4 to cover all cases of refcount table growth */ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ -/* Whichever is more */ -#define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */ -#define DEFAULT_L2_CACHE_SIZE S_1MiB +#define DEFAULT_L2_CACHE_MAX_SIZE S_1MiB #define DEFAULT_CLUSTER_SIZE S_64KiB diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 013991e21c..c84cd69cc7 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -124,8 +124,12 @@ There are a few things that need to be taken into account: - Both caches must have a size that is a multiple of the cluster size (or the cache entry size: see "Using smaller cache sizes" below). - - The default L2 cache size is 8 clusters or 1MB (whichever is more), - and the minimum is 2 clusters (or 2 cache entries, see below). + - The maximum L2 cache size is 1 MB by default (enough for full coverage + of 8 GB images, with the default cluster size). This value can be + modified using the "l2-cache-size" option. QEMU will not use more memory + than needed to hold all of the image's L2 tables, regardless of this max. + value. The minimal L2 cache size is 2 clusters (or 2 cache entries, see + below). - The default (and minimum) refcount cache size is 4 clusters. @@ -183,9 +187,10 @@ Some things to take into account: always uses the cluster size as the entry size. - If the L2 cache is big enough to hold all of the image's L2 tables - (as explained in the "Choosing the right cache sizes" section - earlier in this document) then none of this is necessary and you - can omit the "l2-cache-entry-size" parameter altogether. + (as explained in the "Choosing the right cache sizes" and "How to + configure the cache sizes" sections in this document) then none of + this is necessary and you can omit the "l2-cache-entry-size" + parameter altogether. Reducing the memory usage diff --git a/qemu-options.hx b/qemu-options.hx index ab1a3b240e..f9fe43a4dc 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -746,9 +746,9 @@ The maximum total size of the L2 table and refcount block caches in bytes @item l2-cache-size The maximum size of the L2 table cache in bytes -(default: if cache-size is not defined - 1048576 bytes or 8 clusters, whichever -is larger; otherwise, as large as possible or needed within the cache-size, -while permitting the requested or the minimal refcount cache size) +(default: if cache-size is not specified - 1M; otherwise, as large as possible +within the cache-size, while permitting the requested or the minimal refcount +cache size) @item refcount-cache-size The maximum size of the refcount block cache in bytes diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 87965625d8..19e8597306 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -109,7 +109,6 @@ $QEMU_IO \ -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ -c "reopen -o cache-size=1M,l2-cache-size=2M" \ -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ - -c "reopen -o l2-cache-size=256T" \ -c "reopen -o l2-cache-entry-size=33k" \ -c "reopen -o l2-cache-entry-size=128k" \ -c "reopen -o refcount-cache-size=256T" \ @@ -119,6 +118,13 @@ $QEMU_IO \ -c "reopen -o cache-clean-interval=-1" \ "$TEST_IMG" | _filter_qemu_io +IMGOPTS="cluster_size=256k" _make_test_img 32P +$QEMU_IO \ + -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ + "$TEST_IMG" | _filter_qemu_io + +_make_test_img 64M + echo echo === Test transaction semantics === echo diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out index 6a2ffc71fd..2c080b72f3 100644 --- a/tests/qemu-iotests/137.out +++ b/tests/qemu-iotests/137.out @@ -19,7 +19,6 @@ Parameter 'lazy-refcounts' expects 'on' or 'off' cache-size, l2-cache-size and refcount-cache-size may not be set at the same time l2-cache-size may not exceed cache-size refcount-cache-size may not exceed cache-size -L2 cache size too big L2 cache entry size must be a power of two between 512 and the cluster size (65536) L2 cache entry size must be a power of two between 512 and the cluster size (65536) Refcount cache size too big @@ -27,6 +26,9 @@ Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-c Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all Cache clean interval too big +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=36028797018963968 +L2 cache size too big +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 === Test transaction semantics === From patchwork Fri Sep 21 17:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C20B913 for ; Fri, 21 Sep 2018 17:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 802C02E3AD for ; Fri, 21 Sep 2018 17:32:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 744E82E3B0; Fri, 21 Sep 2018 17:32:11 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 E78852E3AD for ; Fri, 21 Sep 2018 17:32:10 +0000 (UTC) Received: from localhost ([::1]:56748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PHm-0006BN-CL for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:32:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9u-0007wt-Tp for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9s-0004D9-3g for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:02 -0400 Received: from mail-eopbgr730091.outbound.protection.outlook.com ([40.107.73.91]:48030 helo=NAM05-DM3-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 1g3P9r-0004Cn-TZ; Fri, 21 Sep 2018 13:24:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hq7Y39ay4+tmKH3XNGWuBvnQzMTyNsgM3UShWGP7rvQ=; b=L+4mXYhTBuelanDzE9JQJxjdd4iOjBcu8+60ffM424bFtqTBJYthN9cm8YGkuzF1/ihWQ+hoqhPqBaeYLSminxGH4tfkcgjW4ba+58Kk5K2DJuxEOJ5i5jE1bAcskQOdJMu8vclAS+tXfXkSAcD+VFFbx2PwfkFWELxyqikmZTg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:56 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:07 +0300 Message-Id: <20180921172310.10068-7-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbf6b5af-6166-4f0b-5bf6-08d61fe703e3 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:CpadpiLQyNT4LfFF2Ip8EnFlJCFo9zKoZye5t4dF99tqC6U8mfDm27+fWwX5IpsssI36NtovwSfyPUhfQeIIH301pa/IIuA2dXlzsAu9c08Y4G1aK19WB1JvnN++3BopojSe5DDdfNaEqMdfxAk6wVHPljgXXuHWK98ILJiujn3I0U24KaF85mu6NUq7h43KE/eVrmuMe/j7eYsKZZQXw0VSNpOf8WZ1FqnIUj9DEVVLVFxqRQd95yqwjPpbN13e; 25:3fM2LJqncabBnpzJvx0G660WO4dEYgGnkFiKXalIqav1fPGlh1c5i1R+jzlwU0GiNH/xEDc4YRuXJeY7oS4otgJwQmarW+pM52bsMTFqxR/+0qN6fSL0zWiKMNAZJiHTnxk6ADN9dNtcL7CaD51xzkBN7wUixmqXKGtg8JUtblrs7Z7Tibb9Q8sLhMz5VRgumqk579yNZDMe9eh0EEK1Xno04rNIFKHBTlZEEv8gcxaZKi6J10cu7QTIQ9X1ZVPdYtb3qhgz3IqPNycY/nUw75uBh9DNYNjn+boOi8nPqgZyEHcvz+MKWly9vFVKFsCc4ifsRWuIQSOkXThorFzVTA==; 31:tpm3qX+T0wWbCmq9HS/Pu5373R5CIoLUq3wxVu5YKgi1Q1xvdmCo4JrcUZckyT7bjgFtRRkj0gqcxKmBF5VPbU4sy8t/ihd9EmXWEf/lM1GZuV2vGR45F7pbekrvYYasOBjC/BR/A1TTvrnWobtVOLJXCVJgnceyXfiCDdO8Z11v2+his0JsEdLNW5+iSBt1soCFX3yHYIztDjxFUIvd3ETNax0oCqUMsDa9jw9P25I= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:3f32TZBEsEgR15vyjv6hZJ/J981km74SVd8uQi1r1HGdPrCmiuc+O/4TOUs36Yc1v9pkUepoRzx/cVfUVouZhe1EBLudFRbDlgI9xY/0TKnMXUzzpyxcdsULGjQ1sPk+emYcaHS7F21M5ct+qvDZ8M/Rx+DsTDF+QOdIt4pUXSd+jZR8cdQtrI9RpBhCDhiex27hyt1fcWEo/VGeZokHLs3jz9ckAwvtVpKTnXJ++AlFNhZHiCe+HD7LHdq0ubAJIcedlEUcG9LbnumS5FOmuQ== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(575784001)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:+pHZTIQ1PM5BVIdiqkhqzT0pfSpcpI+QuFT2sTA0K?= ancUqsp5zX1J2FmES68FE++ONOYgMY2W5c0KLfVF956UWQ9jBawRMu7cGZ4XE0Qb/IZFxUooBJP3hGmPXs2YWQDkUAFmJXeEktlFdhZXuGBIM+4i5IjITr+D7BuJ7An/Qo43dvlU1rugLxV+d/9MYkjnK0oKKBRdevTs+wvHqfB7WSs93QUtaRv0BOd4smypJIdxZfHHxSgfYf2HMOCLLN8SO4UMS7SVtn6JxZYe5YhIZ6Lf0xgwfqxTBBGHZn6qa5yl3aONi0/nRzp3tUHlc8qFFz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aLecl3jloFl6xBvx+0p7RbQGeFbFnX/7W7FEbv4IXR3g3+Ajos1T1znMZM/0vm905KEQbqo4TFVjmk94CHQNYdZ2xpLWDyLghT9fKKDXB7N51t9onBUq7fCxRJyEkabKDk+irbUoK2c2bSLsVnH/jru3HSRIJF9IvQCjGOLH/Dnisuqb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:56.0298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbf6b5af-6166-4f0b-5bf6-08d61fe703e3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.91 Subject: [Qemu-devel] [PATCH v10 6/9] qcow2: Increase the default upper limit on the L2 cache size 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The upper limit on the L2 cache size is increased from 1 MB to 32 MB on Linux platforms, and to 8 MB on other platforms (this difference is caused by the ability to set intervals for cache cleaning on Linux platforms only). This is done in order to allow default full coverage with the L2 cache for images of up to 256 GB in size (was 8 GB). Note, that only the needed amount to cover the full image is allocated. The value which is changed here is just the upper limit on the L2 cache size, beyond which it will not grow, even if the size of the image will require it to. Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.h | 6 +++++- docs/qcow2-cache.txt | 15 +++++++++------ qemu-options.hx | 6 +++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 2f8c1fd15c..0f0e3534bf 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -74,7 +74,11 @@ /* Must be at least 4 to cover all cases of refcount table growth */ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ -#define DEFAULT_L2_CACHE_MAX_SIZE S_1MiB +#ifdef CONFIG_LINUX +#define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB +#else +#define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB +#endif #define DEFAULT_CLUSTER_SIZE S_64KiB diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index c84cd69cc7..5965d3d094 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -124,12 +124,15 @@ There are a few things that need to be taken into account: - Both caches must have a size that is a multiple of the cluster size (or the cache entry size: see "Using smaller cache sizes" below). - - The maximum L2 cache size is 1 MB by default (enough for full coverage - of 8 GB images, with the default cluster size). This value can be - modified using the "l2-cache-size" option. QEMU will not use more memory - than needed to hold all of the image's L2 tables, regardless of this max. - value. The minimal L2 cache size is 2 clusters (or 2 cache entries, see - below). + - The maximum L2 cache size is 32 MB by default on Linux platforms (enough + for full coverage of 256 GB images, with the default cluster size). This + value can be modified using the "l2-cache-size" option. QEMU will not use + more memory than needed to hold all of the image's L2 tables, regardless + of this max. value. + On non-Linux platforms the maximal value is smaller by default (8 MB) and + this difference stems from the fact that on Linux the cache can be cleared + periodically if needed, using the "cache-clean-interval" option (see below). + The minimal L2 cache size is 2 clusters (or 2 cache entries, see below). - The default (and minimum) refcount cache size is 4 clusters. diff --git a/qemu-options.hx b/qemu-options.hx index f9fe43a4dc..d5f4bcadd4 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -746,9 +746,9 @@ The maximum total size of the L2 table and refcount block caches in bytes @item l2-cache-size The maximum size of the L2 table cache in bytes -(default: if cache-size is not specified - 1M; otherwise, as large as possible -within the cache-size, while permitting the requested or the minimal refcount -cache size) +(default: if cache-size is not specified - 32M on Linux platforms, and 8M on +non-Linux platforms; otherwise, as large as possible within the cache-size, +while permitting the requested or the minimal refcount cache size) @item refcount-cache-size The maximum size of the refcount block cache in bytes From patchwork Fri Sep 21 17:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 870685A4 for ; Fri, 21 Sep 2018 17:25:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F3D2DEB7 for ; Fri, 21 Sep 2018 17:25:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E4022E35E; Fri, 21 Sep 2018 17:25:36 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 B2A632DEB7 for ; Fri, 21 Sep 2018 17:25:35 +0000 (UTC) Received: from localhost ([::1]:56711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PBP-0000sn-49 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:25:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3P9x-0007zA-9c for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9v-0004Ez-5U for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:05 -0400 Received: from mail-dm3nam05on0708.outbound.protection.outlook.com ([2a01:111:f400:fe51::708]:58740 helo=NAM05-DM3-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 1g3P9u-0004E3-S3; Fri, 21 Sep 2018 13:24:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U+Plu5YJaZ5toMP22I/9oxo5JqDx9GRQe5EJjyUSoBY=; b=WnSs33GKA5PIFiObUIdNUJfAJMvr41ZWTswCc0hkhXVak/xv16sbO22vK9ZsLYL9ZnjBp8sggUX9mTfDBfCI4JmvSindrKTfqYESkuvmdvTatfVe3phsFi94EIWQBMklcHlFqaN31L1VxFjItudygJ5H9+yFnToD/YUj0KaqihY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:23:58 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:08 +0300 Message-Id: <20180921172310.10068-8-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1277bdb4-0a27-4bca-d327-08d61fe7059e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:amdfMddQ6ETuAMSOVDMoctJarWob43Ou1fILJghE+6zVpgZYkpl40EfFzauMBzNWBlX+D52/s0EaIkxiqSnU2mWk/BgW78MJKVwih8kqEOGnKB3sjSZwsKZ5On4tYChqiKo0li+A9EAzqRxI5b1Avmo2lfmQ4JAUdR62KMiDWTFvekqi1fBpZ1Y4pl8PCuSUiUYWcj2N1YRJmSpTKfOjDczLT9X1PzcKyQvn0mf3x0evecUibqCqACeJ9tvEEKrb; 25:EcYR6m29k+QM+hn2b7w8h5xHfJQpyTZiEJqJTN2aY5HaNv38krCVYUfHASCOsIOM7SW5fTf8WqEJHxb2hwNXYnUtPe/zv2VWE2VKzbybDoJYKWnc3Fax57OKbeBT+ehLtl2g4RsZ9HMCaYmImZ8M/tNL/NIR1tg+7R1FiJ3ickqz2WRQtU3hKnsNJu82qckR4gL4gJTinlks9IGmzqIQ1Ip3Wb620mU/OLiPKnsd7GKTqXvvV27DoukxBJZ13hhCfNHLZtxIq6ckjihd8NQ2ebK3NItnDP+HVFQXYsrdxXTAdWAIlxJUai7SeXinuiy0qy/EiVNaqEF0t04DpDUKiQ==; 31:zOaahMQYt6judYUP9NFpztgsx+wiS0Sdx4YRTs0SQjW2YmiWSwtKPZll3vh5+OrrCnUCFvLXtskojKqwj93W7b/Xk1w8zC34/yH6Y6C4xva4rVBvoPvtNpNoU29S9rgZj2pzf1QMy+hwrwJxgYDf5cTXC8RLryZdxHK9lOi+mWdBC16gdMjnmZUGnz7hgqX96wcFgDlHk5yIDIdByQhQXRG8BdMxhlhTyGC+vHUS3Pg= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:710wz62O1tskMft6D+F7zK9sHEriDbc0etQjk/g1KTMA0sC74fji9p8WoEfy4U1YTayx+cITNOyTYEhaUy4kmGHrffVG5p64hzu9IsJvfdErnjMTtUAW70y9zaJHM68/0EujwK5u04aYwCrqs0F173PCWbyGgUeeBq5mirWH2WVSa+iJfnY1DZPXspsBaCYPTsirO0i7JyULrGlZdc5xxYDUScKciNe3zLGFxFYRc0OMWA87xhZKu60eFr1D4qvi5wLqAaAzQ6UNYKRE6eyTog== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:0UVjeY8FEk/mRfANMrMQ7csaGpP8rllRs2c5f1Xae?= khqpuq7u0ghYU6qyZatZd/lqlBlUj6sNXo3NJQuU4yp5ZhhA5FjXG5VjK8itT9PbpVVW/vnWnmn/i4pY04EEjHo97SvdTfRZWwnFtpzhg7lg0RiDdnUf+nhWx3y9L5accmy6W9RY9gOfoxR9fBuB3kb473da83cx+IxUichfSpMFKA5HIdqqnSnNJj+us81bCAemCkbez7xIF3hVQ8iGRKP4MoHAgl8FeyJ/JwrrnEEF9e0nNS6u8PLkXY/n455T17cvwUwvpyyAEPVxTjK6ZUmwZypzJ9BtPkxmj7+0X54W0E4PQW8/5a7Kb05o9mH1ABk6S8EpQEFzHtYa8IeBA2swRqIO2zvjc6evtKEGYPmjJs6ypGToxG1W6R2q9Eedt8/a5fBdHFz74XwTY7wd3k6qXaySN6ekAhAbdMZuFrtEEiqDuk7wN0BnVUpp6jAqddN9Dbr8AGwPVaILZ2DmihLycfQfYxD2IShj0+EptauHPxXjJdd0rPH1xyfCxsmp5/mD1zybENudBHM7ypsKaarw8SEC06lA6YADC0q6noUW48JOEA62e37fOxnWfM8u/3fg4AnkFtTcHGk6SQJg8NCIffbFvitFqSf6hoa7+Ts/YQFbXfFFuAr1qtAI+lZWAKTGgvJ9Wqb2Nv7b3lyeBd3L114qkVUMXQ1yKxmRdN/dI1WJJl2UyR6m6PfQ9+q+XfiQRFFjoAFml9S9j+THYxxqnIl70Fa0JuF4ZJQ1TZazHPY2TzXATVr4BT+iZWn2GEXoVgh6J71RBOezEq7OdBPFrM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pIvdKxrizOZ4hiEQmiXffzTV6qbS33vLo0jG2JQmgSlRpSR+nVg8b43RjIhx85dAiC4YtH+omZEn2JQgnBfhQKlMWDsI9TBBF6v0NeNxcULb+nOg8Cp0qdJ54ISAdNj7OdKg8y0L3XEwgAMcGLTpLXAqzMMuCGMoPBjVIGImZuF4G+iLDpFrBkl15e/7+EzclXDbZ7PDgEIUo6Bri6LwFt+Ums8KMnIREWlPMhqIR0G1ANwlFniM7mv1szkFdvrXiht6V4WPB/6ELPbMYodjdiLgkM1QjuFg==; 5:MlbLCmwtjb7KFPC9WcV6J/mJDte/YCYWKi8uHXGIyugP/oe1N5vGvczuVnZ561a1ib7Awbmh/Brn4/CKwQGscWZvZ3oTcLJpxUNXLjvodFGxl4FO+umr2yuE5rerMAKFhupoSjifu2ux8PcZHe8bUQ9NK0c9q2kR63En6FQLF/E=; 7:fjo0wiFrNPrHE+Hwbx2FXYENweMSvbrz6xoqa31pYsUZYn3QSa6XsAwmr0/J4eihk0mK6rGcEU08zHwNEzJM2ct9qqsbY6qgvX17RLiJLzTFB0I+OMLY4rUNLC6XaJ2LPlUx3vr4r1+SocPfXxm0giZ4b7NTQP9m46FaIitHSxWQ2zxOl/rq5EE/H7Njd1oLxUmCSTexGa0ER8V/9HWeNPNytTW6vU+B0wb0P/NjvNsk+r2KoBT/NlbCBkSwNcRx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:23:58.9204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1277bdb4-0a27-4bca-d327-08d61fe7059e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::708 Subject: [Qemu-devel] [PATCH v10 7/9] qcow2: Resize the cache upon image resizing 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The caches are now recalculated upon image resizing. This is done because the new default behavior of assigning L2 cache relatively to the image size, implies that the cache will be adapted accordingly after an image resize. Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 01c39c56c0..1445cd5360 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3418,6 +3418,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, uint64_t old_length; int64_t new_l1_size; int ret; + QDict *options; if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA && prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL) @@ -3642,6 +3643,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, } } + bs->total_sectors = offset / BDRV_SECTOR_SIZE; + /* write updated header.size */ offset = cpu_to_be64(offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), @@ -3652,6 +3655,13 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, } s->l1_vm_state_index = new_l1_size; + + /* Update cache sizes */ + options = qdict_clone_shallow(bs->options); + ret = qcow2_update_options(bs, options, s->flags, errp); + if (ret < 0) { + goto fail; + } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); From patchwork Fri Sep 21 17:23:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C8CC5A4 for ; Fri, 21 Sep 2018 17:25:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31002DEB7 for ; Fri, 21 Sep 2018 17:25:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53AB2E35E; Fri, 21 Sep 2018 17:25:38 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 5252D2DEB7 for ; Fri, 21 Sep 2018 17:25:38 +0000 (UTC) Received: from localhost ([::1]:56712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PBR-0000uv-L4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PA1-00083y-Ui for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3P9y-0004HM-Kq for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:09 -0400 Received: from mail-eopbgr730118.outbound.protection.outlook.com ([40.107.73.118]:28896 helo=NAM05-DM3-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 1g3P9y-0004GO-Bw; Fri, 21 Sep 2018 13:24:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qkvqMl9Ufkd6JNzfUhiYAQZqfe7XtbpeEH01j0MnkPY=; b=CmC8vbFFjpAZQNFvsXQ3Bmk+GxCQRkwpbFeOpfSx9vOnu+1uqJjqr7EkvyGLfsbEMe4+reK5eMA/DNjiGseLJ33hSDH3xQNv1COqQY5HZARxCA8InbRO0a4OfKpixy+zoiOQl98bYTUmpvuwfxXAThvfxTVrUEKVvMoV53x0yDE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:24:01 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:09 +0300 Message-Id: <20180921172310.10068-9-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84ae9a9d-819b-4b9b-5e4c-08d61fe7074e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:vUoT9Wt0uW70AlF/PTM6f5mM1IVGaMc2KCC4KMExLm91vdIoa4R0sn+IrHhSXNbdlPzKYr8GwRv6JeP93dYFd5l3OtZjFme0srGzGN7/sAgvfoGLF/Zd97J+ikXC8zo9VFMKAuarNgvURII49o+UbjgVQ7XPWUWru9Rk4Qe8I/167VfqLWzhoclFMXkMd1rhds09XBfDN1FkeJpJzrGIrvnzoB3RtaY0+j0GV5DqWpUfkrkbsfMky71toGjhLMt9; 25:bPEaqHOZ12ueYQJ14NEWb5RxGijGyA9vuYKwT8CliqQkSofNWyeqta6wqcO2VTvKRMlI4rDDD7r6KGJp51VEnb0n8741ufQAM6/QYgskZYcImZqrgI83s6SEAL7+k7Ja0QHNR/cD3QeVn73IWlhFYlLvm4SV4O3UvfPs2pVPimQQmHuKqzo8wFGbd7pWTccBa/eD59rRvVOWhXSPRpPwU23KpYcQ7cx2hcXbD88xlfRVREd8aBbRv7KK7YoLBpTjsDIE/rmjp857bt0Me4XxcFPOTCQx52V/7JTpD3zSLHar4ZhuCTzJva3GxQsNSICjFocCKXhaHNUxkuqzXnQXxg==; 31:aBauXHtG9jA7kVliVt9gutGgswb3xTJxuRZwxB8tD+f9yol7jhI/lOCD79zonDFxoRx7rtcKmOeojrQxXFyUEsGVRVCKfMh8JgyeYSLcS5zzThs5Qr0AIkI9DyUDE6QJDaTz5FeMGvKo782C7yMm4ALi9KFwWQ9eofr6g15qRxewLTUO55TnYST5wEhGA1Oqr4Q4khje3sfr6ZLtRZeYOd13h3srYw7mGosR77TMqWw= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:e3UMuK7ugi81am1muvZkfBliscA5gwWUf+8+Z4sR+csEQKNgTytCI+1yw9PVftkGJrs4LM3Z+kHoNdJPH32ricU+syIfSuhWgURw6Eospsv0Eu78AhDxHWMt+/2NzpkLZu98n11xB/L6VxwJh7/pybKQkle0Fzi9y9hgWehCqwG22BqgGUVogqfZPTyTYo9BTRMWqiC45R+9nsnlPOzex90BaWRQoWsIA2a//zn9ckKqY8o4gFUbbWB8eLy1LjvXVzRjIZHqVQzGxeH6OWkDRQ== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(107886003)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(575784001)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange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JcRSCikEFxLE77cFZuN/ncoNRoz/YlKzlRannTjkuQG7YGdnOq9ANlF/gN7Rpf8PY7miSKhvRZomJsL5YoQ5TrHdBpW+iBnSHkyT1FQkRYLKru8bDHkgTgvuABAFa1TAoqApsaStgJqSkYlK9RARd6b2dp/pd+ow9HykUlXyiXuRU22TadmwH4lOPhqLbD4RGuvZ/VTKAMWOZXNNW4QhfBRWlZoXGQvh9R78ujSIfBVd/XBywlQ2a8+XLA8gBoY4yN/xLbMXm9jWRK9ddA== X-Microsoft-Antispam-Message-Info: 0yLCvDuRkqbn+3mh1HpLgqo2ifk46eLNu5//0mMPcux+rP1uZgK+NRu+ZyeZokg/Z5l7BC0Os7fYGNR2RCtFRSo+feidRSk0M9DUltSie7Sz+gM/fghPuts1BPmzUbbReNMGWrooJbDHTVO8pLhP/mOFSc1Fl7E7zsNotQei2awEIKqDA6I+jRHEJouxT2Pnby1+AT+WhsKxG+fDC/cTzDRYOecFhggjEt5s2s6qRIE+VkOx7xV76YjtmB0kPADlHvRq+4OKlX1U0QhKPJnzmKI9iec+GMfHRQGwUuXIed6q06jvB72Ex9OVo6fitEGB0c+bL05i3iYroQBbH2h6TCOh0m5wjwU/3NTGM1zBnBg= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 6:+DHNnm9JGLbI6XM8zOii2103M6ust9k4llHwTBeWPPId5k1NvGKxeTPeCCQXe+8gxowldr6aYqJTjN47R1UPq/3K8bWwzXIAjDg55W4gXENrmhuTyZcdj8RTD8LERN804CCTYhAqTttlnLCyN+LoDlH636zccxXhabI/nqVYouni5roE47yMbCNFWIy+OekmmbIrAn1FPA83aBvWjU4JiLgjIUhE4pGxkrfTVkuEYGO1E64PBoyRGPzFlT7REWPeb/oOoh+aoArE81yzXUE4B+DXCEnpJYyUKrYrMyoF/0KrDObw1qaXcGTEzdNNZC4my5JZdYoNA6SbPHFlCSaS+tVm3em8IGM7+V52c7kx+kV039ZDd380JUbtnxHYtnw+3p9mdoBkLbMnME2KJ8rfI766It+tIl5KVB9I1S8VbEPAw7/y9nS4VrqDhkl5cwqvpUXSdJzVCcrBlfoX8J8TIg==; 5:L5oDKY4jhfllx6h1xOn5nv5l9TrZo5O+5x1n4xN69MniLUuG7CUOybMXzf4RBAimQpbuPQ/uPFV44AcYMSvBuEyjTUcLte3oUCubjIgdBW209K6vRqfjmVuAX42PadsgZKzVT68sxE8fr9T4g2KSArg1cIbaf5AarEij2UK3dZc=; 7:Oq1jKeYDfBK0Cy54vCPQ5kTMulHsmdw6lKLrSmpMESy1dT7PN4zIDbTmQW92/xG5+juHJGbxDe5Pk+nqlEJhJvSGKtCMPjV5O4oV2tQ9Z64tB4aREqRoutAx7h8AuWwwlhFzYrm2T9IuBkMtSN7thRBlW6gZ6m8FAr24IY8dPHJddS5fJZXljUSulpbK/SYq6Ey6rqUCgk5z9KWAZUINan/YH5yWlKIJCjrpHHzZ9XXEYidQn98q9BGDtDpVIDXO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:24:01.7642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84ae9a9d-819b-4b9b-5e4c-08d61fe7074e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.118 Subject: [Qemu-devel] [PATCH v10 8/9] qcow2: Set the default cache-clean-interval to 10 minutes 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The default cache-clean-interval is set to 10 minutes, in order to lower the overhead of the qcow2 caches (before the default was 0, i.e. disabled). * For non-Linux platforms the default is kept at 0, because cache-clean-interval is not supported there yet. Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 2 +- block/qcow2.h | 4 +++- docs/qcow2-cache.txt | 4 ++-- qapi/block-core.json | 3 ++- qemu-options.hx | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 1445cd5360..f885afa0ed 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -944,7 +944,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, /* New interval for cache cleanup timer */ r->cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, - s->cache_clean_interval); + DEFAULT_CACHE_CLEAN_INTERVAL); #ifndef CONFIG_LINUX if (r->cache_clean_interval != 0) { error_setg(errp, QCOW2_OPT_CACHE_CLEAN_INTERVAL diff --git a/block/qcow2.h b/block/qcow2.h index 0f0e3534bf..ba430316b9 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -76,13 +76,15 @@ #ifdef CONFIG_LINUX #define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB +#define DEFAULT_CACHE_CLEAN_INTERVAL 600 /* seconds */ #else #define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB +/* Cache clean interval is currently available only on Linux, so must be 0 */ +#define DEFAULT_CACHE_CLEAN_INTERVAL 0 #endif #define DEFAULT_CLUSTER_SIZE S_64KiB - #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts" #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request" #define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot" diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 5965d3d094..15ae797931 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -209,8 +209,8 @@ This example removes all unused cache entries every 15 minutes: -drive file=hd.qcow2,cache-clean-interval=900 -If unset, the default value for this parameter is 0 and it disables -this feature. +If unset, the default value for this parameter is 600. Setting it to 0 +disables this feature. Note that this functionality currently relies on the MADV_DONTNEED argument for madvise() to actually free the memory. This is a diff --git a/qapi/block-core.json b/qapi/block-core.json index 4c7a37afdc..08c27b9af7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2827,7 +2827,8 @@ # # @cache-clean-interval: clean unused entries in the L2 and refcount # caches. The interval is in seconds. The default value -# is 0 and it disables this feature (since 2.5) +# is 600, and 0 disables this feature. (since 2.5) +# # @encrypt: Image decryption options. Mandatory for # encrypted images, except when doing a metadata-only # probe of the image. (since 2.10) diff --git a/qemu-options.hx b/qemu-options.hx index d5f4bcadd4..2975fdf9f8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -757,7 +757,7 @@ it which is not used for the L2 cache) @item cache-clean-interval Clean unused entries in the L2 and refcount caches. The interval is in seconds. -The default value is 0 and it disables this feature. +The default value is 600. Setting it to 0 disables this feature. @item pass-discard-request Whether discard requests to the qcow2 device should be forwarded to the data From patchwork Fri Sep 21 17:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10610741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C19575A4 for ; Fri, 21 Sep 2018 17:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6D1C2E33E for ; Fri, 21 Sep 2018 17:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AC982E354; Fri, 21 Sep 2018 17:28:28 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 235D52E33E for ; Fri, 21 Sep 2018 17:28:28 +0000 (UTC) Received: from localhost ([::1]:56725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PEB-0003MV-G5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 13:28:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3PA2-00084m-SD for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3PA2-0004Il-1L for qemu-devel@nongnu.org; Fri, 21 Sep 2018 13:24:10 -0400 Received: from mail-dm3nam05on071b.outbound.protection.outlook.com ([2a01:111:f400:fe51::71b]:40250 helo=NAM05-DM3-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 1g3PA1-0004Hz-N1; Fri, 21 Sep 2018 13:24:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+KNjyg4kkc/w6krUNmgeM64EvRCavZPcNlKd2Xxy4SA=; b=qwUAp4YzzERDI76s4ULzANf9hAKOfzQBXFzpa2umNgAT9eSn/3baRRJS/5ZJO9m2dq31Vg5BYYO4aBJjbiYdx1BIjon0EZxwN9O+t30R0OUN4kG24oAABNiPF65qH0Gq+EW0GlYM+JeFSSVmpwCvEN6UNguVJEKdKGZ2MyALnQg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 17:24:05 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 20:23:10 +0300 Message-Id: <20180921172310.10068-10-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921172310.10068-1-lbloch@janustech.com> References: <20180921172310.10068-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR08CA0065.eurprd08.prod.outlook.com (2603:10a6:7:2a::36) To CY1PR07MB2618.namprd07.prod.outlook.com (2a01:111:e400:c637::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d7a9a7e-0a58-4d3e-e70c-08d61fe7093b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 3:astMrqgkIL/O0DbjL75qXpRFeyA8wCLfWjh/jvcSXDQPGh4l6iUWClmEJyiLGdIk6dsJyXxelRIPSBQ5+9MiYjaM8sNu7UzWaSKSI96C8wggO3uw9QCALSt/DD/kbiY5cY9dYEHdTXguvpPvif9/dOB4F08+N5jA/l9kPP5FI4Q7cOqqZck21+b5TNWHZ1qlvlnzHN2sg2AbQ8nrd26lSEmm362Hli4Cm0/1ZnOXZCnTVn5Xm18braPRfqbv0SR9; 25:dHJDAmk99rttS6mXqMMysTYfl0aJVX/7XaqaNh736uu7HNVAk9oLSw3TEFjw69cRWCb8O94PDWFeoKzfxhCXzFw3ehZvZfHWqcAhIc6RO6laA8HqCxmF5sk/D3c3rEWL5l6DAIsSL7Dpf6bbNYB7ZbwhZucmuC+ET+1/7fcLod1R8gszNpySN5coTSBXkJDKupk5e0C2Z6wywr4wSxBuEjDnBCSBzieexGK4RJgkWnjtBCkcI3V7s9S/Rvk276ogdqNf9tCZtLfLBoRx2KSfuJHVce4GEPPiLlI1I1ywKBcouG1YmFdwCub/BpDGJzt6Amtks+cE4lc48d++KPUwHA==; 31:ig22fG2ns0lABdt6wurUXzodekRdrKQfzU0cFMNFCDQRnAPEbMq6Ltm7rGFxyFygpZtUSpNjqOpiQzZAwXIpwp3pkxZroIQmD8uOZ/Np5Ok2eUmcAUOs0oT7v8LrjhQk4vfMoh7vQHmRYJdukppxn5wovXwzecCrj3gQ2mOWjx+6eNpCHrxrpuBU38X71EYYe0LQq6xjQf5ghHLowZjvX7PJ9DUE9IgnIoQMgHtEoeY= X-MS-TrafficTypeDiagnostic: CY1PR07MB2618: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2618; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2618; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2618; 4:B237kalYO1o4DT0mmV2ujVJ+bS+nRsOXQtb1VkbbZRtflqAxKy6ZRbYEiKGktQUoPgYZ+xf60Px4BCaG0XkG0EbwBPZyHWoXlkDiwsT050wVvqJoIZlUMdDxe3xqHG7kRfeoylk7CfQzJiSs8Cov3Qv/NEjsAjK4CxMbgWZbdQjSddTSO5rAcA87C8Iln2O797JQaEVvANzQ4V1Br/UxifXcNQ7CncClYNSH0Li04Eb280nJfCwfkyUOTHxk5PCPvvDQqSib8vh2+By6XLX+cw== X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(39830400003)(346002)(376002)(199004)(189003)(86362001)(68736007)(50226002)(106356001)(8936002)(1076002)(2906002)(6116002)(4326008)(53936002)(305945005)(8676002)(7736002)(5660300001)(81156014)(25786009)(3846002)(6486002)(36756003)(6666003)(107886003)(6512007)(14444005)(11346002)(81166006)(97736004)(508600001)(47776003)(105586002)(2361001)(186003)(51416003)(48376002)(6916009)(50466002)(486006)(54906003)(476003)(956004)(66066001)(6506007)(2351001)(16526019)(2616005)(386003)(575784001)(316002)(16586007)(76176011)(52116002)(446003)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2618; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2618; 23:mmguttPbR5ODBBNFgYFJ90tFPwW/Vwhi5qww3MmkD?= nuUspmbTvuHhc7Cuh1GiHPSuHBo2Sejeb7w+lsQRULyXbPOr29yVAXM8NAwgPo9LQ0z0JUSx62w0KLPrz9dWpcwiOI2XIT3x2aVzmuFndOFffxG3mF2UGMOBQUdyWKy+SDLP06POdRL8CwDjGe0nFTFS7IoFaQp29u0Xgsq7tVRg/8qQlmtHJ8u9pj6gkETqkeKe7Lzawv3lV3spJtNMaBFj2WvN76gwXRe8HuMb4wpitLNSGXEOxcwdaSiKECT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LchtjblxeUh7Oo2S57ux/8fypcGK2OthQIXPlIP71x6fw/mc5jUGyLjIDPR1eli3naESqmQERbrMhaZT8wjIll1I/fyqmqNZM2DaYw5xbIpxySMZS3BdvbGk/ddQ2fg94DIIvhVo0/pk1mnn/3Sj7B2woBeAJq5PnmVoDtQYeaC6G+F/ZEnWt6FSG0TyShazL2gftJBfG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 17:24:05.0143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d7a9a7e-0a58-4d3e-e70c-08d61fe7093b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::71b Subject: [Qemu-devel] [PATCH v10 9/9] qcow2: Explicit number replaced by a constant 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch 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: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f885afa0ed..ffb4a9e4a1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1324,7 +1324,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, /* 2^(s->refcount_order - 3) is the refcount width in bytes */ s->refcount_block_bits = s->cluster_bits - (s->refcount_order - 3); s->refcount_block_size = 1 << s->refcount_block_bits; - bs->total_sectors = header.size / 512; + bs->total_sectors = header.size / BDRV_SECTOR_SIZE; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; @@ -3450,7 +3450,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, goto fail; } - old_length = bs->total_sectors * 512; + old_length = bs->total_sectors * BDRV_SECTOR_SIZE; new_l1_size = size_to_l1(s, offset); if (offset < old_length) {