Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2981045imu; Sun, 9 Dec 2018 14:12:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/UbojheuqtPVRU4Cya/JhfNQPN2EF6UB16qFxWjAy1zHx6eUUqOUmFSjnazlF+dkdzzkg5u X-Received: by 2002:a63:960a:: with SMTP id c10mr8752893pge.106.1544393568756; Sun, 09 Dec 2018 14:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393568; cv=none; d=google.com; s=arc-20160816; b=z5QXSS9QJesAYkfJErIe4w5Wfwxf5gutVXiVLWqzB4KqPCk8YOmOhSL4jxdL3KKGT6 v8hd7GvFhp6T9iMwBePSGForHe3ixtvFVaMzJ3o+qmDInmLmileP8jT9eX+mCc8NCVWL qlegKCn6vdoGv6RK2tASBMW6mCQ5fkeEwtPiQ6IY7fkw9p3E3rLYXUM4WwnBa0iS2YAf pgbC5kCkyWiMvRfI3y5bIogxdaPEgYFoAY1Ub4cnclxQJKaFtNV+W3786DMDTnDeOktN 7v596ogtD81anH4dDKDNKF/DhYT/luB5uqTP1Bq+GJbxngqo7piB/WMhJG4ACUddVuCF g7fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=R9M9PJ/C+e03Sve7bp77tkKhxjV/wW1+fsi/CvzS6f0=; b=FFRzP48LPbHJban4zlIr1qUJ8rZF+5QLkLoRaAmvzjZ7ZSaPe/DRwjOSV9acSqEEWU UCOO0ADnerWIWp5GKjw8kNrxe/pUbIeuu2MRLg2O8D6/C+XdaVasrC4yv4K1AUwSOOTs GN/rpkmm+5mRhQynlQxMf11va+K9uESxFPsOaTi4dR9fdR8hdXrP4lRSFJsMO0IRimn3 Qr6DCdu1jU+KF4x21f6mxIVxgdJk6y4RVR26Jitegf3Iwd2Rvf7Q5cAzCHX+AIsy5XFT c8zXxxaXR578kt5SxCUdNf5lvXER4CDRtPognNJQGYh0735pcNb871RTqz7VIuRstSy6 Qicw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si9008662plc.153.2018.12.09.14.12.33; Sun, 09 Dec 2018 14:12:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbeLIWLM (ORCPT + 99 others); Sun, 9 Dec 2018 17:11:12 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37650 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbeLIWLJ (ORCPT ); Sun, 9 Dec 2018 17:11:09 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73H-0002pr-KB; Sun, 09 Dec 2018 21:55:51 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72c-0003MQ-JT; Sun, 09 Dec 2018 21:55:10 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Mike Snitzer" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 115/328] dm cache metadata: save in-core policy_hint_size to on-disk superblock In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mike Snitzer commit fd2fa95416188a767a63979296fa3e169a9ef5ec upstream. policy_hint_size starts as 0 during __write_initial_superblock(). It isn't until the policy is loaded that policy_hint_size is set in-core (cmd->policy_hint_size). But it never got recorded in the on-disk superblock because __commit_transaction() didn't deal with transfering the in-core cmd->policy_hint_size to the on-disk superblock. The in-core cmd->policy_hint_size gets initialized by metadata_open()'s __begin_transaction_flags() which re-reads all superblock fields. Because the superblock's policy_hint_size was never properly stored, when the cache was created, hints_array_available() would always return false when re-activating a previously created cache. This means __load_mappings() always considered the hints invalid and never made use of the hints (these hints served to optimize). Another detremental side-effect of this oversight is the cache_check utility would fail with: "invalid hint width: 0" Signed-off-by: Mike Snitzer Signed-off-by: Ben Hutchings --- drivers/md/dm-cache-metadata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -324,7 +324,7 @@ static int __write_initial_superblock(st disk_super->version = cpu_to_le32(MAX_CACHE_VERSION); memset(disk_super->policy_name, 0, sizeof(disk_super->policy_name)); memset(disk_super->policy_version, 0, sizeof(disk_super->policy_version)); - disk_super->policy_hint_size = 0; + disk_super->policy_hint_size = cpu_to_le32(0); __copy_sm_root(cmd, disk_super); @@ -635,6 +635,7 @@ static int __commit_transaction(struct d disk_super->policy_version[0] = cpu_to_le32(cmd->policy_version[0]); disk_super->policy_version[1] = cpu_to_le32(cmd->policy_version[1]); disk_super->policy_version[2] = cpu_to_le32(cmd->policy_version[2]); + disk_super->policy_hint_size = cpu_to_le32(cmd->policy_hint_size); disk_super->read_hits = cpu_to_le32(cmd->stats.read_hits); disk_super->read_misses = cpu_to_le32(cmd->stats.read_misses);