Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2331890imm; Fri, 7 Sep 2018 14:49:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZdk8qq04LoDHsTXf6WO8iPig/0QrsJY+bdrhirBET3yq/abhXV2izKIDSjJeHsCZGqQ6j8 X-Received: by 2002:a17:902:b947:: with SMTP id h7-v6mr10185674pls.157.1536356977195; Fri, 07 Sep 2018 14:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356977; cv=none; d=google.com; s=arc-20160816; b=kLIc8cTvZMCV1npNYj24DmWweOfJ40fMZ0Ta4R99CNLMV2p0QTMoAnkHP+cWYyFNCP Zz1lPCDK1jwDI6UOSmcBp3gkAFE5XgzF9Ts+KCqhabYXCsur12wNDzqYbaq/RckIS7BV u1YCuinTw5TQF1fVsVSPxpgWBPuy0enkKC4WtSxA29QgqxfdTLj5In/SdhoHutx7zI1n CSTwGDd1mACyyoA4lnt+QxbDF5qOL/mCQVLV3qLucc2YCT8Tzje6LZaOfiIZGUqFDTv7 SDvMNDPdxsaP8Eg0Vjc3VyQu+NuAnKthvbJglEA4MoEurP7j+3LyJL4mREND9RMfQImZ tKWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from; bh=mgtGZC8JwvC/PA6Qp6JXBVVSXpsCcndwOCf5O8ERVbo=; b=aAgE9aqsJQvIObotzitsGHvI/xYS8aj1ac/1qzv3Y0ZwvZmhPkmbumYi1u3AUiOTme itUl4yEUhrH+g4StytfSVUTUjjM5Bpv/LJa0LGwvJvznEseR8KmB5kcS6/8BjUp9vJAA ZYCZ+6nYbFy9YZHKPHaYXd59JpShMISIkq50H4uRbB0VkbL779vFPYT/Iuqts5QOxGsZ nGfe+JBBhSki829vhfhvfbPVUQ74KD5cprVTQo/v7Ugn4oKyofH44idLKyC4v5YtK7l+ DtZZCdZeoa5u8EYQhWCeVmrbZ/fEocRvj9gz3I2vUJGObxr3MkgCux4g4ud7D5JWCOJT o4RA== 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 i9-v6si8353311plt.433.2018.09.07.14.49.21; Fri, 07 Sep 2018 14:49:37 -0700 (PDT) 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 S1730847AbeIHC2P (ORCPT + 99 others); Fri, 7 Sep 2018 22:28:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58098 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727743AbeIHC2O (ORCPT ); Fri, 7 Sep 2018 22:28:14 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 34788F36; Fri, 7 Sep 2018 21:45:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Snitzer Subject: [PATCH 3.18 07/29] dm cache metadata: save in-core policy_hint_size to on-disk superblock Date: Fri, 7 Sep 2018 23:10:28 +0200 Message-Id: <20180907210910.115818625@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907210909.523240901@linuxfoundation.org> References: <20180907210909.523240901@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable 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" Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- 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);