From patchwork Wed Sep 26 16:04:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616095 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 C156114BD for ; Wed, 26 Sep 2018 16:07:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD38297F5 for ; Wed, 26 Sep 2018 16:07:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEAEA2ABE9; Wed, 26 Sep 2018 16:07: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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4B1A929969 for ; Wed, 26 Sep 2018 16:07:10 +0000 (UTC) Received: from localhost ([::1]:59589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CLF-00033E-Cj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:07:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJh-0001pg-L2 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJf-0005cB-IU for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:32 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJc-0005XJ-SO; Wed, 26 Sep 2018 12:05:30 -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=1tgq17XXYQkOUeIPQU0OxDzOJY0e2i+q0WTcEhghDoY=; b=hOKxzqLvwcBq6IdK3VCJNORAdZea2RrkGig19+At6M+kGa77Y2tsBeu3jXpL1EfP6FMVw5uWvVzbyRsfwfRL3zIc2M+0GFzdXnfJr+9tiiFLkkM/0GyE2wTHy8X2XdiCPtvvwIWp2Rmyey0fqNS55cK5kQ3zPt2VcqYUGgtBH8o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:19 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:39 +0300 Message-Id: <20180926160447.5149-2-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e91f9072-59cf-4478-3f1d-08d623c9dc87 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:Vhww8J4Lvf7Cqfv80H8r9jYTUJ/7H3oLU21x0G04t/UlImGPGkP9HvGbqvhn86hnpBshKiinOJCdwKTsCRb+iKQ6nhkXeZepceYatEtASM7iFVYxOm4QR2gDBmoYGB+yjLpxYVHBF8rt/eOQYqv21OnZF8BbL8dOut6bPqxvV5zgT8FwktRsZq8zKblTv6DqXSrNj8p7pIvGDb8rdVPy7eE742doemO3LudPebqxJmUqUBuj+AXJekTFzrKR08g2; 25:MI0EgF3GRx19wWwMESGes576o1t9PpOlbjK2xD4KB14vTUo1155UaJ7x6QHCBAA16GlO/gFrqfhJZp2PQtyhMY+RXM250aQrqWWAR0jaS0swCajSvxhhlkXrDAXMaQAxppbn+4Ep3aK4b62jrzGssPd/IP54xidkodZsLUwRwsemoyHcUAgTwXwMvUQrQk1isN2izVv+B2l1/eMVwVZL1tTLL8dxo7eVPzj58/U8tlwaEKprJCyWDbwH6u7dneJKkdb+P/g5emDklWRcTcK5OuimxN6qsWw0l/BQlNmq8Q0wRqyJWT1d/1X+icLt/vaVwhNeW8Qk9tT1deloRGCSvg==; 31:TcAMdbv9idZ19+5ZuSqSo1XefAfHbxqP64t0naIsFZTA4O5TT3XULovK0xb7xNXSJcpXH8igKSbet+BNrQeCz6EmZ5cKehMH505zXOi7pQHeKG2bzT6z6pIvEvKgqx6qy/jepHYtVCP1Xd4VNlCdyu/A5xYX9ory4Fq7TVXg4RxhknMZjReOaI58lWcovU3wHE+hRodtMLk0YgfX8o04Obg6xgnyC4mgIEhJ/PqgcEs= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:/gD5jQatPNd1r+1z1A9Ju8KrvP1bBH0P9DVHC4M/tWtnABz9jOFhR8VuX1GinFspZF6PYo2gWpTh0jChSvXVGILpovrNJqBya53X0k+mZQ+cd5spKVcV7CirROUcxIctKbbrStddkZQWFGAbNbQAzpf05e6sW1+9fNEUUn0+Cha16uXmnJeu7E3tMfm6F3gEY9rMD4tb1kAXXElbDLdWFLRb4I37lFkiZbtx9dE96baarl///k5M3doC14wWAlQ7cCerbI3E/aRIWqzYuMx9sA== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(551984002)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:gY7Ss/HJUb8DPtcAttJfWWuFw329IXEWey2lFkVo4?= sFCeSieBk1q9hMGTAx7yWQBHwXkLutuOEAkIKym8eEpHa9atRbvnNO/5dsEXkfSxGHOcdKZugBEeAkA16DQnEVlKUBWcIaoPHVTblVIabtj/CQokSIc39Xt2stQYkpFiQBmphutoyaP9Zdzm5mcd2Ud2ZkdgyVQ4n1sT0C7GQ5nDUhNztTTCkBSlDt8o0IglrLnimGxr5vdy3zXmRgsKPaPPY0XjOGHdzYKbzdBuemKParcquRpDkBREZdG5EPQ2kVsQ1xK4eB0bYNoYCDFIjI6m+YmzVndMbR7/SekkJTkMl5OrVCE+6xL1Yc0r7z7LSXDj5/RA/JAygEO9oIAGDe9otii5LX2V8/J6SnxfWIAB0Cu7nIcyna9cEnEu7aofE8QPOyyDJVy4tONUxZXCjQTLi0J8IVaU0z19eM+eOSgDsnnsdgTjC77Eqm+DHOM1yyW4Or8E5f8CiginhDaJsjEzDSyWUkjzsxGROKs07iUf/bcupaq+7ERuxS6GqjonTH9ed51+RsxzjfnIagtHfnOLb/T4ozaQIHkEslPJsdnipcA3Xqqe6++cjQMfBdRLwc3JM8HRBx7Rf5rHYyKHrtmLMkUxsu6bWQUTXhs9NTIunEAG9cR0pQOFrT4buzl+VgPO+j+i5K7GOILnSeI0vAhX+YHoKN5aFfZ0xOeyTY7yB7uhFMYR44dk3MtzNG396jxw8K1k8KihBCSTOPhITFbXg5ardwjiMpQjMp6pIIYu2UWJ6DLbRQiD4z/D3hqEZbRV/bKnnjeUTe2G+98tGazv1c8Yp7LhlezeQkLOM7TWH96/njvLELi3TOQTvScfWN334pAKhuhBjBk+NtPpPBNsru80H9Z7Lt/aN18N2wN9sbklRrwc3h0Cu/uVrOm+9VffUgudnO91Ivd3EeEJK7eC77sxzPcIOTtUESv9STPPB+nh459hiUDBoHXFz7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/zqlpfmUnh63aan096xLyEqbn8fSicsF16+1hBDNuG3W+z/i2fMJWdih5CsnvMzeUP7trGTDRLwvSLDE25LFbFaK/GSiImQmKxnzceJ/7+UZqUWoEPdL2kLmgFNpEI/Bz8OrdESlsKYjJ4GuUUA==; 5:6pTsTCDoy5n1x2xmGVZJFyBkv0btE0BeXlnm510N0qRFnQmgFX2k6a+QpYivlY4MoeB8NJFwfuvxmnIH6ik9NqIPxN94kIIsNifUGUN4HV/i4nYpqXRqcWulMbg+W++HyFbgDQqfaNwMd8E//BrO6ttL2XbVp4GtAlUUTyPJ+oE=; 7:IxXBlNpb5gTfMlnrI3hpoMmVlhi58PxYlyE5HS5mVxSB0QICZkq4KT9M0CoDue8x/AMaL9jooVPQxJrRxC80mz9/4GC1Da0LIdZiIfjv05uqpGQP8ydTkt3C4bfMNjLlSTzhDMELBG0Lj6TQtVJF1GbDZnFGDnjzD/IF78MDhdvpXScPSj7lrLPi02VAKgwkbxLQMzJ/suN364cwCS8s7mYRO+GVRe5uA+ZeS4a5reknpRzBMgKt4NB8bkTH1A7K SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:19.2404 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e91f9072-59cf-4478-3f1d-08d623c9dc87 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Alberto Garcia Reviewed-by: Kevin Wolf --- docs/qcow2-cache.txt | 21 ++++++++++++++------- qemu-options.hx | 9 ++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 8a09a5cc5f..7e28b41bd3 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -79,14 +79,14 @@ 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 virtual disk that can be mapped by the L2 and refcount +The part of the virtual disk that can be mapped by the L2 and refcount caches (in bytes) is: disk_size = l2_cache_size * cluster_size / 8 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,16 @@ 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 + +The refcount cache is 4 times the cluster size by default. With the default +cluster size of 64 KB, it is 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 +134,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 a642ad297f..2db6247eff 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -732,15 +732,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 Wed Sep 26 16:04:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616101 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 28A62112B for ; Wed, 26 Sep 2018 16:09:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2151A2B356 for ; Wed, 26 Sep 2018 16:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F5782B3B6; Wed, 26 Sep 2018 16:09:05 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 6253D2B378 for ; Wed, 26 Sep 2018 16:09:04 +0000 (UTC) Received: from localhost ([::1]:59606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CN5-0004cG-97 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:09:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJi-0001qH-BA for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJg-0005f4-MS for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:33 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJg-0005XJ-7K; Wed, 26 Sep 2018 12:05:32 -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=DzFpL8RwAlrmQBmdow+UgCMSkw2NGLz4zB48sozedxg=; b=QTvo/XmrNBL8qPacRwMfK5bSf3c22QBR4hyW0XDTsgTdNqNr42NKGv3D0xgI9fLoTrcXNjbO4TKe1JKc1haA/RaeebGaEUHbGZTjjc4QakDMw9XJh19I9bHpW/Uj9yjttRv5TuACx7qLMtZhj6KZL99aqSD8mAroLW6awBNm2o4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:22 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:40 +0300 Message-Id: <20180926160447.5149-3-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2fafd561-c313-4330-d1b2-08d623c9de41 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:c1Tqu+Vni9BTzNy1P80Vctljvu2fM7YkBJXmXerVQvbdLxNi21WjgXS/FDr9WrCL+sVbL/3uFFrw9fEPQZv8ME7NRkmTRujNoRGHnqEyufEvS2zeHqxp2MtsiK246EclL2AVIaKQO/DrSLmxzLWs6SbZNeSk08o2x5TKwJnpXv7NqH0qmUlSknHcPwWuQzA1uYFWSCymeXI1SpRwbusFtE68MDpbPG6kaNy1LKMpOmxDN6OkFeqFJxr0s3U8+vpY; 25:5SqbrJw9tnJOeZJZYAXkDOTpIGheQxdb7vsbUGJuryfkTrURlzN4DFIf3rynJAfPPX2liTBHfeXZursKD2fFy60bdjPOhZ/PPo7RoXKJkdjNr9H0JYW8YnRb4xL9g6p4RZlyINmkRqsn27mdkTIL8d9a1VklJGhovIFGOVO2FxL3NYpZ6bUKh/WkUV3jQze0mYnSTTXeN1LL9guoCfbR31he62D/sJdvC622rDJ4TjyOt7G9eG5gd/tF+VMkNElll+xbO31RY8vH6UnDghYPZM0q72zmZOKEjHIpCX7K1Hn4EfRQdZUF7xfZHa5rIhhu8VCITnnofK3ar3vmEsjp0Q==; 31:0m6NJo3KBo+oItKza41Ie3RgqNo6AgGUDaT6am0xUmS5/L24thQahdi2QdqtknyrCdUz7ySRY6N+p3flVI5echo+8nKzPpfkxNAMoRBLNoPzq3mCWFDHFXuvLbTWcl99WdG2fl0JbO646hqh7pOLiFAc1gFMTDcKmQSPIpEkZstkZ1ZZEeXiLWZ2wRpEUeQCnDxbtWwrgMKhc35ZluXh2UrHKwY72t0HzX9a9q+W8go= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:Kf3QNRJPTtJMKUY8t4m4QUtIXPeFXPW3q0UzgjsnHGsY0Lt6dKAYetdxJQpy//7hGnESHLYrErIgrHSBlaHrI7CThcnxNlOoneJy1bRdbUJyFQbBlxcrsbZhHDGF47M8Brb+7+Z01VsssGZZSPuJcI+GPetA+YHqr/mhkUnOPcguZrFyof44Ob4S/knarxidOxTZIGaoOxbzNmR8H16xGRKCIqUGCqh0IeW3jEl1PoAdfyERTR/pFPYs6wvgou2lr5XP4eklTGlQp9eto2X+yg== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:0dziKY01f1vR/EIb9IlnBWpr0enL2H0ahcdLG4PEK?= xungTVYGfcjnxo9H6MGJddTbwwUbHnPxDlUdkSUnONWg3K7fwsAM8av+57TZv9It63JtSTRxkgBeNjPxx9LdZ42oSsduVIJeDvDr7qN4rb2b65zyXkKW7nvxEBwMQeczai8kw/i+/iq7Rl8sSz177d9wITLsYud9H0wOan4iEDBtXuzvl1se3c3u7ZRz4f2qmGhH5uEKyPr3y7Kml8EBE2N+t4R13qvVwtFkTFHQ1ArY+6LS3pjKgzwzJ72N/MjHaThBHLM4Tk5dDNY23UHLPkdn6EzGMsoZrep3tFMvj74GsLgdL26Io4mtlEP0/GFHTi4qUAEfODJc3VOHzktxbi+QX3cA/t04G5ZDpd/tHcO/KDN3Xrvkkey1I4uiw8yILzIbgWTts2N52TpV38KKWOQHhYpH2iqJlX3/It7s2lnzbX7X9h/IN6G70VkiXUUwlfBHiXKSx8Dq9LJXzFQOL5ybFE86ljHeVND/kL5NkZsI0PEN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ginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:22.1429 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fafd561-c313-4330-d1b2-08d623c9de41 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- 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 Wed Sep 26 16:04:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616109 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 C384E3CF1 for ; Wed, 26 Sep 2018 16:10:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD1512B406 for ; Wed, 26 Sep 2018 16:10:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAF3E2B377; Wed, 26 Sep 2018 16:10:51 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 3C4A82B3DC for ; Wed, 26 Sep 2018 16:10:51 +0000 (UTC) Received: from localhost ([::1]:59628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5COo-0006DP-AR for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:10:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJm-0001vU-QE for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJj-0005jO-Jb for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:38 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJh-0005XJ-NL; Wed, 26 Sep 2018 12:05:34 -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=HYm9Zg6/jgPh2CB6LPSSlwhXzJpQFugWhGKVEO5Cmfc=; b=brcVUu4pZOcfyqqLS1SD2IZsxMKj3nIaen3URDReNPcv+xTW9DDrrjW6uTSVjOGfFnWK4DBbHXVH7c+8swALMsIjMmZYd8H5NcfwtIG24ZluAf76uGFVyL1V51tvH/rReHdGbcv2SgCtLjmnwnX/HYbObaFNBE/67kw/KFeWDmQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:24 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:41 +0300 Message-Id: <20180926160447.5149-4-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7416bf0-4e6b-4f5f-511f-08d623c9dfe7 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:eOwVEJVJ0rmzvzEljDM4r32EAMaVLFEa59OI1w/Xu7CDuiK8DB3VYas8Na5YlAJgaxEc+mWiWFI7HqQ1kXcbO8ZzOn/fIvf9E9XaDtH7n9ZNRptXXtrjUHOYWow48NLtxqQSFODwQqzeZxxTFoU+RSxa0zQ29ZZl12uatbYvCr5knBJrs3nLgkenb28U3oyJlxEZCQY9hztfZdRgtSmjagziM9iaRM8SsepsUzvuJ+ebg6YPq3QlWPpETd2ymUYc; 25:X/XLCm8A1gPR6+e4zWGx6vQGoHE47yXKmHgqU5AGQg2B9Xu7fWZ7+cPkfMp23l2V1ZWJ6loBdzfn5glN43f4KWdW4IfDKTrxsVGSAPCa1qhvQ/LsnCMDY+HzyorfApyZjDahsSjJ9hiH5WHYY9FYUbxr8wZrrV4TTSu9vYPUryGc+WRw14j6YTvJjPYsadBHM2iWez+QBFTlF/Exdkzrag35n0WM5LesUDb0innXh8ZQV0VneYs8mMLyjjLSp6h5v2JlyrSVVEvfZT+q5gEHeuPFp/UFKIxo/DsBg/StXLQyrNNwdafHBttkTd2+d1ZpOm178T+RUMEyxMrjQ/cHrg==; 31:7Ezi4XMZt37STPr/bZLsNYjL1ZdXJoZguNwZaccv/jMMSbSrSOD81wyvphBuj/19G5EX2gpoPzrFJT9WnqlhN3M7024U46uLdaFMZ/bIy/KI34s1I01/O5rPUhSJX5krXf7do4IqkvRWeWZoyjTmwMO0dthjgvPAW9x6a2knEcvGYmTi3AGIr5xGFLnyuSDUUeUM5tB+Nx8LaORpE0ZPcQmFudHg72gle1aFzbI7n2A= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:UG2upRmRWpZ5R4xJFwZJQttFWcctvvg3xupzuhYDEsB3X6cJWMRXJ+4O8B2GfCqW67XgqSXPgc6VbV4rIKq0QoESj81wNKfr83XH/pLA+JCc+rb19jVB3+g9EFWNjhfX+w+C8Gm9ytqESo13IC3wnaawM715QIQhy1svnbqFkV1JYF+Fcn1zPFjikHjmc+RTC6pt30ZeC5iahd8CXVO1k+VsLZntIx+3b78BsgkcVj62xeMaU0R8soYedFvmMKcRsX1ud0aFiknhcU98xVNRKg== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:8uBSWdHJKvY4kDMN43pCWrBKeiQ4IsJII6LyshFA1?= SXQHqXJwb7qD6cY/CwYWhuZocNxoDvZOu9xNjg9MvMA6qULar5eNOAg2Xpn7OL2v8O4MF1PDVEuIxwAHyVuSx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1rpBV3oj1nqr9wCYfeVfCQZXXAxq+tth5FyDHbl3AXOucx7rjFH1tuLfnz+q3LWI/L8OztbG5EQJGT63LIOP9GZeo4g4=; 7:KkvuX168UfKeRVwvziD+09xO+/ZuhKSLTF4AsmGnfpuoSJrHsN4kI7/CPZdqL7yPNErkl5yVUC9PqaCcaC0FTYeIpU1EDTMbAEgtDJSfUWPwfdhxyRoWzb3ZgxlI9y5RjLh8znTkklo+BxuXGGKSKTkMO1xsnTzHcLIj4+hObFOPDKu/GaltjOzKQVUygH7MTY8wd0LB5BIrZn5cN+bziyFlHwIP0k6wSV0EOlPBvb0Iuv2nT88YvoSs6ocUqGXa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:24.9082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7416bf0-4e6b-4f5f-511f-08d623c9dfe7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- 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 c13153735a..d2c07ce9fe 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 Wed Sep 26 16:04:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616107 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 C71033CF1 for ; Wed, 26 Sep 2018 16:10:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C07C82B3E6 for ; Wed, 26 Sep 2018 16:10:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE5CA2B3EA; Wed, 26 Sep 2018 16:10:16 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 18E832B3C8 for ; Wed, 26 Sep 2018 16:10:16 +0000 (UTC) Received: from localhost ([::1]:59621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5COE-0005dh-7U for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:10:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJm-0001vZ-RY for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJk-0005kS-Oc for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:38 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJk-0005XJ-FI; Wed, 26 Sep 2018 12:05:36 -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=5qeZHhNXaAowsh9zkxJ0Qqu90roMvHxi2nM2aDmEiyU=; b=oPJyYe95sfs5FJC445qS2Iyc6S4sq2sUbPp1VW/ExSO3cVvm0dnFkHRuOskCAkq9Qyu8BMy529h8UJSeZihi3HFJur+la7CXmrZYJ7hbOFdMJpgH7AVXCq01Oby515ahGQ8E9ykg94U+wqZOgT2lqA7xAgWy7ACr1y7wkpDKCws= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:27 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:42 +0300 Message-Id: <20180926160447.5149-5-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bfbc6eaa-838e-4910-c8fa-08d623c9e190 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:h5UPiGs7TNBfQd9291HI9GDcLx0k6PQtrElkSK81YNsBKfVkYOHjAOyVUlk4rA7ufpkg44ur1lJkb04sKmpob+liG7Sp5OVTBt7qXGuZ2YSu/TnxJ6nJX2AptK6eV6A+Diplb3YvtSYHX1OI369JCNhnRFSN1fxL2gtCzKJXIqHzk4iXzC3Z97qoqWJ7O2XQFaLxV9Y/DHiK89Nx5c1rpfgtNteBSe6zd4dRLP6hgiA8qYi/YJ5cO/N48GldQU6C; 25:oAatziLB1vRWAcTsThTjCJTgFMMI0i4jfrK4WQuMyevL9/gkeauhU7nTodeXmKqBUS67JGwAwScNrJ+0YVotJlA1ngMlYDRO4jC7Ttdh3EOeYB9I0G7IiwE0qwN3tm5zN4j+MqFWJXwdyyNRmXTT6xgU6jgRsGIto0ICQ29VvJXQzQgl+S58RPjuuVKY961zCy/uTqkiR41NoP0sm1W8VfilLsSfw8XGTqJ1cG5jIBKNY8AA0aSF66drPH+43hKmP/NwnwNgx1X9eDBK0lb7mq7wfveO6HaTcQDYRJKDS9xrj8HXJmDMaMr4M1zinfVxSlVemwfz4h60UzHOk/mfwg==; 31:Ev/YPHH3HRW2G579Ss3rdOTE1SK081r0FfZ0BwBDuxJJ+rR7HrAUENgcfzdba3Gix86nZTdeC0/DVodhSqLtia6b22acDrA0StiO7Basu0j1XVuknI5DxjBl0Xbi8Y889GkqF/9QbYfgzaEo/MrypL8QbpdTVmjiLMfO2CDQMAN5418qJGpFudD4C7hDcydl0JhbAp+HCQRI8soa2d063vVOdkbH/dBWpGZFPMLnosE= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:Z/FBGHwwYUrF582Hzbr+it7We3432fV2UFnKTdyRhZDCfJx1nTE0XJg9ooBXaFWBdDOnBt/Bh5T2FjuvkQy3m2pLHcj/6gP4RIXPrsWL2mQTe1eyENedhQ6eYiM+3MD0GmkfaHd7eMvd7x5aut1Qgz0unHwtdMoRvr6xz4fNXdfPYNa6hvlBq7AwuB88ZQE04FdewgE6f3tP5zuX/ifEr4rrDQ8E7bawK+Sb9JosB4cK2cEJhWIhI+pGkI8DDb8K25JaknyS2afurKJfXkvsqg== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:M0QNrY/1M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ypLlQfOS/+1PnhvQZVnilJGabZWsz4WcSVhnJgWWrsaGYvfztPpHUtcnUJopWP8Snu36wv/NXo9Un6ToPoc+KCfJvbjNRcCuejgfxvXlaSp1AGv6ONgjUusg07Po1Uyjxa2QPzFHI7MBxocFZrX+IZXp1rQc2kPx7Xct1jn7Cjb59057eqJDnD9z62v3Aa08boihjLoM+I1KooMMzHuf4PuPB8I= X-Microsoft-Antispam-Message-Info: 6nYO7iyVBksySfm9vfMob5DyarA0o5+Evz0n3bQOlqknSZWlGOIGZqY7fP6VfEabyBZGaZ4/K8KCetrfJ+0KBIu2vV6q8Nv1kNi9QLytpIsTojInkOsTD02L+BM+OgDddb0dSLmnxYuCTeqmFNpz+jkzPzscqXm3eOvLDPjWSB+t+B4DlTwm4+mrRFuN0nUGBxatilPhq73Gr56RON42HVUV3JKAWN+0T+QY/OY2zvoIKFcJj0gihHCw1K8BJOGkeLqgs59/uc6GDrndh+ayv6HG6SIAfi7RPkIVCmpb0poJB+35juReVao+HXzGez/DL2ezLwjpcI/++6wnFlHFDda3VHzVW4qkpp2n99yvaAA= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 6:sSEZG8H4VVTEtaAPYXQ6MmqUUROuMxi33Sgt743piZWbtKn6QV7fo11w2d+mSMKzbp/50x+O+15cUA/LZt62qpS3Dp/0XOzs83L0MRwLgw9v7IpNkY694LDYSPeFyugPz7aUtFATd5P/sR+vipvXV39qPy02PrTrIK0hGjuoAjSG7oC4jcKOO776z5vQpxFO6V774LH/ZqszC8q9O/crGQpxHugosG58PySY7cmbyZW68qW9v+FddGz8MrtXPfHXD4t91150gpAV/R08KEAnXiF5+/jOk9ggNdt1S4fxAbsQL+FmoTunwhN+FSCVc/vPZDawFHIrgML7ut+JXbMEv0zrTm3sPwNo44sLUoTnAPTg5H5PCZmFoPDA9rz10xFrntGSH+xf4YRUuteGbi5lprBlN2EsYr+AzKDekpItrifBsLrf3+UcpL4MHBNv4cwEKGlZodjUY6Yl89i0V6SsHg==; 5:iJ2TWXtb8ZnV/o32HS6uIZzk4WeK4O829HNeOxYAKOZdB31mjQ6EYIpUoR0eLr0RhdB+QvtpyVdgpcevCqvwaLvuBkBVbwEdaW971SWeXYrlBwID6C87rXMyvflYKCXxM9rMk/iE7N/6Bi8wY/slvY7rtyG88CugJCSMcySlprU=; 7:ehbrUGqiQ/2CBeLTybxr5oolkRovJzq63D/RSYW9kmNOBAfYw7m0c5FkPoFd+W95/G2stxbKJWhUH3FcHyW5dkcsoM/WxxOllhK7GB3KoW9n7BRZKxH/4H+Rbx5NzJfN8s64kVlFS0/saKFDPiA5RmVIUXTGci2XweHz/rW6CG1Bvj1nT3O3Tybjv6tYNtBgf27/vIdnVzLe14ZXdh5NhZJGFGdE8tdnjDkDWxhy5YbPG5SXPZ5r3GIWy10aRHIK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:27.6935 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfbc6eaa-838e-4910-c8fa-08d623c9e190 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- block/qcow2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index d2c07ce9fe..cd0053b6ee 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 Wed Sep 26 16:04:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616129 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 CCCE414BD for ; Wed, 26 Sep 2018 16:14:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C265F28CE0 for ; Wed, 26 Sep 2018 16:14:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B62B728F89; Wed, 26 Sep 2018 16:14:37 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 CA73428CE0 for ; Wed, 26 Sep 2018 16:14:36 +0000 (UTC) Received: from localhost ([::1]:59658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CSR-0002b5-Lj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:14:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJm-0001vb-RY for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJl-0005kc-5S for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:38 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJk-0005XJ-Tk; Wed, 26 Sep 2018 12:05:37 -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=HI0QYFRodMKgi7/VWv07Mv2othK0PnqKtoqIPjyVRXs=; b=W8DK5Ed3bBBR8si2x4qws/BEmvx2oXUL2XQoj8UDwQWTJt/608JcMsLFmNY8Gf8uxHzxZojWg/iT2rysBN0TQ7prBhesoarJpCISbE5KctidDlANP8Zet1jCxDxPmT0/IGoM9aM+Dqg9agYSZ8qFcTFqwrJLTI4vefg9/sJv50c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:30 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:43 +0300 Message-Id: <20180926160447.5149-6-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be6e54c2-7084-4a43-30bc-08d623c9e34d 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:+V6LJuajSRhDltjQKhbxcixrBzs3iZRBO+dMWi/lIwnbKtst+/n8daj0QqPQyESiD2twL6faWr+HbPF9AAjIPrSSk41geK/N7HCR/BTl6H+nqFhtR2kkckxzfcXDK4UIceB2ObQ2u4umnFHldPdTy6cAjVbHQ4ZapiAbo23i67HeJXotB+tEavLpa4gToA11htt5cn8wW8ipexAY747qGVdBdpIv6n3HDlv10ojEwYbJVp05pKCEpclIU5wR2y9S; 25:bl2TES66IExxf0ncYS5vFtVIjxBlP07gceWKzD/LoXoow18voEa1+8UmxOhaoXiFwVfx9hqaOq5zpSQPUzVua6VoATKhELSkcVtF7KiKhU/FWbrZo582oe6F0HUhK+dCSUZSmDyvOkprqXGW4CjUGyKoxltBtb/817LUgV/up7Igc3rXIHaaNJZ/+MheXPoUhaim6r1I3vtUbRQLptjaFI73d3VBrhYnNclk27bPY4yG4Q00X/LeAh+K7xzjXoYeWkitzSa474Kfo8xl+O+CFlHFVNhLH8zkE5wkDovoa97NIJKhiGcga+05XW3ZI9ae4fFgU/CNUYP5gZb12Ywyaw==; 31:GMX/3scX4IAoExZPq87Bpo7qHx8Ai8+bCAsk8+ywRRwaBHgn1SfWU5oQIOce8Idxx3lvnWRSPMmYk/DA2rqsmucU1QmYCeyZCpYblWhhq/PWA6MjhnGpSx5HSheKLVxGa0l6xQthufdWBE2OutPhp1eMB6pgC2Mf99RmO1SdP4jK064sY9mcGbXSSfm77ZLVr+h1o2w69Clc/IqdGJd+Iw/SyJl2h90Yrkg/bnEP5K0= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:QunY/vCdF2L8GlNZOUjo60UPeS1qSqjslqSSQ7ICIA3rtLamDzWCkOS13oaHB+tp21kt8IYtK4BKaJoEGuXe0GdN1/eUYZH3B6MsJRmZCkL/JXJM+3fboolTG5o6QhEqo51uBTwzjZRe8/Evi6C5Tu/VzPD42vzj419ZdxvWy6ZXviDGafV2Gv5oQASSLxdVryhYEo+MwJKSd+PLnLKgMST6BX89Nu6VSW+Y2BlhvAm80OPx7VPgCXyqfvfPYCkhegUGhfXkf2ffGvOFBsTX5g== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(551984002)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(575784001)(53936002)(551934003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:ZwPMSbAMKwKKEGbEUrfGPzeykJBrPYx7J+wxlPFyK?= QlGmINaBd71maEWGVqadJJ2i/9GvuJUlnSgqwUdiO4ihwxNgeuyiRRYQ71b+q5yUO38VeZMY2aKhuuWAcAw68ChycN3hnhD3qFDzqrOqLUELVLfgG8mCwTZccSA6sSUSeptF+H/XXiD8iJowNd2JNZJp1O3b0xyKV/NKhS+jF938Y9Po6zBtgpbfwTz9J52xYYTDoMpt2ufAcxHsGtUBQ6f/bY0vnvLa1rVK0vLzhofO54D/vqsIPuNwFV5zdymFrtzVRjIlY9PMmIPE7oIbbYVjynPRzV7THXRji1Arvm6+Ts1bSTi8/fdyqr9pcvrXGyb4x3JUkTOEfWax8C7mGfn3Y8HpDHZ0wTYaaVbv2zcVnlUmwwwFam6I69fCob4Dw/yK0VyotQgbPicMyUzxdeto/1pV+3ARbEmx41ZJOCAgdllwwOl3wgaaTgAxMknthSBeXGBVAzB6SXcsrvvlfru4KpUebR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8uqXOO71FxupdRkckxSSasxU/KQ4KXTbYPUU+PP5+3ocCtNnUbz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:30.6070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be6e54c2-7084-4a43-30bc-08d623c9e34d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Alberto Garcia Reviewed-by: Kevin Wolf --- 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 cd0053b6ee..589f6c1b1c 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 7e28b41bd3..750447ea4f 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -125,8 +125,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. @@ -184,9 +188,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 2db6247eff..6eef0f5651 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -736,9 +736,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 Wed Sep 26 16:04:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616123 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 C52F0175A for ; Wed, 26 Sep 2018 16:12:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBCB32B355 for ; Wed, 26 Sep 2018 16:12:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF5EF2B377; Wed, 26 Sep 2018 16:12:52 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 25DD82B36B for ; Wed, 26 Sep 2018 16:12:52 +0000 (UTC) Received: from localhost ([::1]:59645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CQl-0001Ow-CL for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:12:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJm-0001vd-Rd for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJl-0005kp-PR for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:38 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 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 1g5CJl-0005XJ-A0; Wed, 26 Sep 2018 12:05:37 -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=0RUEVujr2DHPFeCNOOaF9qV4ZDy2XdlAhK9RPsCeC4s=; b=dsocVxziLGEuY9frn8P1a43sypfYsfFORekAVPy/zogkmUorokG99pAh+C8vm85bF2BlGaX+afrjB9nPjna+O6rGj8oJl6pkQestZr0EFHIg9PWKvOgoOC9FJH8wTboFd3mArrd2e949V511IEdOEpujxX/zSta6tMARo/AyleY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:33 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:44 +0300 Message-Id: <20180926160447.5149-7-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6424fbad-5bc2-460c-b80a-08d623c9e50d 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:BT+Jx7cHM46+obI8Qgg3ZGU0BLp6NXqvPV2/cwFgbs4OMqGuoKOK6sEwJkCxXJOYOFcvd5ukkYBnEPt0RMOhVgui+wYH1vpoe88EtJUXCQUdu/vbzaMaFSXPF1Wx+pc+GCRLFzT5l55eJveB4zZYu77sCx3qSyhBwoLOogprsTNSfoeJrwSzXbhv66vkmpbjEjLr3cRZuC05utxucQytQBKrmorbnZKh5b/One3rdtZLMX0f86S2FC62uyyOLWdA; 25:PvFiDtF4ZrB/e67fBe4Ejb+A8CJblnEeNEDblEUaaajb5BLg9PmetZFDGqXuTvVnzBkuYMmdbJR6PZl831AB+5mTF0iyvw4s2vzkQ5l06Fpxq8OTslTXxgnjL953A2DVFaJDDhS3ew1+E8DFVaCAUQn5VsSyRiAgiI2tpbu26Z1c3rZZozHZxz/Yj2jNAYrRNT9UOeOECO/p0Z53aGtElpwZsCEHDbnB6Bhbyh3a1y+hfbWc73ZXtEHU3ookgpEzTM6unqlaX4XiyJk7Z7ipE5mS+JcmNVBJjC1v87+uDwIpYHK1sQSmpmv6r0dL2ZFm0rfd7CHq1fYBI9u1F55mIw==; 31:MLbkxeJMv+Ac7NKz3lTLmUy0BBzTPo6nogS+cz4gJ3hFS2QXBeNMvy0X38FJ89o1zVZuT/Dd1ozSv59a2cuWP+tOTDnWzhYWxzIozNu8f1jmFp8HlY753UlvXFwKlm5+s2jXYtpUYa7lVFN69WqXKrtmD92ZhUX0OU+TObMrw0xPmQ0byz6l3tHv6GsDiAdT+C+eJ3/sKvrABdNa65dI1c5gp8qctSt0+WNx2cGmOec= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:gfavgGWP3SVwwIxiViZvbUt6VEWyGdaUr+7Vf/5zpTwBsrRe3RbIuFRSl8tV7XVpwGbq8SE9nHmgY5cHFIcMPksSpykSs267uyEjvG8c4YVfNgcSGBWUj4RN3h5W3mAI8F2oQz5o6PouW9lLFGIEFPH8PPBSRDJXY/W0YowkJr6+GwoyDQ7jI3WfN2zewmrOzBNszzH/BlQ8G68oPiw5ol7fcZwEJobOUv2U5AcQC6o26cSzWpdGGke2xrMU6JO1lDLTBYaQ03DnCCHqMJyRmA== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(575784001)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:ZOh20u3ujNTmNmn8+Sfoiyq2xPjUpHcQ17+PswyLF?= MUbMoI0pvq/O8ZGiydLT7gdU5Tts6//kNiM19y3Bujta9m6Z+WFXmArl58Tpe8DSTQPtY1o3KvQSKkRXgv/NYjOAJ86JNweVvfjbBEWjAd+4C/Riyp9c2oN1bCOaK7tCgErw0Awt35Ejy8kWR8jTemV9ZD2PA0X7eOPBlsQTIxo0X2psgnhvtQ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HY7WUR22/AJP4Yr3ynD7JaxHVG3GtG/OrGzX3T5/+TI7NQXvG9dDCN7B+18Z1A=; 7:hAI+9jMy9jkC7rl6CWMX+ZBeT4Uraer2RS5FdWpplDl+T8wHB+o1xvJYD/vYHmgHPmTBGQj9LmmV+rpBqgtM4Pv37OdPCMPGV4r5i2k3BovkE+3wmVIiwGnHyO9tDx4jMHyWQ4S5uKvTmAG8yJ8LLFZyRJUl4HNptJHmfa3c3QmCbsEROEPqcV7BdjqJ0L7vwrdFMCYznsJa2FW88ocCJBrDl9jSY5dzTkzNxCRhEForZIuH3BOqQmMCQYq4AS3T SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:33.5455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6424fbad-5bc2-460c-b80a-08d623c9e50d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- 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 750447ea4f..1fcc0658b2 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -125,12 +125,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 6eef0f5651..14aee78c6c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -736,9 +736,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 Wed Sep 26 16:04:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616105 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 E3D383CF1 for ; Wed, 26 Sep 2018 16:10:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D700E2B41B for ; Wed, 26 Sep 2018 16:10:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6C02B3AE; Wed, 26 Sep 2018 16:10:04 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 22AC92B3AE for ; Wed, 26 Sep 2018 16:10:03 +0000 (UTC) Received: from localhost ([::1]:59618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CO2-0005TQ-Nw for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:10:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJp-0001yE-5R for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJo-0005ob-7r for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:41 -0400 Received: from mail-dm3nam05on0720.outbound.protection.outlook.com ([2a01:111:f400:fe51::720]:12480 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 1g5CJn-0005mX-Vv; Wed, 26 Sep 2018 12:05:40 -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=GBvzJu6NvSqyvgZxFPfkyyscJHWOpEy/HRtwqJV0Ows=; b=ojUpvn2AFi5hlAvuRSidz0S1tY+0tISAfJR9p0R9vnBeJceeB6UDBqom/E5qhtat6UrTUi9qUCyGg0VUpleYgmFO1ENUNKQYU5eJytfgmB4RUG53cVMk1duiMAZTAvj2hOwi5Saxm6d7PtF5EDVEgwRSrorbR6UzEV2IEkXJdzA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:36 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:45 +0300 Message-Id: <20180926160447.5149-8-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8fc9f404-6bbf-40a1-050f-08d623c9e6b9 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:B2sDjr2WD/bcMi3ke9M7uipRgnr8VJceK+Y6NsJEFLIH6lMJLdZuT22DBNns8ysCNB5Uyj/J9pThWlqLdcHlbfigxslM+WEM2C48FJGyHlB0Fx0mjYpqGStK+T34i5pFP50VGKgPRrBTjP2L3kNyZzFwTkCQEIGwsEcbNWB09bgA8HEQMeNvH2+DUrIHLON1hH/wAFzMAy1sL3uDGy2t0i1VRp9+u5RD9q9YxD/lyyOpVs6P5iVP/jtqlinDvMFo; 25:zW1qlkqXCbmyOMJNH1OsGNNF+nXSOWdZ3t23nIQB/kncBi++3AlyhUSiih2Wtz6JSqqVtYo7H0UR6huUS1FHzEbThXuPex1Qvns3/qgzs2cJFKdoLgR1zTRdWaWwQikA8uVScp6lTt5Z5z7b3glwqNT0UuY9rNhK8sQbHP4PEUo/MnRMQwWuadjScBsLVYhDtmSWwkJ8YVFajdL1J5kyOHRH2KxbynYD/3Su2KXNUfh8eNtc1ThkG+QfKB22f9TZRfqmM3e4SwchIzHxM+Z2LR0ug1tzgFzCUDNBgYsRo4VOkRXloT1IsxakGDEy2jwNRaElSLBiYA5QVzrEU/jp4w==; 31:MGZxLVfQZ8Wle3Zi9zF34hFjDR3/Ky/+mbJ//0mO0TVJHr7z6H0zfAyEuTKh70k8yNkTJBXhYnWNupjNbvbhIGRWAhYx2WuvshAFIFNVW8JGLI3I0QmwgMhefLxLbd0dxMGEGb0EGSgs6c4qBxf6lJinKzOa+rSWUs7WQSlwNditL/fs7A4aIMIen7OPPtdMhOG2o4GKWgrZxOQ35FvsuVsJ83B/UYmif6j+B+bV++A= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:zH+mEuCrryN1qrnWzF7gJMxFKyDZFOF33IKdUbV9m+ivSFYabPdLB6B/RuG/DdHRmie6NiLjW0BGVErmY4WA/fOwX2Io9gacnJ/Fdh7B9g2Ch33Ta8eZHlXOZzkXilU4FBTEF4XEYGIyx6IyIAkGClOVElRTXeeQ8ri3bL6w+4xjxrzmLHwX3ApwynsDosCQGEmBn+pYF55zNP5PiAhXsiXATxG2s+aG1vI2QDIIw+8M09+QyGf3VfsHBwTakr0mJ96zGmM3jHbycdGz428xcQ== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:6bI1sTH3y3pIY/UqF9p9z4l1MciefJc1oBsT4y1vF?= K1U0NJM6osrL7OQaq0Klmr5rxQwFcY2bUI5nFVQ/eVgTU+N78eUTpHN4Q1FCvr66gKo353TmddrTGKuf+/YufPLRMQ1rgIlolsqpjS5Q6uMMvhZ/3tm1ZZcQokIX+yfjl724E9ZdSJO1dGK0Zx2IdFNtF0XW789HI66e0fF4bRDpr8MvZwR+0oLRFHUn/S3syjwlCmOLZW/D/oRDVfNjzLXUs0uULWiTe2R7pzVwLvh+qbnYK13qWxwNdi+5KgNZoEkEHdv63kD2dxhbSDLZS+eDn7ezeQzvQWgIsqf3HcMz63yh6ZoXJ+ouiITAJ2TA+YVk2qgNIxsELxvSsy86k6JcT8v0xVA84ip5acI12c4FoxkXo2WSOjZHT59aoisKDnV9kvkVCDJOi2MMfa9NdYBdir2H6Ws++QaN+yL9xMgrXqG31vCgU+hIjRilsECTgQbW3ASzhhdF2HdRMz+j8YW4SosUboiIu8bQe8EJ017G+a0MV71xl2PutJXHbieU0OZU45+Bee3SJNblGNY5EQthduuNyRx1K0BH+F9aanEXFe+JPtJRh1bCRA0C6q32DCN/KF+gcI5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-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 6:JIgFZp94KeRmKyOntxSTJ2hHoTrvihKNOQWjYcvGbrEqVRzhYYcYzW57a7d48eVuhpblhIt7wPjETqkn69BZIUBiTRdGkIdKfwo8LVkXKc56v36BhqqIZiHxhpb9BJrFsQUsHh5QXQqQeYtJ//ZruMMWc2QdU9qq21SFQL4qvVGGU0ot/wq+H1DcNxaL03Sgt8W0ne24GAwF+dCyiBvuKqj37wF6RThZ8R221L2AemZAx4t6igUx/nHgx34NXs0IaS01Q/+PsY343RaCROn3dcDLX2ETJLvPp8FPD22Yxu2OlObQ4nr2ampAiIuQAFzmSb6Vb9X7x1WECeT2cHy7x21ISMcxIJa8BuE4u9X0HHvsSTrpbjJ69YE7nSobhi8OLY5+oGRlSG4H6J7AEUKsdWDtGKluuJJ//O9/eH9639UBkJgInnC5YaC2uGkgg4ksam70TAm3kHpy4sr4rc/6eQ==; 5:SGFMMJvDj0xmZsdZMgEGkimp5Bm/nUUAVbWsauDVmrV0qL9xJZRrLJyp1wXSO8LMG+Q63pKiw+VQqn5uW9nSz/463AsUqc0OVo2b1G6XSZ85li3SZseK0OuDtPCveXSUs+RS/IZeIt1Gfe66vR++eogVK92L8vJTlSYYUAga6wo=; 7:s1rrMqdr2LZTrBPanMqibHPi2di/0PiVunmDIpJtDEAvmbCcGtTBLouSuCM0wOZw2NbSlHNXTiAynGuHbMlgCeqMths9jp0rIsMMPkHOvt7tmRdI3HzCpUHZP9x+W6bQmr1Eg+ZaWy/8GTu8v3mAkaaELaMtmcOyrspY4PFc3cSO9dgyp2y5cg5rlOoWB9+lbfGzzyGHSKh9b9vb/i9cmtQhQ8/MgTI3LrSZmskwSeGKZKKJKaeZWAlohD5PaGWg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:36.3508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fc9f404-6bbf-40a1-050f-08d623c9e6b9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::720 Subject: [Qemu-devel] [PATCH v12 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 589f6c1b1c..20b5093269 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,14 @@ 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); + qobject_unref(options); + if (ret < 0) { + goto fail; + } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); From patchwork Wed Sep 26 16:04:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616113 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 B43D8112B for ; Wed, 26 Sep 2018 16:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB8672B355 for ; Wed, 26 Sep 2018 16:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A033A2B3D5; Wed, 26 Sep 2018 16:11:48 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0BA142B3C9 for ; Wed, 26 Sep 2018 16:11:47 +0000 (UTC) Received: from localhost ([::1]:59633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CPi-0007j0-AT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:11:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJu-00023K-1X for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJq-0005rS-T0 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:46 -0400 Received: from mail-eopbgr730106.outbound.protection.outlook.com ([40.107.73.106]:54899 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 1g5CJq-0005r8-M2; Wed, 26 Sep 2018 12:05:42 -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=Mund+t7aW5KyOHuTsDm5fH8C97MERJjcdm9+cMnHvuE=; b=UZq5+Zi5D2GZ2p8dKWdQr9SocV1nxy3kSUOm5jkDx9HbCazCQixS7Nlgm4bqZFdrKDNB66+knFLyeNDmE+fue2z1qfo1wKf97brm5VUTowtJ7bCFDcjwbv04fxHbaYQcINV0WJKzfgZO9hCtyi6wiR+XNjsDQjYnEXZChtmfljA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:39 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:46 +0300 Message-Id: <20180926160447.5149-9-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d2af236-8079-49a7-a7ca-08d623c9e860 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:xtCuy7VweBBRwRN1Y8I65/pc0w2lG2uONCJfkLCG5dchUOg1P/GFHffTgOFxbbVrTFO4LWJWgreKGbL2mI1GDj+qVAQjTFcKFtyYCAxFHCRsJ9O2zSPgR9IPRC+XKi55SXzdL33Y4gHL9PueMl+uxoYrFiK/RDSXQ2+bQwXuY25tKv6CpHCYNtieRVeC/e9+sT+DlCBHAz/Wk0SCwVDgzFfgd1dWQOCmXDZZ4irF8O2lYHEB5BqF+zDR8zmDB1rW; 25:F7pyvae6Y3+jnvY7rpPYsFqzu1fsGr3e5nEbWruj6yOYwBnPUpLJW1ufckmrDYvU6UYth3fg4aq5fTCv5R8ntFPgQwcXuxOIjpFnGvgnAsraToU8I5AVrbzWmOfB1lXapoFSFZZHbRqs2GdBW6a5CjKK1qYa6PXaPWC6EN2J81aSrFlcQRiR2qouBC/MJkGrClJ57hotpy/ag71lveTlvdLPI98ZEwcNpoGozXn+4MpchkuAlmvx0o2d+Zyo7DvQTc4GYxq/26CYRh7+TAPbsXDdIR6oWiUu9uBwajcMidkR3D1Hts61Cb8QPblk4Kv351kOCBvFF92q6itKedjSkQ==; 31:Q11J1Ros6rsMy0YxOhoQAiMzo1pitsxYJIHCGQhTM9Y7CrX0ougXmzzvMuSCCzeYsSv3jiEldbOIs1+K2yni6uq5kuZiwSnoxFgjGzfCwnaPY4w6CgOi0vWxUzUmWvHHNWb6yzWAhOs/gWPDXW9h+dXMmE9nKaJaJpirlHTBzFHLEr5GWrgRM2zwjw7rZR65z+JhKm86Wf6D+XNPNTaPHJN+irHftaJggT8pQYDrx9U= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:ZcfcCbHY0ubkGUrEVTDSQbVpCXOWbXDAIFPyhMGZ3opZBBbbMIWg4z9uc2j8iEkyPSmZ2mk7CjuAq4wDKQ0L2HsNVIGxMYn810S1u44uOXFlb9Z1RIkrNAfwf8XCN8NzB+/FXvfld77VJCpB5pZWVSzvjvPEiw3bG+LqnTx0cNqyeMK3WDvxyIb5jw9/dqeaXc1J4d7lE21oCnJbAfhDdVYikgi1AwLfs8Dt/S9zxWl0hWyVoOlWz9eAGJFPsw+VNT4CASuBP32CqPgNIcSzeg== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(575784001)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:pqNMWXXzMURJa0+Rp/XUvQ1bd+NWZ75excyytzKPf?= TxZAKMMPzTUDOUSc9GAfdaZYqj9lBvgxqmxfoMzm8IL2+gGq+pxiHwZgXH4y4myxJd43MhzgRRKbR1tdG0jURmmku8nWaP1sgq9QLuMK23UXeh/vJXiqFPc1hAI88iMMtkHqy5+pNdEQEUTZ7LcSgV4rUFTXx/0aZkTytOV6LkzmzH9W4ZHrKduoXHDv4WvRJ2VcUEFvvFpUR7JRQPrThVyZSN26hQbwkJlU8u38BCBgSkAu7x3jboT2KYm/eKv6zJ06WmG3zBfo9la9g1GfIJjmLj48fxpoqs5smqXN1g65md0p/Q4vs8khLV4V5V5z60gcKbdvXpMOCY5UDOUrPQC1RPtv38+qyKm94EHRKRyios+UocI7jE0xkbpTttiJJJUgw/xPXXsd0cA4YIOOr2FS6twbmejS/Q6ke55VYAYRihTv5Ljv6RHAarum2BOJZVvy5o6iOOISrAXGYjuAJ/F4l+Lu/ivBNh8rAhS1SCzK7VDp1lfSZ5klI7SEiGPeikro+jAXJ6Rpp8lIqS0ynsOJao09RCaPY45+RvRqmg8phNvSyB93k5q4kyCnBmff5EqVDCvNxPc1FhQtcICysj1pjJOp/C4HZpoEzMftZ281OF3mgtvW/yh5o28wsUhiAzw+1iY/EvpP7TVB58ncylApcIjCbLu52MNlG+BJXYpF++k8uG6w1IkJL2OFaSAu4H9zM/ZRYzhRT1Sp8e5R2T+fSbPSmu9ePCIlhBGgG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OEIcqC6kh1KSsY6SvVMY+dA5cg2uulHrnS5aFzJKRdaZ80o2U8Up+htieNxWCiY9qtgluOWAdVeuu9M3ekQ0I9HFFRyfOfPptUTdGHBZEI9yLEsarp+taBCGiNAM8vc/N+sMWqivqoWQQFck6qxnHPjpCNrfIxRTCtvFUVeBZkKNYetTlgABOmMiozE6WqM2CqnEYPVEua+k6KhKsFWd977F+3pzfScvM+kI+xqC5HsVht2+DVUK8/DHgSSJmKvg7ECkXfN0v0JxbAhw+3UdZBoNzhCvymac1/47eHVRB5LSig+3h3nDkDPHWpWWaI/n8UVzXMGFn5t/btybO5oje/CSA26pLs72TbTcCtlcJqOkU1210w==; 5:fA7sOq4AkaPTtL81WOKbpSPp4LO7vDrhPajnvvRMv4YcMTY58FhmDdl2Nnwy4KOgJQNz6CsGaxS4kTDldtxRi5LQT0Q3pjLYr+aFU/EmIPcin6wy/hYBpuPH6ZCoBoh8AP2wfvj625v/kLWaP2D+srdZQc9DtF1MpedUyDxcnfs=; 7:vy7fiosYiaTTB60g0BTJQ18gjdEw/x+j9WuOzsWO6yc/plvHTCROi68QC6E9PSAGS7ptZf8/erf5WgSJSDllE3tcZCVpphSTT8kh4/KnYTYxUMHiB0M1KwXjunUvRyAFX6tXrLwIoXMe/okpVFbbIa8yaAWcUXMh9vlAOIFPukRWzl49mnmc+UWO8JhZRgMriay/I95adVbAst7uAoPwOtlJ5FxXP2MW8fsB5PZGONogVpFTo50a6df91ZQm5OLs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:39.1212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d2af236-8079-49a7-a7ca-08d623c9e860 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.106 Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- 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 20b5093269..95e1c98daa 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 1fcc0658b2..59358b816f 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -210,8 +210,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 ac3b48ee54..46dac23d2f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2895,7 +2895,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 14aee78c6c..52d9d9f06d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -747,7 +747,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 Wed Sep 26 16:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616131 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 3721314BD for ; Wed, 26 Sep 2018 16:16:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22EE72997F for ; Wed, 26 Sep 2018 16:16:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 152F22ABBF; Wed, 26 Sep 2018 16:16:32 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 8889B2997F for ; Wed, 26 Sep 2018 16:16:30 +0000 (UTC) Received: from localhost ([::1]:59678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CUH-0003jc-9D for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:16:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJw-00024i-ND for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJt-0005s4-Ix for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:48 -0400 Received: from mail-dm3nam05on070c.outbound.protection.outlook.com ([2a01:111:f400:fe51::70c]:44064 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 1g5CJt-0005rs-Cc; Wed, 26 Sep 2018 12:05: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=q5e0yaAAra3gKwOjak4dBYkP3OSJ2GBKqoB1DeO+tVM=; b=NhLXNv0xY+fhGykX0W6JuUBI5dBg+ROJ+9OVJx4JwPplvo9vpkm8uxsO8TJ4ysuG765+239st+BTZLgwWbw1kC6BhuaiZCHPGWiHea5R1xrbLXnPzYFgUlUioIhBlh3a/8lzUz2q5lpcZng357ldGVN1W2Tbm2qiYrpWJ1qhc1E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:41 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:47 +0300 Message-Id: <20180926160447.5149-10-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9be4d355-9192-4d40-5f46-08d623c9ea0a 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:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:WzZ1gQxmJWln/uXt/K93aU6JnMGnWxotctq5vXW+nwuhBx9wjL6tiS7c0iqyJfzNddDG7da6GvHbHy3rYyk3gjCGqDdkaqT1tcjgN/pqUKhV8jysNfwavki7hK4zt/BL4Vfli//vZn03anFzl8UgTQXUVrDesGkCi33d0hmpjNXbCCp1bUf/+UZxrAvJN7Krf0cpezRNF9G1znYMUMsUf7fPuoPH8tjJXEa7LtDe0pjCsLOk4bk8N/O+GqAkcf+m; 25:BSuZ6aIRdKU5IIKJqPIHlu52RwzO/NW/rhp6Lkex0RP4kG9XIdNi/TnU2yD0P4uZOIUSzJa7kT5I4JiCUxYejra7v9L8a25NO/aMo+K8kb/AG4dqkFZLVao/rJR1K48EdPmj/fRWJDAarGTNiMSiJ4iXvIWTMaQwxWTif5wcuQ9jEo5miyF8Ary3RkrajaVRpZejWmz7Lx2oMcZLdU8EIy13KTuI6gCo1fVFsWsDugV/gN9tdL/t6Kd3bAy9IZ4avcDiSufa1vNqn2xftjwFhz5MHC6R6wqUom7nCf1lez3LyvsHPocFAlAOFv9MdfF+t7yH3LvvAQM7WXD7YeADHQ==; 31:sBFMEr6ytAtRmF5EtMztT5tq57ki6E3W6VRYxEAG4pBwGVXEuuv4Cv/vVt9WXBS/ihrgqyPzHCpm0WuRwEOEkYV2ziOnPDceeLwrzAzSEUg7dOsZiJ3oW6Q95XOJsL/HXqgRQloufiurUcvVT0rNwANTLezYS6HGiMPRblcpYCUb99DaZvxTsDFjhEg4lM23ONNFr+hDl1h0SR6fWRFcgsGI/YRoAOUEkK9DSIBAt5s= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:TSQBaBGO09/8vzV7s8BUH1G6XZyGrY9wP6nHHhq8Yl//846jn9q3TUzgWmkuxbKFeJ+LwIwg8aPPTfnFnsavweZy5d7sPNfuAXcyyym8mBfaXK6/pCMpsEEnyxYI3yDDEGOLSxavKCunAOLI9b2f4NFnwAjaNGCeeCdArHCIQDS4edNlmReRgrryetipI6eKNnz8fJqqK8hoeFn9eF/yiuyABakRs+uez3rFHY/LN2nYgYdI0vn5tis9zWQYk/Pt1KOrEt7MFFxqtOBfmorjsQ== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:ObMWlRd7l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B5kVDDC1o9a8Dx0OqbK4EXig==; 5:NRaZuf/o772pWN7PWQhwIBHHdOImZj01arDvWBAQ88K9sB/zrg+DFhZJ5skDnOWLAnZqL8ECR8szv4E4RS/iSnpasijpJbTn0ii9Y7FJT7ya38Q5y5ASo4Q7r6W/iLmlaFoTj9VtUj/L1sHkD93HuxoWBHzb6DyrlNl676sUHgg=; 7:Ue2YrpxTmDpSGkRKYdhXpPXn15zbnjl5Zd6LREZpSRPOPR/DuMsQRL/pJQ57MJk+7zwZoNYTdxbMKwnzaxRhoV9OAKOociO6geCEWH/Yksp4+s4I8nEGyE7qREqBIqLuZFIpXOvswKaJDEzKA/0w8JB4kL0V8wgf9lPyXXc5w39roYGG7vOiCUTxsjTtAAvLqW9Mp7ciB46e5k1eG2Krx8y9IkMDm2R4ZGO7FfQnRFJgbfCqdMkbt9upR39uOzuM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:41.9185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9be4d355-9192-4d40-5f46-08d623c9ea0a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe51::70c Subject: [Qemu-devel] [PATCH v12 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 Reviewed-by: Kevin Wolf --- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 95e1c98daa..7277feda13 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) {