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 @@ -2883,6 +2883,27 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
2883
2883
return to_cblock (size );
2884
2884
}
2885
2885
2886
+ static bool can_resume (struct cache * cache )
2887
+ {
2888
+ /*
2889
+ * Disallow retrying the resume operation for devices that failed the
2890
+ * first resume attempt, as the failure leaves the policy object partially
2891
+ * initialized. Retrying could trigger BUG_ON when loading cache mappings
2892
+ * into the incomplete policy object.
2893
+ */
2894
+ if (cache -> sized && !cache -> loaded_mappings ) {
2895
+ if (get_cache_mode (cache ) != CM_WRITE )
2896
+ DMERR ("%s: unable to resume a failed-loaded cache, please check metadata." ,
2897
+ cache_device_name (cache ));
2898
+ else
2899
+ DMERR ("%s: unable to resume cache due to missing proper cache table reload" ,
2900
+ cache_device_name (cache ));
2901
+ return false;
2902
+ }
2903
+
2904
+ return true;
2905
+ }
2906
+
2886
2907
static bool can_resize (struct cache * cache , dm_cblock_t new_size )
2887
2908
{
2888
2909
if (from_cblock (new_size ) > from_cblock (cache -> cache_size )) {
@@ -2931,6 +2952,9 @@ static int cache_preresume(struct dm_target *ti)
2931
2952
struct cache * cache = ti -> private ;
2932
2953
dm_cblock_t csize = get_cache_dev_size (cache );
2933
2954
2955
+ if (!can_resume (cache ))
2956
+ return - EINVAL ;
2957
+
2934
2958
/*
2935
2959
* Check to see if the cache has resized.
2936
2960
*/
You can’t perform that action at this time.
0 commit comments