aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2014-11-26 11:07:50 -0500
committerMike Snitzer <snitzer@redhat.com>2014-12-01 11:30:11 -0500
commit2bb812df63bbd246bd39d10f2e810b2a0a59e99e (patch)
tree071abce53825307314e1531fb81a3b58619600af /drivers/md
parent43c32bf2b0c16d292f4f214dfd16f9cb205e4e81 (diff)
dm cache: discard block size must be a multiple of cache block size
Otherwise the cache blocks may span two discard blocks, which we don't handle when doing the discard lookup. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-cache-target.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 161bbd6652f8..fd7f61387283 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2275,9 +2275,8 @@ static int create_cache_policy(struct cache *cache, struct cache_args *ca,
2275} 2275}
2276 2276
2277/* 2277/*
2278 * We want the discard block size to be a power of two, at least the size 2278 * We want the discard block size to be at least the size of the cache
2279 * of the cache block size, and have no more than 2^14 discard blocks 2279 * block size and have no more than 2^14 discard blocks across the origin.
2280 * across the origin.
2281 */ 2280 */
2282#define MAX_DISCARD_BLOCKS (1 << 14) 2281#define MAX_DISCARD_BLOCKS (1 << 14)
2283 2282
@@ -2292,9 +2291,7 @@ static bool too_many_discard_blocks(sector_t discard_block_size,
2292static sector_t calculate_discard_block_size(sector_t cache_block_size, 2291static sector_t calculate_discard_block_size(sector_t cache_block_size,
2293 sector_t origin_size) 2292 sector_t origin_size)
2294{ 2293{
2295 sector_t discard_block_size; 2294 sector_t discard_block_size = cache_block_size;
2296
2297 discard_block_size = roundup_pow_of_two(cache_block_size);
2298 2295
2299 if (origin_size) 2296 if (origin_size)
2300 while (too_many_discard_blocks(discard_block_size, origin_size)) 2297 while (too_many_discard_blocks(discard_block_size, origin_size))