Message ID | 20161115063715.12561-11-pbutsykin@virtuozzo.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E3D56047D for <patchwork-qemu-devel@patchwork.kernel.org>; Tue, 15 Nov 2016 10:11:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78A57286AB for <patchwork-qemu-devel@patchwork.kernel.org>; Tue, 15 Nov 2016 10:11:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CF7C286EF; Tue, 15 Nov 2016 10:11:49 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 C41FB286AB for <patchwork-qemu-devel@patchwork.kernel.org>; Tue, 15 Nov 2016 10:11:48 +0000 (UTC) Received: from localhost ([::1]:45226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org>) id 1c6aiS-0003XZ-32 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Nov 2016 05:11:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <pbutsykin@virtuozzo.com>) id 1c6ai5-0003WN-M0 for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:11:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <pbutsykin@virtuozzo.com>) id 1c6ai3-0003cD-4v for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:11:25 -0500 Received: from mail-he1eur01on0101.outbound.protection.outlook.com ([104.47.0.101]:45385 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <pbutsykin@virtuozzo.com>) id 1c6ai2-0003bc-Sz; Tue, 15 Nov 2016 05:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=UzB5w0hp093owQ/59GvjYKAGcPGLm75w2WTgDyrVd0c=; b=bEpY5OD2Cfr26PrtCBlpbVPeQw1Ga4FbCLbCIyvf0e4GKV4rtS2Edt1ZDtuoCJMLpPv6U1pGDd0MXGD+tIKJWLlw4q9vMKZn7uYb4F5ewNae4XtLyyXyTre57Hld9DF4NAZ76/MNWeVv4t0w95IwSAMBE5mtwPrPf01H1D74Hs0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Tue, 15 Nov 2016 06:38:23 +0000 From: Pavel Butsykin <pbutsykin@virtuozzo.com> To: <qemu-devel@nongnu.org>, <qemu-block@nongnu.org> Date: Tue, 15 Nov 2016 09:37:07 +0300 Message-ID: <20161115063715.12561-11-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161115063715.12561-1-pbutsykin@virtuozzo.com> References: <20161115063715.12561-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0101CA0010.eurprd01.prod.exchangelabs.com (10.169.240.20) To VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 2:ijHIeR/9Yxel4l9fagM9Ki2nu0eFaTExk6bgIRg+PcdyZHD4RR6cB07/TjWRER7E62mvbDhHftveI9QPBZ1c031XWu1fP7ISlPJJ7CNPtDuDJTsUBZeiJSKYdLAXU9Pu6BjaGzGGAne2dztQA5pRiJFA4PIVdXvRVTBcYhkwrpA=; 3:G2QAYAlc3qGAAy/NLtoAWip6Th+61yFsMkTBxyGm3eqWG5O5EREmuGPcczNuu/7xgEfMtf91bhbUi7o8H6iGN/Uu8TavXIiFQnCSbsMTow3On3I96tRdfK2yoImz1pP4uj/wMAPmQwVPHUCVpkfe9+ZeLZ3rfXWz1PtbtHRLBik=; 25:o9qSFSTwi6isgxgZ6ZYpfgcz1BK4YN9db+7AQBaTgd3VMO4GBgm1py9UC8wH6cjSeTo2AKjN2HfxVNt3lvQl8toNs1BXjCEKcp7qh4EBQKV7kGq5AaznfTVNBJmcQRIaPQmR8WQH4Hb+UlrOC1eVtb/G3KPhv878BvVLogFff3XYw0HSy7SSv8sR/U9rUhswDqJkQjgEUzSjhRrTAO89dhSi9lqXNObGVQPsm6wz3ACAHUX1ok4IQFu6oWWMRlMvGRHS6cCspzJvTnuKFswBXuyBoftMX7cC4Xo3V8DVsWqGBd6EMsX1m+suFDfBGc2anzoWwbULBQ3JImF+sMvcM16+1P9dDd8br28Hq3M9FoxL72QqJ8O7wT9CD/YcGpvDHxsRx3H1B3mNn/65EO4meBubRqmQzOSiGt8Tl2OUkXjpR/xAf+R6IHhtG3dAE1AN X-MS-Office365-Filtering-Correlation-Id: 00a9be37-2eac-41b9-47ca-08d40d21ffe9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0802MB2558; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 31:VA5jcvVWBO+tFU8sipxoGIKinvu+g3TOkpJwhmAhUNmHc59SVpzfpS05QDtRrmyU9vJEot2+XtsI02mau2HpI5zkOmspxaQAKYrw6b/F/LOPCpcWeqBIZxLBYcviT2rzsT2gT9H5eBdoaoZfPlcbeU+pa4GEz4AKfpQ+nWBdooZfMh3q61wRKyRcy//8q5D76QFaz7tQzCqa5aLj/9YRc8Q7cujHd/7jcZjOd/AeafI3gNWNFwiV5oz79b77flVw3lO/wZgjEMcaLv/tD5yBkQ==; 20:zaa2tJee3It4sbNDPlK/PJ7yZ5tghxh6hzmtwUyinwafP7+rW8XggP11kVJtcX1GQE883y3gyTnCIWcurHGH3pMFIV3MW18kPJ2rpKdtAoI3ufr5s1ErvMa7bxnXQFwTGsf5PA8+Bzo+o516yDJHFXkgAlg2Qj80R/6A5iFZw44=; 4:aozZpkXNLpwDsD6HZXapVHfPLLCox/jEwhO3AUNPuRtyMuB3QmaWTKg/R7nNOsyrl/2IB64b34QsVws0hu2Lm9uSVGD8SXMVFELGMJlgT7c04d0QUABnWfj4YTE2t/rhx6FXUMI7iJ9HtYN9Q611NVqEukIIO+01RMIhDjpz9SK8R2YjKI/ucPFuS2A+9Gfecvin2e/hB0HuqLf4lTht09o99NWQMzYGfkHHFiSOnAjJISVu4I3XycxhseYcyb5cVHkLqJ2B6KVf9dvY0Sc0lzTg8yPTs2yxAvOKSP+Qyt4iwok635CXhNsSTDv27IdXXCbkQo9MRM/EGALGj2GGD9TGRNojxscxl+oziBPM0MPmX46UvTDPVOsTl9XJY/OYlbRELS/Xoi7Yxdxs6s6LCFJlLW3jwHfVhCX/WyiHcUoo5URZbI1V09IdWfgRqp2n X-Microsoft-Antispam-PRVS: <VI1PR0802MB255889EE90DCCA2824CCB3F2ACBF0@VI1PR0802MB2558.eurprd08.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6061324)(6043046); SRVR:VI1PR0802MB2558; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2558; X-Forefront-PRVS: 012792EC17 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(47776003)(105586002)(101416001)(1076002)(68736007)(106356001)(6666003)(76176999)(305945005)(4326007)(97736004)(66066001)(53416004)(189998001)(42186005)(69596002)(2906002)(7736002)(5001770100001)(7846002)(86362001)(48376002)(50226002)(2950100002)(50466002)(50986999)(5003940100001)(33646002)(77096005)(81156014)(8676002)(92566002)(81166006)(3846002)(36756003)(6116002)(5660300001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2558; H:pavelb-Z68P-DS3.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0802MB2558; 23:81056JOUUIstk4CPbhECZRW889Qj080m0mD5BGz?= =?us-ascii?Q?R3mvpEZ/eB+YxF6dlilgAOSChAIv+8jAb6MsW/tMMcUcQzwH1N+FArv03tbw?= =?us-ascii?Q?jUfP0EPGXYqrvrG7ruGdgJd3dhUxURji56xd/nMwEA/Vx4sgs3cAUbwxx4Jn?= =?us-ascii?Q?T7tmjYcvNVDsy7r/odVol3F/hNY11kZpDq01vYYaKP8BCa4lpBOc5dXjTsGy?= =?us-ascii?Q?1VALppfJhRTph55/AVatICXXEEiumor6+OA8BUU8ONUWV5Pi6iQ2W+sOOyjW?= =?us-ascii?Q?igyYMCnJquKFU6VgX/x42sD5U05lT9DIAWi9O4fzgidaXRcHkkLTvCsNVPx6?= =?us-ascii?Q?K+4E9GmtITQYmge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hc0thAYswYZ4rz74U6M1PbgU2C4Yj33fL0HtGF54YFE/6VduhjCqo+ALKMYAR+D32gGQZ2O/nBM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2016 06:38:23.7376 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2558 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.101 Subject: [Qemu-devel] [PATCH v1 10/18] block/pcache: skip readahead for unallocated clusters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, famz@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/block/pcache.c b/block/pcache.c index 3717037..1f3800d 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -223,6 +223,28 @@ static RBCacheNode *pcache_node_alloc(uint64_t offset, uint64_t bytes, return &node->common; } +static bool check_allocated_clusters(BlockDriverState *bs, uint64_t offset, + uint64_t bytes) +{ + int64_t sector_num = offset >> BDRV_SECTOR_BITS; + int32_t nb_sectors = bytes >> BDRV_SECTOR_BITS; + + assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); + assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + + do { + int num, ret = bdrv_is_allocated(bs, sector_num, nb_sectors, &num); + if (ret <= 0) { + return false; + } + sector_num += num; + nb_sectors -= num; + + } while (nb_sectors); + + return true; +} + #define PCACHE_STEPS_FORWARD 2 static PCacheNode *get_readahead_node(BlockDriverState *bs, RBCache *rbcache, @@ -242,6 +264,10 @@ static PCacheNode *get_readahead_node(BlockDriverState *bs, RBCache *rbcache, break; } + if (!check_allocated_clusters(bs, offset, bytes)) { + break; + } + node = rbcache_search_and_insert(rbcache, offset, bytes); if (node->status == NODE_STATUS_NEW) { return node;
Typically, data for unallocated clusters is filled with zeros, so it makes no sense to store it in the cache. Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com> --- block/pcache.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)