Purge core command

Purge invalidates all cache lines which belongs to given core. It is very
usefull feature for tests.

Calling purge is possbile with casadm `--script` swtich.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk
2020-05-11 04:49:03 -04:00
parent d24288a9b1
commit 3b62e40a2e
7 changed files with 149 additions and 2 deletions

View File

@@ -1967,6 +1967,29 @@ int flush_cache(unsigned int cache_id)
return SUCCESS;
}
int purge_core(unsigned int cache_id, unsigned int core_id)
{
int fd = 0;
struct kcas_flush_core cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.cache_id = cache_id;
cmd.core_id = core_id;
fd = open_ctrl_device();
if (fd == -1)
return FAILURE;
/* synchronous flag */
if (run_ioctl_interruptible(fd, KCAS_IOCTL_PURGE_CORE, &cmd, "Purging core", cache_id, core_id) < 0) {
close(fd);
print_err(cmd.ext_err_code);
return FAILURE;
}
close(fd);
return SUCCESS;
}
int flush_core(unsigned int cache_id, unsigned int core_id)
{
int fd = 0;

View File

@@ -221,6 +221,7 @@ int get_core_pool_count(int fd);
int reset_counters(unsigned int cache_id, unsigned int core_id);
int purge_cache(unsigned int cache_id);
int purge_core(unsigned int cache_id, unsigned int core_id);
int flush_cache(unsigned int cache_id);
int flush_core(unsigned int cache_id, unsigned int core_id);

View File

@@ -1420,6 +1420,7 @@ enum {
script_cmd_add_core,
script_cmd_remove_core,
script_cmd_purge_cache,
script_cmd_purge_core,
script_cmd_max_id,
@@ -1486,6 +1487,15 @@ static cli_option script_params_options[] = {
.priv = (1 << script_opt_cache_id),
.flags = CLI_COMMAND_HIDDEN,
},
[script_cmd_purge_core] = {
.short_name = 0,
.long_name = "purge-core",
.args_count = 0,
.arg = NULL,
.priv = (1 << script_opt_cache_id)
| (1 << script_opt_core_id),
.flags = CLI_COMMAND_HIDDEN,
},
[script_opt_cache_device] = {
.short_name = 0,
.long_name = "cache-device",
@@ -1501,7 +1511,8 @@ static cli_option script_params_options[] = {
.arg = "ID",
.priv = (1 << script_cmd_remove_core)
| (1 << script_cmd_add_core)
| (1 << script_cmd_purge_cache),
| (1 << script_cmd_purge_cache)
| (1 << script_cmd_purge_core),
.flags = (CLI_OPTION_RANGE_INT | CLI_OPTION_HIDDEN),
.min_value = OCF_CACHE_ID_MIN,
.max_value = OCF_CACHE_ID_MAX,
@@ -1512,7 +1523,8 @@ static cli_option script_params_options[] = {
.args_count = 1,
.arg = "ID",
.priv = (1 << script_cmd_remove_core)
| (1 << script_cmd_add_core),
| (1 << script_cmd_add_core)
| (1 << script_cmd_purge_core),
.flags = (CLI_OPTION_RANGE_INT | CLI_OPTION_HIDDEN),
.min_value = OCF_CORE_ID_MIN,
.max_value = OCF_CORE_ID_MAX,
@@ -1670,6 +1682,11 @@ int script_handle() {
);
case script_cmd_purge_cache:
return purge_cache(command_args_values.cache_id);
case script_cmd_purge_core:
return purge_core(
command_args_values.cache_id,
command_args_values.core_id
);
}
return FAILURE;