Skip to content

Commit

Permalink
dm cache: fix corruption seen when using cache > 2TB
Browse files Browse the repository at this point in the history
commit ca763d0 upstream.

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.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jthornber authored and gregkh committed Mar 12, 2017
1 parent fe8f92c commit 9987feb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ struct cache {
/*
* Fields for converting from sectors to blocks.
*/
uint32_t sectors_per_block;
sector_t sectors_per_block;
int sectors_per_block_shift;

spinlock_t lock;
Expand Down Expand Up @@ -3546,11 +3546,11 @@ static void cache_status(struct dm_target *ti, status_type_t type,

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 long long)(nr_blocks_metadata - nr_free_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(cache->cache_size),
(unsigned) atomic_read(&cache->stats.read_hit),
Expand Down

0 comments on commit 9987feb

Please sign in to comment.