Merge pull request #34 from arutk/engine_wo

Extend CAS interface with Write-only cache mode
This commit is contained in:
Michal Rakowski
2019-06-14 12:41:43 +02:00
committed by GitHub
10 changed files with 124 additions and 24 deletions

View File

@@ -254,6 +254,7 @@ static struct name_to_val_mapping cache_mode_names[] = {
#ifdef WI_AVAILABLE
{ .short_name = "wi", .long_name = "Write-Invalidate", .value = ocf_cache_mode_wi },
#endif
{ .short_name = "wo", .long_name = "Write-Only", .value = ocf_cache_mode_wo },
{ NULL }
};
@@ -1062,6 +1063,7 @@ int set_cache_mode(unsigned int cache_mode, unsigned int cache_id, int flush)
int fd = 0;
int orig_mode;
struct kcas_set_cache_state cmd;
bool flush_param_required;
fd = open_ctrl_device();
if (fd == -1)
@@ -1073,9 +1075,13 @@ int set_cache_mode(unsigned int cache_mode, unsigned int cache_id, int flush)
return FAILURE;
}
/* if flushing mode is undefined, set it to default (but only if original mode is write back mode) */
/* If flushing mode is undefined, set it to default unless we're transitioning
* out of lazy write cache mode (like WB or WO), in which case user must explicitly
* state his preference */
flush_param_required = ocf_mngt_cache_mode_has_lazy_write(orig_mode) &&
!ocf_mngt_cache_mode_has_lazy_write(cache_mode);
if (-1 == flush) {
if (ocf_cache_mode_wb == orig_mode) {
if (flush_param_required) {
cas_printf(LOG_ERR, "Error: Required parameter (--flush-cache) was not specified.\n");
close(fd);
return FAILURE;
@@ -1084,14 +1090,15 @@ int set_cache_mode(unsigned int cache_mode, unsigned int cache_id, int flush)
}
}
if (ocf_cache_mode_wb == orig_mode) {
if (flush_param_required) {
if (1 == flush) {
cas_printf(LOG_INFO, "CAS is currently flushing dirty data to primary storage devices.\n");
} else {
cas_printf(LOG_INFO, "CAS is currently migrating from Write-Back to %s mode.\n"
cas_printf(LOG_INFO, "CAS is currently migrating from %s to %s mode.\n"
"Dirty data are being flushed to primary storage device in background.\n"
"Please find flushing progress via list caches command (casadm -L) or\n"
"via statistics command (casadm -P).\n",
cache_mode_to_name_long(orig_mode),
cache_mode_to_name_long(cache_mode));
}
}

View File

@@ -125,15 +125,15 @@ int start_cache(ocf_cache_id_t cache_id, unsigned int cache_init,
int stop_cache(ocf_cache_id_t cache_id, int flush);
#ifdef WI_AVAILABLE
#define CAS_CLI_HELP_START_CACHE_MODES "wt|wb|wa|pt|wi"
#define CAS_CLI_HELP_SET_CACHE_MODES "wt|wb|wa|pt|wi"
#define CAS_CLI_HELP_SET_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Invalidate"
#define CAS_CLI_HELP_START_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Invalidate"
#define CAS_CLI_HELP_START_CACHE_MODES "wt|wb|wa|pt|wi|wo"
#define CAS_CLI_HELP_SET_CACHE_MODES "wt|wb|wa|pt|wi|wo"
#define CAS_CLI_HELP_SET_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Invalidate, Write-Only"
#define CAS_CLI_HELP_START_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Invalidate, Write-Only"
#else
#define CAS_CLI_HELP_START_CACHE_MODES "wt|wb|wa|pt"
#define CAS_CLI_HELP_SET_CACHE_MODES "wt|wb|wa|pt"
#define CAS_CLI_HELP_START_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through"
#define CAS_CLI_HELP_SET_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through"
#define CAS_CLI_HELP_START_CACHE_MODES "wt|wb|wa|pt|wo"
#define CAS_CLI_HELP_SET_CACHE_MODES "wt|wb|wa|pt|wo"
#define CAS_CLI_HELP_START_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Only"
#define CAS_CLI_HELP_SET_CACHE_MODES_FULL "Write-Through, Write-Back, Write-Around, Pass-Through, Write-Only"
#endif
/**

View File

@@ -900,7 +900,7 @@ int handle_get_param()
static cli_option set_state_cache_mode_options[] = {
{'c', "cache-mode", "Cache mode. Available cache modes: {"CAS_CLI_HELP_SET_CACHE_MODES"}", 1, "NAME", CLI_OPTION_REQUIRED},
{'i', "cache-id", CACHE_ID_DESC, 1, "ID", CLI_OPTION_REQUIRED},
{'f', "flush-cache", "Flush all dirty data from cache before switching to new mode. Option is required when switching from Write-Back mode", 1, "yes|no",0},
{'f', "flush-cache", "Flush all dirty data from cache before switching to new mode. Option is required when switching from Write-Back or Write-Only mode", 1, "yes|no",0},
{0},
};

View File

@@ -911,9 +911,8 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info,
return FAILURE;
print_kv_pair(outfile, "Inactive Core Devices", "%d", inactive_cores);
print_kv_pair(outfile, "Write Policy", "%s%s",
(flush_progress && cache_info->info.cache_mode != ocf_cache_mode_wb)
? "wb->" : "", cache_mode_to_name(cache_info->info.cache_mode));
print_kv_pair(outfile, "Write Policy", "%s",
cache_mode_to_name(cache_info->info.cache_mode));
print_kv_pair(outfile, "Eviction Policy", "%s",
eviction_policy_to_name(cache_info->info.eviction_policy));
print_kv_pair(outfile, "Cleaning Policy", "%s",