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 @@ -2899,6 +2899,27 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
28992899	return  to_cblock (size );
29002900}
29012901
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+ 
29022923static  bool  can_resize (struct  cache  * cache , dm_cblock_t  new_size )
29032924{
29042925	if  (from_cblock (new_size ) >  from_cblock (cache -> cache_size )) {
@@ -2947,6 +2968,9 @@ static int cache_preresume(struct dm_target *ti)
29472968	struct  cache  * cache  =  ti -> private ;
29482969	dm_cblock_t  csize  =  get_cache_dev_size (cache );
29492970
2971+ 	if  (!can_resume (cache ))
2972+ 		return  - EINVAL ;
2973+ 
29502974	/* 
29512975	 * Check to see if the cache has resized. 
29522976	 */ 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments