]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/md/dm-cache-target.c
dm cache: fix resize crash if user doesn't reload cache table
[mirror_ubuntu-bionic-kernel.git] / drivers / md / dm-cache-target.c
index 044547583eecc124d0585f55a47dc9c5a2b9dab9..360a96da4e4d0d41231aa63661586ab50852540f 100644 (file)
@@ -3015,8 +3015,13 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
 
 static bool can_resize(struct cache *cache, dm_cblock_t new_size)
 {
-       if (from_cblock(new_size) > from_cblock(cache->cache_size))
-               return true;
+       if (from_cblock(new_size) > from_cblock(cache->cache_size)) {
+               if (cache->sized) {
+                       DMERR("%s: unable to extend cache due to missing cache table reload",
+                             cache_device_name(cache));
+                       return false;
+               }
+       }
 
        /*
         * We can't drop a dirty block when shrinking the cache.