From patchwork Tue Aug 7 20:21:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10559141 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 3ED8D15E9 for ; Tue, 7 Aug 2018 20:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255DB2A6B5 for ; Tue, 7 Aug 2018 20:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 176432A6BD; Tue, 7 Aug 2018 20:26:14 +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 982E82A6B5 for ; Tue, 7 Aug 2018 20:26:13 +0000 (UTC) Received: from localhost ([::1]:40727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fn8YW-00044b-Sl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Aug 2018 16:26:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fn8Ul-0000Du-6s for qemu-devel@nongnu.org; Tue, 07 Aug 2018 16:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fn8Ug-000891-Ll for qemu-devel@nongnu.org; Tue, 07 Aug 2018 16:22:19 -0400 Received: from mail-by2nam05on072c.outbound.protection.outlook.com ([2a01:111:f400:fe52::72c]:22811 helo=NAM05-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 1fn8Ug-00086y-D2; Tue, 07 Aug 2018 16:22:14 -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=6GY98t9WWipuGsNH+mpFhQLZk2rdzUU8Nn7LYJ3QnXk=; b=YiGMEmTvNJlrMvIKlnte1F771zexnzgNaYmYKsWoUppZ0iA7bCxyRdzk78esOO45EFrtBI19A35Qt6TyNEbYa3pZtAZf2PIdUXceREqr3GwG4lLBSg/XcuXjlLuca65i0Bd5qJqE6oLkdo9Moq16k1DO2MaI/6kEKoY63oulIrs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by BN3PR07MB2609.namprd07.prod.outlook.com (2a01:111:e400:c5f0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Tue, 7 Aug 2018 20:21:52 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 23:21:20 +0300 Message-Id: <20180807202122.27006-4-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180807202122.27006-1-lbloch@janustech.com> References: <20180807202122.27006-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: VI1PR08CA0126.eurprd08.prod.outlook.com (2603:10a6:800:d4::28) To BN3PR07MB2609.namprd07.prod.outlook.com (2a01:111:e400:c5f0::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3afe9e47-74eb-40e3-2b8f-08d5fca36a52 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:BN3PR07MB2609; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2609; 3:Jz+e69PpCXC1TpQWYuPYCGGOvHX7hkWhI6r2cut991lLPLa09e8oZk5G2GJi3ewh6QGnfqDggVGtWaDGt/gzkSVnJh78mxXpFYnfcO7H01n7lJoFcRKR3IgIcMV+g35iqSpesmQ0X1kcnmV15MxRPn/Qg+R/Xx9/RcHSJb6aJKwEoO0HBhz/I62Px7eTrHZFm7La6zO4aTUEw+XJD+Ka+LIgDzlfhaoKUgRfJLDpZDKujV47nHdnkF/quHcKLkTm; 25:dSmUZSMW0YrRLv3p3VwgyFmZcptdAMDxjGXM/J/QqHokSKMJpy2zVNl2vsdJLD/q84XrT+7rbX3elVNFXospoGj/3Vlyp1z7h++Zi0aWRTbYifRaXTCWOOWgEBRrABFWoLTSI7F4Q/+Luk8NClK0gSu65Wo7nl1zhtTSk9lczzkqktIomGZKprbJjBnubj2bS1E73jmzt9vaz/h3lzfV9cFmkU+TOxUJX2qDjb+7AV8gdMQq4BUnKdMLH3graT0UmybC7fBmJ78vDFx0kSq1eKYXuMEUUG/CcW/H+Q2B3rHqJi0Ag2qlVbhzw4x2x2H5u6rA+BxZ6YFPir6d8EMdcA==; 31:tAmnwQ1wPvJGr1061bPxeKlxSwGZzQvsAqlm7JgOg03g/unt88slDxZzxxb3CcKMH2R01wqxmEq0tY31ooluBO7RmWtCpNPgurJuTZ/jSwJKy+DLdqpNQsPfRwNAfePSn4kKQCOLqWj7zT3J0cRZId6lQ5nNc93lfDrz8yX5bA0f0gFhPOYUryeeDuuFogif9Dt6JhZnaWvucqJbyFPbwA7zG9kfySVkozV/+k0smok= X-MS-TrafficTypeDiagnostic: BN3PR07MB2609: 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)(20161123558120)(20161123560045)(20161123562045)(2016111802025)(20161123564045)(6072148)(6043046)(201708071742011)(7699016); SRVR:BN3PR07MB2609; BCL:0; PCL:0; RULEID:; SRVR:BN3PR07MB2609; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2609; 4:TPk160aI5ljhNXFA4jEjmUi+n4KjKVNK/OiU+Jki8puvUPDfuP4XhUjYLzPN0Ze6Wi+rDZaBjhV+bGe0SXOMkGBVqcCP7lhRktF9EFkFoSwdMLpequkjHiaZmZDRzgxoQJZfu8tMIfEimWM9kcDP0rIkOgPw0J87MCVaAx6/P6bxrWAbi9bnocNukqJD54wa6dgnHQCwdhGD1SHKo5Dnc/Zje/J6sPVSR/cbUIz8mScRZhbEEoLMS7IdgbxlsvGR5o89WoZWpljSgj+NsltC8A== X-Forefront-PRVS: 0757EEBDCA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(39830400003)(376002)(136003)(346002)(366004)(199004)(189003)(47776003)(446003)(66066001)(956004)(305945005)(11346002)(105586002)(48376002)(76176011)(486006)(50466002)(106356001)(7736002)(5660300001)(2616005)(25786009)(52116002)(2361001)(51416003)(2351001)(6916009)(81156014)(81166006)(6666003)(476003)(36756003)(386003)(6506007)(8676002)(8936002)(16526019)(50226002)(16586007)(26005)(54906003)(316002)(68736007)(186003)(6512007)(3846002)(6116002)(6486002)(97736004)(1076002)(2906002)(14444005)(53936002)(4326008)(107886003)(86362001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR07MB2609; 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; BN3PR07MB2609; 23:R4yQgDSQ0g3iYDuhjDll506iHaJ8MMpL/40ag8HpU?= FoErJh3+EZAT6QBWcL5t9enkBkdTlG1XYExhg1U6+GKS5Jxg/b2F5vmKVWmjWl7Ath5YBPOHRi2XLBxt9r98TFa/eq+Qt/2BTBtKg3vkneRpQamb1QCEzHZULR+zCU2Pwt5tuVMHTfyr0xKYrs4oMPuQ6dK13sEXybvwPXt2JNu8B22cdwR/i+uSOT4GSVsoj2ks3WEzA88MopudrDy2a2SuHH4mhjVoPG3sDMFrNE3PW7dxNhCiC6PjFcqPVm+YNHakcHjNvRPuxiBfg/fbuQ3EN7LyPXCMqIUkbinbfqlKbLUibDA0iH50W5y4m084cd3Hr09gGypS9pSbBAShd+IiMBFj+tfvEXsbcelBjbxdx6UstNDHYxB5mck6FpdiZO8QCQy9/KvFh4BMJIfl8DetQKWhgcBVEfXIzJthd1aFsmqtC//8pOOBbFiJId92GjnTIeuGzv9uCqrCSc/K71g/UR2PvffwkiQ54qCCNKIFyX1KZLStvm/qvSwXF4C2RcHrZfG/wKVOOUnLHt2Wr3M9STcICmcrcdYfe3+WTD3P3JCWPA/Ar7kcKeYDZH5iWEn2w9c5XPdUmW3JuZRuNTIwOMy6FUi9SUmVgAbLVOzYfcLbRzOBXRCWDVc09sQY/27DKcDCAMNKPfeu+6CtVxPu4ucjBWsm7dbqPkV8ohh2Fj6pt9xZgN2fRHm/LBCo7ddm9v3GHvKovewaMUufN5Tu4Wz8EvoDSjgaMP9Hs3JYyYNM6cSAFm6hg4s8RWUjo4pEXa0Os4kt+TTZyYN6EM48gw9aYa+8O6hKsikkyrdMiL0H15kbtGbs1YxHlbUa1QtxIPcMxrF6POeP4fEe57ekjpBK+oGbjjCXjIPPWApBcQjLc3/PyJZIzMJ+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Wu82CyncLEhZ0dYQ1uHdDmLHXG+y+gWoj3KQHfCweakoXKxss6CZDn6osZcIVEBGgUW3GFt68fQeNOsKopxYahY8Vce9r8sygPiDzEbO8MDy2qTOyMbmi2ZKlaZI9yTujr1WDuoi10Bq9uWWSH2S+JVSHGMeFozIH5YUbgoQM38lSMhTP0+1kZYqgVvda/oQ==; 5:FYGZDyeH9Xckn6xlGo+i2zLcTTVH9sNBGHDt+zYzQvFfPu5re2AO0s3V6dY1F3XDHESD8jCa/f+2PV3XzuWjDxXM+0i1B4yo0+8KJVKcuACzZ65cDJN5emEvqINChhWg+tThGUuWTFlYOq2tqmjgWzVFdegoAaTVU3IiL6aRqNY=; 7:g/rrrytCKTGAIJAqMPIh18wlaT3Fo9tqskriXAKOxE941bU7Upq5Lgf2c2rsRq0Cd9dIjPoXjUyX2Y/ftbGgHvuQw5Bnr+08MprQWu812HzzpcxV8PLRvcLDVz3bvebGlCEJt8Ow+mBOiKXpGJFk59D7+c+Ai7sxr+Q9vPTrONmAgamHjEuBHWGl9hHApy6bENIV2uGpTHc+u3QBWSTiBMXWgrLLRZGTn0KJqv6vl/S4CfHNzO2OAKy+ryoo9e1c SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2018 20:21:52.0988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3afe9e47-74eb-40e3-2b8f-08d5fca36a52 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2609 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe52::72c Subject: [Qemu-devel] [PATCH v2 3/5] 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 a sufficient L2 cache to cover the entire image implies that the cache will still be sufficient after an image resizing. Signed-off-by: Leonid Bloch --- block/qcow2.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 98cb96aaca..f60cb92169 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3639,6 +3639,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), @@ -3649,6 +3651,12 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, } s->l1_vm_state_index = new_l1_size; + /* Update cache sizes */ + QDict *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);