Purge cache command

Purge invalidates all cache lines. 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-08 11:12:31 -04:00
parent f7d854bf70
commit d24288a9b1
7 changed files with 129 additions and 1 deletions

View File

@@ -1915,6 +1915,29 @@ int core_pool_remove(const char *core_device)
return SUCCESS;
}
int purge_cache(unsigned int cache_id)
{
int fd = 0;
struct kcas_flush_cache cmd;
fd = open_ctrl_device();
if (fd == -1)
return FAILURE;
memset(&cmd, 0, sizeof(cmd));
cmd.cache_id = cache_id;
/* synchronous flag */
if (run_ioctl_interruptible(fd, KCAS_IOCTL_PURGE_CACHE, &cmd, "Purging cache",
cache_id, OCF_CORE_ID_INVALID) < 0) {
close(fd);
print_err(cmd.ext_err_code);
return FAILURE;
}
close(fd);
return SUCCESS;
}
#define DIRTY_FLUSHING_WARNING "You have interrupted flushing of cache dirty data. CAS continues to operate\nnormally and dirty data that remains on cache device will be flushed by cleaning thread.\n"
int flush_cache(unsigned int cache_id)
{

View File

@@ -220,6 +220,8 @@ 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 flush_cache(unsigned int cache_id);
int flush_core(unsigned int cache_id, unsigned int core_id);

View File

@@ -1419,6 +1419,7 @@ enum {
script_cmd_add_core,
script_cmd_remove_core,
script_cmd_purge_cache,
script_cmd_max_id,
@@ -1477,6 +1478,14 @@ static cli_option script_params_options[] = {
| (1 << script_opt_core_id),
.flags = CLI_COMMAND_HIDDEN,
},
[script_cmd_purge_cache] = {
.short_name = 0,
.long_name = "purge-cache",
.args_count = 0,
.arg = NULL,
.priv = (1 << script_opt_cache_id),
.flags = CLI_COMMAND_HIDDEN,
},
[script_opt_cache_device] = {
.short_name = 0,
.long_name = "cache-device",
@@ -1491,7 +1500,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_cache),
.flags = (CLI_OPTION_RANGE_INT | CLI_OPTION_HIDDEN),
.min_value = OCF_CACHE_ID_MIN,
.max_value = OCF_CACHE_ID_MAX,
@@ -1658,6 +1668,8 @@ int script_handle() {
command_args_values.detach,
command_args_values.no_flush
);
case script_cmd_purge_cache:
return purge_cache(command_args_values.cache_id);
}
return FAILURE;