diff options
author | Joe Thornber <ejt@redhat.com> | 2017-02-09 11:46:18 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-02-16 12:57:10 -0500 |
commit | ca763d0a53b264a650342cee206512bc92ac7050 (patch) | |
tree | 7582bbeb5ea5e125756f3cbc1269501620cf4ba5 /drivers/md/dm-cache-target.c | |
parent | 105db5991240cb2675f193589130ef0c8a4f70fe (diff) |
dm cache: fix corruption seen when using cache > 2TB
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: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-cache-target.c')
-rw-r--r-- | drivers/md/dm-cache-target.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index e04c61e0839e..897dc72f07c9 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
@@ -248,7 +248,7 @@ struct cache { | |||
248 | /* | 248 | /* |
249 | * Fields for converting from sectors to blocks. | 249 | * Fields for converting from sectors to blocks. |
250 | */ | 250 | */ |
251 | uint32_t sectors_per_block; | 251 | sector_t sectors_per_block; |
252 | int sectors_per_block_shift; | 252 | int sectors_per_block_shift; |
253 | 253 | ||
254 | spinlock_t lock; | 254 | spinlock_t lock; |
@@ -3547,11 +3547,11 @@ static void cache_status(struct dm_target *ti, status_type_t type, | |||
3547 | 3547 | ||
3548 | residency = policy_residency(cache->policy); | 3548 | residency = policy_residency(cache->policy); |
3549 | 3549 | ||
3550 | DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %lu ", | 3550 | DMEMIT("%u %llu/%llu %llu %llu/%llu %u %u %u %u %u %u %lu ", |
3551 | (unsigned)DM_CACHE_METADATA_BLOCK_SIZE, | 3551 | (unsigned)DM_CACHE_METADATA_BLOCK_SIZE, |
3552 | (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata), | 3552 | (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata), |
3553 | (unsigned long long)nr_blocks_metadata, | 3553 | (unsigned long long)nr_blocks_metadata, |
3554 | cache->sectors_per_block, | 3554 | (unsigned long long)cache->sectors_per_block, |
3555 | (unsigned long long) from_cblock(residency), | 3555 | (unsigned long long) from_cblock(residency), |
3556 | (unsigned long long) from_cblock(cache->cache_size), | 3556 | (unsigned long long) from_cblock(cache->cache_size), |
3557 | (unsigned) atomic_read(&cache->stats.read_hit), | 3557 | (unsigned) atomic_read(&cache->stats.read_hit), |