From patchwork Fri Aug 10 06:26: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: 10562271 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 0E415174A for ; Fri, 10 Aug 2018 06:31:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2AF12B41F for ; Fri, 10 Aug 2018 06:31:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6FFB2B438; Fri, 10 Aug 2018 06:31:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A5212B41F for ; Fri, 10 Aug 2018 06:31:27 +0000 (UTC) Received: from localhost ([::1]:54565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo0xK-0001ey-NK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Aug 2018 02:31:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo0tf-0006xz-VK for qemu-devel@nongnu.org; Fri, 10 Aug 2018 02:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fo0td-0001m6-BN for qemu-devel@nongnu.org; Fri, 10 Aug 2018 02:27:39 -0400 Received: from mail-by2nam01on0135.outbound.protection.outlook.com ([104.47.34.135]:24126 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 1fo0td-0001l3-1Z; Fri, 10 Aug 2018 02:27: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=5KZMmlmN7dOAE01Wi8hStPLGyKFALSicNbHHp0xlCmw=; b=aCvmZc+Sgh9I98lQATxGj4PMVVqTSRLbCz1Cqx2kT7gC6/UmTvS6SaNaC6Mschq8joIalKHxclNfu1YLWCaL5+VHpXmfaSDGUdDdmbzKC7hNh+ZdGC+BbgOGI24ohheQGeCzbrgX3uXpmoDkbVyCJAXvkuAOxGBGr5sz5c3UbX0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by SN2PR07MB2623.namprd07.prod.outlook.com (2603:10b6:804:8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.21; Fri, 10 Aug 2018 06:27:32 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 09:26:45 +0300 Message-Id: <20180810062647.23211-8-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810062647.23211-1-lbloch@janustech.com> References: <20180810062647.23211-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR05CA0232.eurprd05.prod.outlook.com (2603:10a6:3:fa::32) To SN2PR07MB2623.namprd07.prod.outlook.com (2603:10b6:804:8::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e55893e4-5e9d-46cb-eec2-08d5fe8a5c56 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989117)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN2PR07MB2623; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2623; 3:KEWU+I/vrJEL50icHZj+ubsadiYC4+LciB2BTrTQ8Ups4AX8hgqbiRj/tEZ7rg0rf+9a1M0K9kqGaQBRSC3p1c01DjyXxg/3gh6SZ/ElaLe403eXjDW2T2HUn1z3dBCG6I4EJS0mbqjNIAVBkiW7aZXqRb3HA4qaoDbwxZHqUCrtS/eZkoE2eNfZXCKRIiw9sIYc1nMly6taH7+Lf1mgM4qdJvcoQVohoB1gSzW5nKweaDCV5QQHAdRY9rUyvOyF; 25:L2ftel0RBz9oocZwZJ/bhQXODxVm5SnG1Ha6HQce5M3zFWs0G+wG60rFDBGHCjmx9+l9b2vbptJtae7vOzpd4OPTbnlGbCnriW4ZkUtbEE+nsasNa7CFTdU6fugZy0/SdcmWu6a8Ueaypdvadky9XfxS6PVGPi8PoRR12CexVrmZ6OYPQvvwRHKzx6rUAc/EtDi82Ozu/wwZk5iIUE7ytVlKPyRqKfuHCUqVIoS2A/lfsna30PjEhiA5xpibOtoSm3RVnH91gQusFONqWFLqn5BlPnYa/NiQlwItcF8tRK9LPN3ND/GxJth8fp5AOSsO1S/RIlQPUpj1SYu5Ici8iw==; 31:VFVAj/oYLIBpVwqObdPxJnhqE3XUwQIJwaD/lpqZpVVFcqhsnqqftMqNFNE4BqDjlbRL7OJUhE+A+aqzFuepAqj+y+wPc6fWkpuisbSg5d0qrXKlbdCWJOIcozpoDfZqOTDkJ0b+G30j4VxyltLwaq7n+LL7Vhv7Ir46WaQYhB9uevd0hyiTXeUVfuQxQf7d6UPaz1oGPpPNGvPqyZNsEX6tbSp5uKAkEQwNVkEVF1s= X-MS-TrafficTypeDiagnostic: SN2PR07MB2623: 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)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(2016111802025)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6043046)(6072148)(201708071742011)(7699016); SRVR:SN2PR07MB2623; BCL:0; PCL:0; RULEID:; SRVR:SN2PR07MB2623; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2623; 4:JYzjiMlZeQNAlzPMHuUy8qjXVAspcXcqZw3yzs/NkItSABA+AT0kCyZh17Gwh+J2OLv9DwgP92UGjTihPT1nmZ1igMhP1gAEiW3XGsh5pV8kctXFJud4HryuaEVU6c6+FEOniN+e0nJjEygoBS6mo5Njs7DJig6UkUNSjjTB520kLndPdOhfAzxIb6e+cPF2dDkAFH63xgB4GuyhytvxVBmzEDO1E7dOMQNVFo9paqLGIdubpSW62mQOUg0N/y138YRVmcQ0FuipvnLKMtY1uA== X-Forefront-PRVS: 07607ED19A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39840400004)(366004)(396003)(346002)(136003)(376002)(199004)(189003)(36756003)(2361001)(68736007)(47776003)(107886003)(105586002)(4326008)(5660300001)(186003)(106356001)(16586007)(2351001)(6506007)(316002)(26005)(76176011)(16526019)(86362001)(6916009)(54906003)(6666003)(386003)(25786009)(478600001)(11346002)(6116002)(8676002)(3846002)(81166006)(50466002)(2906002)(81156014)(2616005)(53936002)(51416003)(446003)(48376002)(6486002)(66066001)(486006)(7736002)(476003)(305945005)(52116002)(50226002)(97736004)(14444005)(1076002)(956004)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:SN2PR07MB2623; 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; SN2PR07MB2623; 23:bNCXZF5urIaWKFNLKsbGb8UYPe64e1VrJXJFLvuzK?= ilu1RXynw4dhdXrR8BDH+2D9I2yDDCj28zmvn/y2/IJLlYEKFY9iRtMxCFt/Jba4nYoX+RAVYiffGQEUYBwXLM5JyMfwjYjxQ5kxgz1InHNO9ZJBP+7xXqMA1QArqCo9f+nMI+blkNkTtCNhh8jK4kW8BYBPqtkX4mvavV6IW6WzilwADHWnFdT9USOGSSY3dtnSVIkccxh8fPnNKFNSc5FeHYra/tRpZ9lr37/j59Z+HNSyPK3/+XLYmqMEJrk8AAtqAQCi8H64KRiWswr/S1mTH30d16sRotDv/U8xQEUrxA+xkiwPqKVT73a7jprN5A+M6KK47jd1tn6yE3eEwShUzUiO+KiSiAMoWXiFGO9k7eUcx6OhnPBZruxla2P6jaBZXKjo3d6hHAi5hdpda+CJ3uJbeqeDgGa7XdkrqxdfRlCjXbStZFHyz11Jb8hw5ooXPnxlmO3FdnlBD793Tyrt8trsWKaJwL2CCyGv7qpCxNT4yYZZ/vmXXKxCWECWTkWTUAyTycfpAW2zmzyPSpXIV5k/dID5/NW8tmBdubwJ7QYf74bOsVQvNkhG7W4VNhyuu+BosAZN05m4URHvH7wMqBwVqvGQm0VusmlJ6eINF5YCe5Zc5I1yUZ+XKXO9eZGJBR3lnnrL/TCVpPMGp8OGIaMVX7yggil5biaQC6bZwfFk+U0Jrn/wyPle2PUqT5jCFykAvvs/wZqOI6dYMfWS5txI8b6wt5yYqdJFHGVoY57jF5/639oCCwGizVEVvg09q4MqCk9iqYp5qa+pT5tv+bKqE139bXCeAh1aTf8d9gm5hPf+rCbU3g5JxU3aOPY7n8upgTGYZFqY5aruh8C0tRSiP3lOeQBsVHmIEOOJ/tAdmSw38o8Y4WGoz5jnnwe4uvFrE89sT5a0/L2Gmo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HMq+x2P0A6q7a7c3gjX5HB5lhwhWww86f+Wi+LQ0nKifveXARLKo5UP27Pc/QVkdM7FrMaxYCmg2mLxp0RUCijKBJ06+wP2U+PdbIspMVCr6B+KNPQ+8DQGNkN1J43DG9H4g5PPaHp2Q9LnueLr0DBrw==; 5:oxF2iSN0Yh8FNbi3GI3fsDdStvXdrQhPYpo6Mew1nnaAkRlXg3Osuz39oBbThKE7oHxQ0TYjP/bxXTVIU92tQVf56tEkiJSBzJ/T9L2zZYE/78hRufRbiTuHIrKJ1uIoo0cPLPLL8uaPmReE1odmDsDNVHd23T30VOxSxvxLBA0=; 7:DxTe/1ypKodp9V0xZJ4vBWwrKrkCHLhFFROhDPwp/EPf+2O1bfcDLk28WvA/6ATYQ2BNoKywRpJ37W9aUqrXPcMJXe894k+tzRd79qNJQFlSZVxE64LgF7NwMoPaJ1oYKcAxUmRYZRxzfR2xIifQXZOg7bbm5fRZ3nhyjdC2uJFiAINS9haQ+J61gf4zkpM9dpWFFX9qaW4Vtme4tL4rVH8MSLzmJx/8qHTSPzmaUEXLdSeafeM48AAjDrnKwPk/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2018 06:27:32.7967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e55893e4-5e9d-46cb-eec2-08d5fe8a5c56 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2623 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.34.135 Subject: [Qemu-devel] [PATCH v7 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 434fb89076..ba4dfae735 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);