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)
2996
2996
return to_cblock (size );
2997
2997
}
2998
2998
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
+
2999
3020
static bool can_resize (struct cache * cache , dm_cblock_t new_size )
3000
3021
{
3001
3022
if (from_cblock (new_size ) > from_cblock (cache -> cache_size )) {
@@ -3044,6 +3065,9 @@ static int cache_preresume(struct dm_target *ti)
3044
3065
struct cache * cache = ti -> private ;
3045
3066
dm_cblock_t csize = get_cache_dev_size (cache );
3046
3067
3068
+ if (!can_resume (cache ))
3069
+ return - EINVAL ;
3070
+
3047
3071
/*
3048
3072
* Check to see if the cache has resized.
3049
3073
*/
You can’t perform that action at this time.
0 commit comments