[fix] Enhance cache cleaning policy configuration
- Add set_param_cleaning_policy method for ACP and ALRU policies - Add validation for wake-up and flush-max-buffers parameters - Improve cache configuration to handle different cleaning policies - Fix casctl stop with flush option for proper shutdown
This commit is contained in:
parent
cbcb8bab74
commit
09764e0e15
@ -7,4 +7,4 @@
|
|||||||
# systemd-shutdown plugin to stop all remaining Open CAS devices
|
# systemd-shutdown plugin to stop all remaining Open CAS devices
|
||||||
|
|
||||||
/usr/bin/echo "Open CAS cleanup handler" > /dev/kmsg
|
/usr/bin/echo "Open CAS cleanup handler" > /dev/kmsg
|
||||||
/sbin/casctl stop
|
/sbin/casctl stop --flush
|
||||||
|
@ -139,7 +139,16 @@ class casadm:
|
|||||||
cmd += ['--'+param.replace('_', '-'), str(value)]
|
cmd += ['--'+param.replace('_', '-'), str(value)]
|
||||||
|
|
||||||
return cls.run_cmd(cmd)
|
return cls.run_cmd(cmd)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_param_cleaning_policy(cls, policy, cache_id, **kwargs):
|
||||||
|
cmd = [cls.casadm_path,
|
||||||
|
'--set-param', '--name', 'cleaning-'+policy,
|
||||||
|
'--cache-id', str(cache_id)]
|
||||||
|
for param, value in kwargs.items():
|
||||||
|
cmd += ['--'+param.replace('_', '-'), str(value)]
|
||||||
|
return cls.run_cmd(cmd)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_params(cls, namespace, cache_id, **kwargs):
|
def get_params(cls, namespace, cache_id, **kwargs):
|
||||||
cmd = [cls.casadm_path,
|
cmd = [cls.casadm_path,
|
||||||
@ -269,6 +278,10 @@ class cas_config(object):
|
|||||||
self.check_lazy_startup_valid(param_value)
|
self.check_lazy_startup_valid(param_value)
|
||||||
elif param_name == "target_failover_state":
|
elif param_name == "target_failover_state":
|
||||||
self.check_failover_state_valid(param_value)
|
self.check_failover_state_valid(param_value)
|
||||||
|
elif param_name == "wake-up":
|
||||||
|
self.check_wake_up_valid(param_value)
|
||||||
|
elif param_name == "flush-max-buffers":
|
||||||
|
self.check_flush_max_buffers_valid(param_value)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'{param_name} is invalid parameter name')
|
raise ValueError(f'{param_name} is invalid parameter name')
|
||||||
|
|
||||||
@ -315,6 +328,29 @@ class cas_config(object):
|
|||||||
if cache_line_size not in ['4', '8', '16', '32', '64']:
|
if cache_line_size not in ['4', '8', '16', '32', '64']:
|
||||||
raise ValueError(f'{cache_line_size} is invalid cache line size')
|
raise ValueError(f'{cache_line_size} is invalid cache line size')
|
||||||
|
|
||||||
|
def check_wake_up_valid(self, wake_up):
|
||||||
|
if self.params.get("cleaning_policy") == "acp":
|
||||||
|
if not wake_up.isdigit():
|
||||||
|
raise ValueError(f"{wake_up} is invalid wake-up value for acp cleaning policy")
|
||||||
|
if int(wake_up) not in range(0, 10000):
|
||||||
|
raise ValueError(f"{wake_up} is invalid wake-up value for acp cleaning policy")
|
||||||
|
elif self.params.get("cleaning_policy") == "alru":
|
||||||
|
if not wake_up.isdigit():
|
||||||
|
raise ValueError(f"{wake_up} is invalid wake-up value for alru cleaning policy")
|
||||||
|
if int(wake_up) not in range(0, 3600):
|
||||||
|
raise ValueError(f"{wake_up} is invalid wake-up value for alru cleaning policy")
|
||||||
|
|
||||||
|
def check_flush_max_buffers_valid(self, flush_max_buffers):
|
||||||
|
if self.params.get("cleaning_policy") == "acp":
|
||||||
|
if not flush_max_buffers.isdigit():
|
||||||
|
raise ValueError(f"{flush_max_buffers} is invalid flush-max-buffers value for acp cleaning policy")
|
||||||
|
if int(flush_max_buffers) not in range(1, 10000):
|
||||||
|
raise ValueError(f"{flush_max_buffers} is invalid flush-max-buffers value for acp cleaning policy")
|
||||||
|
elif self.params.get("cleaning_policy") == "alru":
|
||||||
|
if not flush_max_buffers.isdigit():
|
||||||
|
raise ValueError(f"{flush_max_buffers} is invalid flush-max-buffers value for alru cleaning policy")
|
||||||
|
if int(flush_max_buffers) not in range(1, 10000):
|
||||||
|
raise ValueError(f"{flush_max_buffers} is invalid flush-max-buffers value for alru cleaning policy")
|
||||||
def check_recursive(self):
|
def check_recursive(self):
|
||||||
if not self.device.startswith('/dev/cas'):
|
if not self.device.startswith('/dev/cas'):
|
||||||
return
|
return
|
||||||
@ -590,9 +626,16 @@ def start_cache(cache, load, force=False):
|
|||||||
|
|
||||||
def configure_cache(cache):
|
def configure_cache(cache):
|
||||||
if "cleaning_policy" in cache.params:
|
if "cleaning_policy" in cache.params:
|
||||||
casadm.set_param(
|
if cache.params["cleaning_policy"] == "acp" or cache.params["cleaning_policy"] == "alru":
|
||||||
"cleaning", cache_id=cache.cache_id, policy=cache.params["cleaning_policy"]
|
casadm.set_param_cleaning_policy(
|
||||||
)
|
policy=cache.params["cleaning_policy"], cache_id=cache.cache_id, wake_up=cache.params["wake_up"], flush_max_buffers=cache.params["flush_max_buffers"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
casadm.set_param(
|
||||||
|
"cleaning", cache_id=cache.cache_id, policy=cache.params["cleaning_policy"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if "promotion_policy" in cache.params:
|
if "promotion_policy" in cache.params:
|
||||||
casadm.set_param(
|
casadm.set_param(
|
||||||
"promotion", cache_id=cache.cache_id, policy=cache.params["promotion_policy"]
|
"promotion", cache_id=cache.cache_id, policy=cache.params["promotion_policy"]
|
||||||
|
Loading…
Reference in New Issue
Block a user