Skip to content

Commit ec6ae63

Browse files
snitmgregkh
authored andcommitted
dm cache: fix resize crash if user doesn't reload cache table
commit 5d07384 upstream. A reload of the cache's DM table is needed during resize because otherwise a crash will occur when attempting to access smq policy entries associated with the portion of the cache that was recently extended. The reason is cache-size based data structures in the policy will not be resized, the only way to safely extend the cache is to allow for a proper cache policy initialization that occurs when the cache table is loaded. For example the smq policy's space_init(), init_allocator(), calc_hotspot_params() must be sized based on the extended cache size. The fix for this is to disallow cache resizes of this pattern: 1) suspend "cache" target's device 2) resize the fast device used for the cache 3) resume "cache" target's device Instead, the last step must be a full reload of the cache's DM table. Fixes: 66a6363 ("dm cache: add stochastic-multi-queue (smq) policy") Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f11a6ab commit ec6ae63

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/md/dm-cache-target.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,8 +3097,13 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
30973097

30983098
static bool can_resize(struct cache *cache, dm_cblock_t new_size)
30993099
{
3100-
if (from_cblock(new_size) > from_cblock(cache->cache_size))
3101-
return true;
3100+
if (from_cblock(new_size) > from_cblock(cache->cache_size)) {
3101+
if (cache->sized) {
3102+
DMERR("%s: unable to extend cache due to missing cache table reload",
3103+
cache_device_name(cache));
3104+
return false;
3105+
}
3106+
}
31023107

31033108
/*
31043109
* We can't drop a dirty block when shrinking the cache.

0 commit comments

Comments
 (0)