From patchwork Tue Sep 18 15:29:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10604509 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 50B6915E8 for ; Tue, 18 Sep 2018 15:40:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 359802B768 for ; Tue, 18 Sep 2018 15:40:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 330A92B857; Tue, 18 Sep 2018 15:40: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.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9FA4A2B7D1 for ; Tue, 18 Sep 2018 15:40:47 +0000 (UTC) Received: from localhost ([::1]:40919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2I7K-0006Gm-T2 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 18 Sep 2018 11:40:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2HxH-00078U-Cl for qemu-devel@nongnu.org; Tue, 18 Sep 2018 11:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g2HxF-00041l-PU for qemu-devel@nongnu.org; Tue, 18 Sep 2018 11:30:23 -0400 Received: from mail-sn1nam01on0107.outbound.protection.outlook.com ([104.47.32.107]:28492 helo=NAM01-SN1-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 1g2HxF-0003aG-Hb; Tue, 18 Sep 2018 11:30:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17jCltmobbbrulmLbfYr2kRyJVbuhFZj/mJJi9sixuc=; b=ItqrWWADVDqK+rLZP6k8PJfxASE1HppUX7H85pTLUDSyqmg2CEgZmyq3dtwLtJFgocQCRZz+kkZX9vCKhKmqJe+INvb2s9cg0xry9qyBhYd7kHfK+4pXkoDouiRTCuOJIeNslxL/aRu39YcjWwksRDM6OvALEoyPUQTYRFsvIe0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CO2PR07MB2614.namprd07.prod.outlook.com (2603:10b6:102:14::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Tue, 18 Sep 2018 15:30:07 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Tue, 18 Sep 2018 18:29:17 +0300 Message-Id: <20180918152923.24824-4-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918152923.24824-1-lbloch@janustech.com> References: <20180918152923.24824-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: AM5PR0701CA0016.eurprd07.prod.outlook.com (2603:10a6:203:51::26) To CO2PR07MB2614.namprd07.prod.outlook.com (2603:10b6:102:14::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b8fa16d-e71e-4c41-21d9-08d61d7b9e4c 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:CO2PR07MB2614; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2614; 3:NjdBD4Uj9BKS318H+JuEzQHkGl0yNTyzfVUMkvNaEj5L3fwATcDLMWoeE9MZPft6AR2YmuJXC88u3VZdrFbExV97KAlGZnUaZzyvQO3u1JRdWh9+B5c8lWNEfNq2VHFpkFB2yh6LcfXWBBitc3u5NKoWBDSxYpMQwtlXRPC0oWjRtXkdVnrJCjlJnJnMRKe7h1ofs3KQ8aR0jv24Cbq+7LbuQiXJAvUnSH72qLS121ZS/QGfOxUySVUCGosZCeTQ; 25:hvp548O9vkqfzGpxS7F6g/yactkftZaoQpfcZRNJ6KfqYytSkhjZVbAdiJ3l0tl8cy+MZldqYPylyTo2BxVJiy5mBsfvG9x1MiFbKL+0rRA9GVkKeqMI5FNInm+2UJfDJuu7TCDXJNZA0dv30G62II+/FC8daNa3tapPg3Hw32powT5GDx0tlZ6fFEZhnntWOD09KrBDx7ZedHOVvbjB9OfPQHFpPvkqiB8DUC9ufg9AGuYXR6znqRp8qR2ZrpiIf+UAFJ6BXplr1EX2u98JzNYyOmPCQXCOkhD7ujevSuZDBF/4t4SGVawXeETQEMxD6gzJ2/VTBdE0gLOUCJt10A==; 31:wlJ/hEMbE5c6+mIdrugJTYt1N/HGc7sw2Kmw1TR2WvTDG91ROonW4t+FyRoeuWXo4gZwJfKOZFgtNh7YSeh0rk7MzHUzJKxAWxTaEWwlqrgU5G80tCrIMfqxu/MDRw64MIdtgtMasX5tQNl2UjZWztVY6amHFXZGjCPihJyEUgS07V01izCBKZaV0YVWRkMIIB+Qmhp6XHRL8du95QHieBNp5YfDRo5bqAfLfRs4p2w= X-MS-TrafficTypeDiagnostic: CO2PR07MB2614: 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)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(2016111802025)(20161123564045)(6043046)(201708071742011)(7699050); SRVR:CO2PR07MB2614; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB2614; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2614; 4:F5tRQAb7ALn+96DdfnPLafnrDmQRfeicJY+BH+1fiUd3ZW/jqrJZtdSDpQope8oXTQ8AzHGsNDVZXWAZRmWlceL6IO7g0jN/lb/GvKRbJCbzuJ9FldD8iG1Rj23l6QXPetTL5TBbapj3FEg77KaUB76YB1mq+5w1Pd7o1cGReEAgR3XiDVwhZ+lsXyumOwpstjEe19DM7YckC/kHSrM7taeWyzxg3cf3linfNSiD/vPfqIv1MANb6YEWmL9Wu+2FpFINDlIqGwUZZdOHPvXxVw== X-Forefront-PRVS: 0799B1B2D7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(136003)(39830400003)(366004)(376002)(396003)(346002)(199004)(189003)(386003)(956004)(47776003)(36756003)(66066001)(6666003)(68736007)(53936002)(5660300001)(6916009)(486006)(6486002)(8676002)(305945005)(8936002)(81166006)(81156014)(16586007)(54906003)(16526019)(446003)(476003)(316002)(11346002)(2616005)(186003)(6116002)(6512007)(7736002)(105586002)(52116002)(50466002)(86362001)(575784001)(76176011)(26005)(6506007)(97736004)(106356001)(50226002)(25786009)(48376002)(4326008)(107886003)(2351001)(2361001)(3846002)(508600001)(51416003)(2906002)(1076002); DIR:OUT; SFP:1102; SCL:1; SRVR:CO2PR07MB2614; 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; CO2PR07MB2614; 23:Mc6tUI+cUez+wa6PTDc9vFfnsHWckqR4NJlhKG7lK?= /h9z/i3MLuhhWzb6ouPEJ7agfq3CO8cQaEA/L3LPGpF7G6rDnnikdZvKYEeP8lpdMSvxMagBkPIlEbP2QMXyg5EyG3zMDqyXrAlnMjgzH1dBMAusJ/PmQD6VnEcPNS1HaajWDGyTWN5fzX5qrI7hXGALpPsOuveQU4Yk8wodXYtAvYmjIhvlOrjaCiMkUTLO680XZOzcK+bxRwP5FRS4TLDg50OlMsvNyynCZs6jiC9lkBivfO1i1Ja2BybLLKyBBkhRbGMEh3MJ0SHBZr3+2B1W+saNK87Ao2tVM9030lcKNfPqNobgkFZLUz23y5kolMPZ3cWASytSXUPVlvISn+c3eqi/z2eSKknQD11r96S/9GkdFlAO2gPa0kOWNfxzOrapdRx+3RCDVaYtU2jCm+lGEekSNJgD+GnzgX3CTmmpTd2pGF857nggmds69xxp/abxk1PVESKJ91Ow2bzUuc0zLB6lLtO40pummgUNQpA1f9rcQ45J0HI3Cxe2XaiX9/YmabuqrAl/kPizrlSW6Uxg4TOy6rsbAf8j//ZRz+/ePXvCTsKhP5TyWupICvsMmncE0cMo/uQo5RATcIir/gyFV/O30Axo5QTXWjEA23Mjl7TpNeTPeThCYbhllJkGeCqIl3LLQqkxkF8GTykcMNW0L/itcK4yJdTDPrI+SDvc5mAi9xPLSGG4oIZFm+5sr0h9LQtoke9Y8EwLr+zU3muQmFJ7VcHwfttu/7Zrq5Mm+asYfVWTG7AMrS99y3nPJi08t7NIv8Pa9cQIQJhSP7ah4ncs2XYzIjqNytU0mlSuRaJkCtVBmPrnO11/HpKfH03+hSJoGw/4qHa0yvOmIhHiGT4cduV2RX6CnJ9Juwc+h7rWykeWxXoKw+1eyMeFVVbfby0dHVPCWLHRIdZI7uWHoAt4if0JcEoW9p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JXNSMYJGDffMocxpYi2gB6idNdwjluEfVPq9bM+lN3239VuIZr4xS/dZGPCz3khyY229Ud3K0OK86ABt9Ky/IT7mrrnomR2sogtrZGZHQaDlB+kZzoxfPY0XFbnXR6mCbCSg==; 5:U7Z1EYgcHsOMT41HJki63wwrYb41B8wUVzg3vBo+tC9iZsVpwC9xDi3G9ZcryaK7VQ//N7qzEQuj5rJ/ga8qX5EEFwHZzqX3dCntVfcFWESXV1gtm8oQ/MKyhT6evuFo4cq0mHyLyhO2iQoODWw6HMFMZLA6LPtOHrTSQuhjsiQ=; 7:dgaqHB/i/YmeusMTqw9o1dIMJ0eyEPJc/J0FbL59G/upiZbeZ9XwKcpyxe2A+xCAQE41cNQJEp26ecy5OrTSzR1IkXKELxSZccUwdypgKa6wrRvBfu4deBvACbZVo2DSsl9x2kz+hrVjsayXXuMmFNkgr13Z1rRMr7r2YQWXVsWyovCq7+1EePgai76A/OStOLfK9XFhno8ixZ38T4W7kOJb8FZpiycAYbAb1dPqq5jU/43hgC0w+bwVdNBKP+mw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2018 15:30:07.4029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b8fa16d-e71e-4c41-21d9-08d61d7b9e4c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2614 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.32.107 Subject: [Qemu-devel] [PATCH v9 3/9] qcow2: Make sizes more humanly readable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 2 +- block/qcow2.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ec9e6238a0..67cc82f0b9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -830,7 +830,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } else { if (!l2_cache_size_set) { - *l2_cache_size = MAX(DEFAULT_L2_CACHE_BYTE_SIZE, + *l2_cache_size = MAX(DEFAULT_L2_CACHE_SIZE, (uint64_t)DEFAULT_L2_CACHE_CLUSTERS * s->cluster_size); } diff --git a/block/qcow2.h b/block/qcow2.h index 81b844e936..a8d6f757b1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -27,6 +27,7 @@ #include "crypto/block.h" #include "qemu/coroutine.h" +#include "qemu/units.h" //#define DEBUG_ALLOC //#define DEBUG_ALLOC2 @@ -43,11 +44,11 @@ /* 8 MB refcount table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_REFTABLE_SIZE 0x800000 +#define QCOW_MAX_REFTABLE_SIZE S_8MiB /* 32 MB L1 table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_L1_SIZE 0x2000000 +#define QCOW_MAX_L1_SIZE S_32MiB /* Allow for an average of 1k per snapshot table entry, should be plenty of * space for snapshot names and IDs */ @@ -75,9 +76,9 @@ /* Whichever is more */ #define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */ -#define DEFAULT_L2_CACHE_BYTE_SIZE 1048576 /* bytes */ +#define DEFAULT_L2_CACHE_SIZE S_1MiB -#define DEFAULT_CLUSTER_SIZE 65536 +#define DEFAULT_CLUSTER_SIZE S_64KiB #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"