File tree 1 file changed +24
-0
lines changed 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2899,6 +2899,27 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
2899
2899
return to_cblock (size );
2900
2900
}
2901
2901
2902
+ static bool can_resume (struct cache * cache )
2903
+ {
2904
+ /*
2905
+ * Disallow retrying the resume operation for devices that failed the
2906
+ * first resume attempt, as the failure leaves the policy object partially
2907
+ * initialized. Retrying could trigger BUG_ON when loading cache mappings
2908
+ * into the incomplete policy object.
2909
+ */
2910
+ if (cache -> sized && !cache -> loaded_mappings ) {
2911
+ if (get_cache_mode (cache ) != CM_WRITE )
2912
+ DMERR ("%s: unable to resume a failed-loaded cache, please check metadata." ,
2913
+ cache_device_name (cache ));
2914
+ else
2915
+ DMERR ("%s: unable to resume cache due to missing proper cache table reload" ,
2916
+ cache_device_name (cache ));
2917
+ return false;
2918
+ }
2919
+
2920
+ return true;
2921
+ }
2922
+
2902
2923
static bool can_resize (struct cache * cache , dm_cblock_t new_size )
2903
2924
{
2904
2925
if (from_cblock (new_size ) > from_cblock (cache -> cache_size )) {
@@ -2947,6 +2968,9 @@ static int cache_preresume(struct dm_target *ti)
2947
2968
struct cache * cache = ti -> private ;
2948
2969
dm_cblock_t csize = get_cache_dev_size (cache );
2949
2970
2971
+ if (!can_resume (cache ))
2972
+ return - EINVAL ;
2973
+
2950
2974
/*
2951
2975
* Check to see if the cache has resized.
2952
2976
*/
You can’t perform that action at this time.
0 commit comments