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 @@ -2903,6 +2903,27 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
2903
2903
return to_cblock (size );
2904
2904
}
2905
2905
2906
+ static bool can_resume (struct cache * cache )
2907
+ {
2908
+ /*
2909
+ * Disallow retrying the resume operation for devices that failed the
2910
+ * first resume attempt, as the failure leaves the policy object partially
2911
+ * initialized. Retrying could trigger BUG_ON when loading cache mappings
2912
+ * into the incomplete policy object.
2913
+ */
2914
+ if (cache -> sized && !cache -> loaded_mappings ) {
2915
+ if (get_cache_mode (cache ) != CM_WRITE )
2916
+ DMERR ("%s: unable to resume a failed-loaded cache, please check metadata." ,
2917
+ cache_device_name (cache ));
2918
+ else
2919
+ DMERR ("%s: unable to resume cache due to missing proper cache table reload" ,
2920
+ cache_device_name (cache ));
2921
+ return false;
2922
+ }
2923
+
2924
+ return true;
2925
+ }
2926
+
2906
2927
static bool can_resize (struct cache * cache , dm_cblock_t new_size )
2907
2928
{
2908
2929
if (from_cblock (new_size ) > from_cblock (cache -> cache_size )) {
@@ -2951,6 +2972,9 @@ static int cache_preresume(struct dm_target *ti)
2951
2972
struct cache * cache = ti -> private ;
2952
2973
dm_cblock_t csize = get_cache_dev_size (cache );
2953
2974
2975
+ if (!can_resume (cache ))
2976
+ return - EINVAL ;
2977
+
2954
2978
/*
2955
2979
* Check to see if the cache has resized.
2956
2980
*/
You can’t perform that action at this time.
0 commit comments