]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/dm-cache-metadata-save-in-core-policy_hint_size-to-on-disk-superblock.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / dm-cache-metadata-save-in-core-policy_hint_size-to-on-disk-superblock.patch
1 From fd2fa95416188a767a63979296fa3e169a9ef5ec Mon Sep 17 00:00:00 2001
2 From: Mike Snitzer <snitzer@redhat.com>
3 Date: Thu, 2 Aug 2018 16:08:52 -0400
4 Subject: dm cache metadata: save in-core policy_hint_size to on-disk superblock
5
6 From: Mike Snitzer <snitzer@redhat.com>
7
8 commit fd2fa95416188a767a63979296fa3e169a9ef5ec upstream.
9
10 policy_hint_size starts as 0 during __write_initial_superblock(). It
11 isn't until the policy is loaded that policy_hint_size is set in-core
12 (cmd->policy_hint_size). But it never got recorded in the on-disk
13 superblock because __commit_transaction() didn't deal with transfering
14 the in-core cmd->policy_hint_size to the on-disk superblock.
15
16 The in-core cmd->policy_hint_size gets initialized by metadata_open()'s
17 __begin_transaction_flags() which re-reads all superblock fields.
18 Because the superblock's policy_hint_size was never properly stored, when
19 the cache was created, hints_array_available() would always return false
20 when re-activating a previously created cache. This means
21 __load_mappings() always considered the hints invalid and never made use
22 of the hints (these hints served to optimize).
23
24 Another detremental side-effect of this oversight is the cache_check
25 utility would fail with: "invalid hint width: 0"
26
27 Cc: stable@vger.kernel.org
28 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31 ---
32 drivers/md/dm-cache-metadata.c | 3 ++-
33 1 file changed, 2 insertions(+), 1 deletion(-)
34
35 --- a/drivers/md/dm-cache-metadata.c
36 +++ b/drivers/md/dm-cache-metadata.c
37 @@ -362,7 +362,7 @@ static int __write_initial_superblock(st
38 disk_super->version = cpu_to_le32(cmd->version);
39 memset(disk_super->policy_name, 0, sizeof(disk_super->policy_name));
40 memset(disk_super->policy_version, 0, sizeof(disk_super->policy_version));
41 - disk_super->policy_hint_size = 0;
42 + disk_super->policy_hint_size = cpu_to_le32(0);
43
44 __copy_sm_root(cmd, disk_super);
45
46 @@ -700,6 +700,7 @@ static int __commit_transaction(struct d
47 disk_super->policy_version[0] = cpu_to_le32(cmd->policy_version[0]);
48 disk_super->policy_version[1] = cpu_to_le32(cmd->policy_version[1]);
49 disk_super->policy_version[2] = cpu_to_le32(cmd->policy_version[2]);
50 + disk_super->policy_hint_size = cpu_to_le32(cmd->policy_hint_size);
51
52 disk_super->read_hits = cpu_to_le32(cmd->stats.read_hits);
53 disk_super->read_misses = cpu_to_le32(cmd->stats.read_misses);