File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2996,6 +2996,27 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
29962996 return to_cblock (size );
29972997}
29982998
2999+ static bool can_resume (struct cache * cache )
3000+ {
3001+ /*
3002+ * Disallow retrying the resume operation for devices that failed the
3003+ * first resume attempt, as the failure leaves the policy object partially
3004+ * initialized. Retrying could trigger BUG_ON when loading cache mappings
3005+ * into the incomplete policy object.
3006+ */
3007+ if (cache -> sized && !cache -> loaded_mappings ) {
3008+ if (get_cache_mode (cache ) != CM_WRITE )
3009+ DMERR ("%s: unable to resume a failed-loaded cache, please check metadata." ,
3010+ cache_device_name (cache ));
3011+ else
3012+ DMERR ("%s: unable to resume cache due to missing proper cache table reload" ,
3013+ cache_device_name (cache ));
3014+ return false;
3015+ }
3016+
3017+ return true;
3018+ }
3019+
29993020static bool can_resize (struct cache * cache , dm_cblock_t new_size )
30003021{
30013022 if (from_cblock (new_size ) > from_cblock (cache -> cache_size )) {
@@ -3044,6 +3065,9 @@ static int cache_preresume(struct dm_target *ti)
30443065 struct cache * cache = ti -> private ;
30453066 dm_cblock_t csize = get_cache_dev_size (cache );
30463067
3068+ if (!can_resume (cache ))
3069+ return - EINVAL ;
3070+
30473071 /*
30483072 * Check to see if the cache has resized.
30493073 */
You can’t perform that action at this time.
0 commit comments