From patchwork Mon Sep 24 22:53:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10613011 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 0DE9C174A for ; Mon, 24 Sep 2018 23:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CE4929908 for ; Mon, 24 Sep 2018 23:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F186F29915; Mon, 24 Sep 2018 23:08:24 +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 669E829908 for ; Mon, 24 Sep 2018 23:08:23 +0000 (UTC) Received: from localhost ([::1]:49148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4Zxm-0003hx-37 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Sep 2018 19:08:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4Zw9-0002Vi-SK for qemu-devel@nongnu.org; Mon, 24 Sep 2018 19:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4Zkh-0003KY-JX for qemu-devel@nongnu.org; Mon, 24 Sep 2018 18:54:54 -0400 Received: from mail-by2nam01on0119.outbound.protection.outlook.com ([104.47.34.119]:39906 helo=NAM01-BY2-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 1g4Zkh-0003K3-AC; Mon, 24 Sep 2018 18:54:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1HohcBbvVgjjHwsA8Okvkkqt9uZmZR+V8sG8pEM5aBA=; b=caCoFRX7qRapXWINThEAjqbWLS1n1gwC7vkfB0G6EYYrZMcsCEA4Xm1VT09hh+2MPjAZLYdFoZNxjTEvmzXYXM0xHi0iBcVM3GWVFyrPiIUAJ1mbUDNPD4FdOyisTbUHtguanNhtNlmokmaHOMFXQjnRxwjCr6C9IYvFXKEtBQ8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2617.namprd07.prod.outlook.com (2a01:111:e400:c637::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Mon, 24 Sep 2018 22:54:46 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Tue, 25 Sep 2018 01:53:55 +0300 Message-Id: <20180924225357.24245-8-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180924225357.24245-1-lbloch@janustech.com> References: <20180924225357.24245-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: LO2P265CA0063.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::27) To CY1PR07MB2617.namprd07.prod.outlook.com (2a01:111:e400:c637::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba1db814-7788-4c7b-ca00-08d62270bad3 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:CY1PR07MB2617; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2617; 3:0rCZqUP7k9t6H51tdIm2zYduhj+igalC4nAcdzJLNIfxZGjfu+sLhJVywx6kJ1C13z+QMmMiNFFL9katYy26LEStLdi6VcrDoEOaYhXfbAxrgi/P/KNUla/rSs/U7i5dsoaF0FdKfwAlhlZ4i7xDJ7rCPgu2rMLNZdQ6cBkGM+mEVUlBSvnsUsiNBqhx+6CNKn7Ti+fd513zLNfYRQZGnJMYYUDSo5QsekqGoh16z1pjYYxEXKp+vZGiG+/U0Jne; 25:Ei/MiR2E3zgFpdBVZpbl5ouo1FJpOO4QZjev6cFa/aBMkNrRRihMUgwJg5I9lWQUFmCEX4R8gV3qk/UyK7k7nMI5qVWAS8sBlnAPtUVFRn7nktOSGjJgFpkyX8fK27yj220FpNKqffrCruqYybXPAkTHZt1lQ8eqbBt1L3uIqXrqtx6e6Jq3KGa0VoulDOysySrl+cklHwX5iBnO2OyI5lE9rov8wB1g3RXsd8rC4GuLjjHPt+IxI65PQOAGZAVzDfIKMKKr5e9Tx7uDy/ya5FcKy8DcqFb/dbbxb9PoGZFngprdgDtu2Kqsh7XBaNrCTsaYOZJbCrOtOaJ0ysijdA==; 31:r9u/C3TZlnis8Xug8prOwSvuV1VRDdwM8IrUarSgEiEyHYPkMDXnO+45z8noGTcaK6jTQYqXYLKYh/ShuKLlyk4HomZ6uDOVZtisKvxN7/MjzAq7CbOXrEcsUghOQx58LOe8mq5LKhzFqH+T0ivSYJfJuNstL/ngQqji4oAFCLrXxFDH8Yh79Pvf/U2cuAsbxtpNj0PpJSTnWdz9f3sNBubVFxPPpkIJKRIemXPHfU4= X-MS-TrafficTypeDiagnostic: CY1PR07MB2617: 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)(8121501046)(5005006)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(149066)(150027)(6041310)(2016111802025)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2617; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2617; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2617; 4:9+P9m2UPK67+6sDKkA9Zh2Dv0r7ww4V85VTP8tpPu5GsdkEfGtTYLjDRiw/VmJsVQaNfBDgXQo0g4w0Y48Fe7xGlmNPyXVuu4jft9pdK7VWb3AG9/HCjIYBi2tst1MvQRE+Bc5c2co0iXxjrEhRTDRQrbilAPZ5yJqnWWLCR4Ooa0z6XOqAT51elzzB9OMRZPmxHfcsaOhP7qI//b3bVaBwipBr7BYsJ1nuCl4TdbK+vDYeX/6RgbVPNB+JGUiUeeCIo7Lj9HIjKFDZO3cmi8Q== X-Forefront-PRVS: 0805EC9467 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(346002)(136003)(39830400003)(376002)(366004)(189003)(199004)(476003)(54906003)(68736007)(14444005)(956004)(2616005)(16586007)(105586002)(86362001)(66066001)(6666003)(7736002)(486006)(47776003)(106356001)(51416003)(11346002)(76176011)(36756003)(446003)(6506007)(2361001)(316002)(52116002)(386003)(97736004)(186003)(5660300001)(8936002)(16526019)(1076002)(2351001)(81166006)(8676002)(81156014)(26005)(50226002)(6512007)(4326008)(6916009)(53936002)(3846002)(25786009)(107886003)(6486002)(6116002)(50466002)(305945005)(2906002)(508600001)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2617; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2617; 23:O+wMHx6Wuk2h7f4VIHtk8Oy5CAdmtLgLXQ7h3TNAy?= r87ZlwildSNTyIRznTaFTBaAojKa5RFiG3uZDo1d06NFzqjXtffBVss+t6nFE/cs/EMcaIpiiljBXsqysjHoconv9z9y4nPwPgPn+fyHYvDNDr3DM5QKrqoFluHG77JNrDtgb4DWIYoRt3mDc6eA4kEI87eIkVFE9RDMVZJS3SWrSPbSViSghHsdmFJ69n8b0GJ0Vs6FOk1vZB76gA6PyAxSbZzzvD1rMRSB/bwNEJqJCGaR3p1+ZwFMGNOn8bl5qy4k5FJ9orDp1r9I6MnLDzBfafPHX2/tf2Pr1NEAWUdzMgueFhsgSuqKV6aKFAgsGiCStryv/LBC4kBhL/Nq4BUOWRq4FLNwTBjGaRA2wkyfsOtVp9bScXrnYf2A3egfXRyWkuNrd6N3QrFnsCX05KGngsJoh47KfPY6QvWY21RswuNmYWmeSrHQSeVIGQHkqG8PKHX5LXK59nIbKBoa241jy4UFfiBXGv/PQw09fFZsa9pNDvn1Tn28jOiQLb9eLOje5Sm2UBHfb2mmjH6+O37Mp+ylnoj2jrOAnJwYohNvSOP/RmVANncH11DRCTBM6AdJDwMq8DUYCYfA5xrp6GuNIjjWuAx8OU7cJM91LQ/cUg/HBE5LfGB1dfMzFfj06Zo+LMI/qwUoT+L0z5PpY8SRH+4IohtAFOPxUZidTxYR1z81wthIm9agKYwwmR2dL0MVzOa35ck/L2zvxMv5wo1UJzBF0dpykEghpKb7Dp0/NbvlJcNLEXBXdkUhRlbHOytulGqMIEqWZZTM4JCZ0XLrW4XHboXNYzqXzvjsFiVQQtPvPqot+7pIHWNCwBpv5EzBQYcmyd3vNo/xa2HWQhUIsbFuRGEn6JcQKuXP/RyXJKyrsoNvs/pOD1d4QUDz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jji5RRBKXNM4YNcArUiFIhsD2fOGE1ZppvMkF/JSpNYpj0vR6R4k+PDegqrXvpP81mJ/AwRQJglZODZ6T3lGvWzrptxbDd2u6oU2/+l5M1+IWnP3ruONC66oyAs5sG4QsNz9Qx/qoq+LD3Y4WDwkcQMTuWkh6qqIRCcylbIhHZxUECcSZ6sg==; 5:ptrpQvUOh5Ix5Uk1eIsjjJ3A0WQMbcPIb0VWWvm043wDqZ+0n0KYnpvPn8lw/rh0JOIw9nXU4PVucyZURBjrN/VqkLgNOzNvr2535n/wwWjCoog6nY0ltmC8P/xEvU2A/Z10hHpaxftMIBdyLT/TY8aQ62YNjD+1krXLehKW8cA=; 7:hUwbnWeR5ENOM6kIV2sC3WQ4Hlu2s2Is/iaNhLNj50PTah+NCY2zji62KLV9bx/0LktwrAlNMq9H4MgRS8d9bPEMYpPkG6Q48oocbiKwPh21tVemN5eAjLTeQFdJOcyGU1MmV1a6D43E+MC8/CT7RpAB59PRaRWWGmp52FMtfMkoKK90EYAO9qMlkXlc1GJY0WXwrNP8IyqgcMC40U/TKbeKT97B85HT8lK95e8f6EYnYUZ25C32CuI/GF2V2CNQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2018 22:54:46.8127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba1db814-7788-4c7b-ca00-08d62270bad3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2617 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.34.119 Subject: [Qemu-devel] [PATCH v11 7/9] qcow2: Resize the cache upon image resizing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The caches are now recalculated upon image resizing. This is done because the new default behavior of assigning L2 cache relatively to the image size, implies that the cache will be adapted accordingly after an image resize. Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia --- block/qcow2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 589f6c1b1c..c68f896c66 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3418,6 +3418,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, uint64_t old_length; int64_t new_l1_size; int ret; + QDict *options; if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA && prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL) @@ -3642,6 +3643,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, } } + bs->total_sectors = offset / BDRV_SECTOR_SIZE; + /* write updated header.size */ offset = cpu_to_be64(offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), @@ -3652,6 +3655,13 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, } s->l1_vm_state_index = new_l1_size; + + /* Update cache sizes */ + options = qdict_clone_shallow(bs->options); + ret = qcow2_update_options(bs, options, s->flags, errp); + if (ret < 0) { + goto fail; + } ret = 0; fail: qemu_co_mutex_unlock(&s->lock);