Skip to content

Commit b7227e6

Browse files
snitmgregkh
authored andcommitted
dm cache metadata: save in-core policy_hint_size to on-disk superblock
commit fd2fa95 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: [email protected] Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3bef882 commit b7227e6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/md/dm-cache-metadata.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static int __write_initial_superblock(struct dm_cache_metadata *cmd)
362362
disk_super->version = cpu_to_le32(cmd->version);
363363
memset(disk_super->policy_name, 0, sizeof(disk_super->policy_name));
364364
memset(disk_super->policy_version, 0, sizeof(disk_super->policy_version));
365-
disk_super->policy_hint_size = 0;
365+
disk_super->policy_hint_size = cpu_to_le32(0);
366366

367367
__copy_sm_root(cmd, disk_super);
368368

@@ -700,6 +700,7 @@ static int __commit_transaction(struct dm_cache_metadata *cmd,
700700
disk_super->policy_version[0] = cpu_to_le32(cmd->policy_version[0]);
701701
disk_super->policy_version[1] = cpu_to_le32(cmd->policy_version[1]);
702702
disk_super->policy_version[2] = cpu_to_le32(cmd->policy_version[2]);
703+
disk_super->policy_hint_size = cpu_to_le32(cmd->policy_hint_size);
703704

704705
disk_super->read_hits = cpu_to_le32(cmd->stats.read_hits);
705706
disk_super->read_misses = cpu_to_le32(cmd->stats.read_misses);

0 commit comments

Comments
 (0)