Commit 85050844 authored by Joe Thornber's avatar Joe Thornber Committed by Sasha Levin

dm cache: fix corruption seen when using cache > 2TB

[ Upstream commit ca763d0a ]

A rounding bug due to compiler generated temporary being 32bit was found
in remap_to_cache().  A localized cast in remap_to_cache() fixes the
corruption but this preferred fix (changing from uint32_t to sector_t)
eliminates potential for future rounding errors elsewhere.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent c0601ca1
...@@ -210,7 +210,7 @@ struct cache { ...@@ -210,7 +210,7 @@ struct cache {
/* /*
* Fields for converting from sectors to blocks. * Fields for converting from sectors to blocks.
*/ */
uint32_t sectors_per_block; sector_t sectors_per_block;
int sectors_per_block_shift; int sectors_per_block_shift;
spinlock_t lock; spinlock_t lock;
...@@ -3092,11 +3092,11 @@ static void cache_status(struct dm_target *ti, status_type_t type, ...@@ -3092,11 +3092,11 @@ static void cache_status(struct dm_target *ti, status_type_t type,
residency = policy_residency(cache->policy); residency = policy_residency(cache->policy);
DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %lu ", DMEMIT("%u %llu/%llu %llu %llu/%llu %u %u %u %u %u %u %lu ",
(unsigned)DM_CACHE_METADATA_BLOCK_SIZE, (unsigned)DM_CACHE_METADATA_BLOCK_SIZE,
(unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata), (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata),
(unsigned long long)nr_blocks_metadata, (unsigned long long)nr_blocks_metadata,
cache->sectors_per_block, (unsigned long long)cache->sectors_per_block,
(unsigned long long) from_cblock(residency), (unsigned long long) from_cblock(residency),
(unsigned long long) from_cblock(cache->cache_size), (unsigned long long) from_cblock(cache->cache_size),
(unsigned) atomic_read(&cache->stats.read_hit), (unsigned) atomic_read(&cache->stats.read_hit),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment