Redesign failover standby management
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -1891,7 +1891,8 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
|
||||
case CACHE_INIT_LOAD:
|
||||
attach_cfg->open_cores = true;
|
||||
case CACHE_INIT_NEW:
|
||||
case CACHE_INIT_STANDBY:
|
||||
case CACHE_INIT_STANDBY_NEW:
|
||||
case CACHE_INIT_STANDBY_LOAD:
|
||||
break;
|
||||
default:
|
||||
return -OCF_ERR_INVAL;
|
||||
@@ -2111,7 +2112,8 @@ static int _cache_start_finalize(ocf_cache_t cache, int init_mode,
|
||||
|
||||
_cache_mngt_log_cache_device_path(cache, ctx->device_cfg);
|
||||
|
||||
if (activate || init_mode != CACHE_INIT_STANDBY) {
|
||||
if (activate || (init_mode != CACHE_INIT_STANDBY_NEW &&
|
||||
init_mode != CACHE_INIT_STANDBY_LOAD)) {
|
||||
result = cas_cls_init(cache);
|
||||
if (result) {
|
||||
ctx->ocf_start_error = result;
|
||||
@@ -2137,7 +2139,8 @@ static int _cache_start_finalize(ocf_cache_t cache, int init_mode,
|
||||
ocf_core_visit(cache, _cache_mngt_core_device_loaded_visitor,
|
||||
NULL, false);
|
||||
break;
|
||||
case CACHE_INIT_STANDBY:
|
||||
case CACHE_INIT_STANDBY_NEW:
|
||||
case CACHE_INIT_STANDBY_LOAD:
|
||||
result = cache_mngt_initialize_cache_exported_object(cache);
|
||||
if (result) {
|
||||
ctx->ocf_start_error = result;
|
||||
@@ -2181,7 +2184,7 @@ int cache_mngt_check_bdev(struct ocf_mngt_cache_device_config *device_cfg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cache_mngt_failover_detach(struct kcas_failover_detach *cmd)
|
||||
int cache_mngt_standby_detach(struct kcas_standby_detach *cmd)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
struct cache_priv *cache_priv;
|
||||
@@ -2222,7 +2225,7 @@ int cache_mngt_failover_detach(struct kcas_failover_detach *cmd)
|
||||
if (result)
|
||||
goto out_cache_put;
|
||||
|
||||
ocf_mngt_cache_failover_detach(cache, _cache_mngt_generic_complete,
|
||||
ocf_mngt_cache_standby_detach(cache, _cache_mngt_generic_complete,
|
||||
&context);
|
||||
|
||||
wait_for_completion(&context.cmpl);
|
||||
@@ -2235,8 +2238,29 @@ out_module_put:
|
||||
return result;
|
||||
}
|
||||
|
||||
int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
struct kcas_failover_activate *cmd)
|
||||
int cache_mngt_prepare_cache_standby_activate_cfg(
|
||||
struct ocf_mngt_cache_standby_activate_config *cfg,
|
||||
struct kcas_standby_activate *cmd)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (cmd->cache_id == OCF_CACHE_ID_INVALID)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
|
||||
result = cache_mngt_prepare_cache_device_cfg(&cfg->device,
|
||||
cmd->cache_path);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
cfg->open_cores = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cache_mngt_activate(struct ocf_mngt_cache_standby_activate_config *cfg,
|
||||
struct kcas_standby_activate *cmd)
|
||||
{
|
||||
struct _cache_mngt_attach_context *context;
|
||||
ocf_cache_t cache;
|
||||
@@ -2263,7 +2287,7 @@ int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
if (result)
|
||||
goto out_cache_put;
|
||||
|
||||
result = cache_mngt_check_bdev(cfg, false);
|
||||
result = cache_mngt_check_bdev(&cfg->device, false);
|
||||
if (result)
|
||||
goto out_cache_unlock;
|
||||
|
||||
@@ -2276,7 +2300,7 @@ int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
/* TODO: doesn't this need to be copied to avoid use-after-free
|
||||
* in case where calle is interrupted and returns???
|
||||
*/
|
||||
context->device_cfg = cfg;
|
||||
context->device_cfg = &cfg->device;
|
||||
context->cache = cache;
|
||||
|
||||
cache_priv = ocf_cache_get_priv(cache);
|
||||
@@ -2290,7 +2314,7 @@ int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
}
|
||||
_cache_mngt_async_context_init(&context->async);
|
||||
|
||||
ocf_mngt_cache_activate(cache, cfg, _cache_mngt_start_complete,
|
||||
ocf_mngt_cache_standby_activate(cache, cfg, _cache_mngt_start_complete,
|
||||
context);
|
||||
result = wait_for_completion_interruptible(&context->async.cmpl);
|
||||
|
||||
@@ -2336,11 +2360,16 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
|
||||
return result;
|
||||
}
|
||||
|
||||
if (cmd->init_cache == CACHE_INIT_LOAD)
|
||||
switch (cmd->init_cache) {
|
||||
case CACHE_INIT_LOAD:
|
||||
case CACHE_INIT_STANDBY_LOAD:
|
||||
result = _cache_mngt_check_metadata(cfg, cmd->cache_path_name);
|
||||
if (result) {
|
||||
module_put(THIS_MODULE);
|
||||
return result;
|
||||
if (result) {
|
||||
module_put(THIS_MODULE);
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
context = kzalloc(sizeof(*context), GFP_KERNEL);
|
||||
@@ -2394,8 +2423,12 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
|
||||
ocf_mngt_cache_load(cache, attach_cfg,
|
||||
_cache_mngt_start_complete, context);
|
||||
break;
|
||||
case CACHE_INIT_STANDBY:
|
||||
ocf_mngt_cache_standby(cache, attach_cfg,
|
||||
case CACHE_INIT_STANDBY_NEW:
|
||||
ocf_mngt_cache_standby_attach(cache, attach_cfg,
|
||||
_cache_mngt_start_complete, context);
|
||||
break;
|
||||
case CACHE_INIT_STANDBY_LOAD:
|
||||
ocf_mngt_cache_standby_load(cache, attach_cfg,
|
||||
_cache_mngt_start_complete, context);
|
||||
break;
|
||||
default:
|
||||
@@ -2932,7 +2965,7 @@ int cache_mngt_get_info(struct kcas_cache_info *info)
|
||||
if (result)
|
||||
goto unlock;
|
||||
|
||||
if (info->info.attached && !info->info.failover_detached) {
|
||||
if (info->info.attached && !info->info.standby_detached) {
|
||||
uuid = ocf_cache_get_uuid(cache);
|
||||
BUG_ON(!uuid);
|
||||
strlcpy(info->cache_path_name, uuid->data,
|
||||
|
||||
@@ -65,9 +65,6 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
|
||||
struct ocf_mngt_cache_attach_config *attach_cfg,
|
||||
struct kcas_start_cache *cmd);
|
||||
|
||||
int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
struct kcas_failover_activate *cmd);
|
||||
|
||||
int cache_mngt_set_seq_cutoff_threshold(ocf_cache_t cache, ocf_core_t core,
|
||||
uint32_t thresh);
|
||||
|
||||
@@ -114,9 +111,13 @@ int cache_mngt_set_cache_params(struct kcas_set_cache_param *info);
|
||||
|
||||
int cache_mngt_get_cache_params(struct kcas_get_cache_param *info);
|
||||
|
||||
int cache_mngt_failover_detach(struct kcas_failover_detach *cmd);
|
||||
int cache_mngt_standby_detach(struct kcas_standby_detach *cmd);
|
||||
|
||||
int cache_mngt_activate(struct ocf_mngt_cache_device_config *cfg,
|
||||
struct kcas_failover_activate *cmd);
|
||||
int cache_mngt_prepare_cache_standby_activate_cfg(
|
||||
struct ocf_mngt_cache_standby_activate_config *cfg,
|
||||
struct kcas_standby_activate *cmd);
|
||||
|
||||
int cache_mngt_activate(struct ocf_mngt_cache_standby_activate_config *cfg,
|
||||
struct kcas_standby_activate *cmd);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -378,23 +378,23 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
|
||||
|
||||
RETURN_CMD_RESULT(cmd_info, arg, retval);
|
||||
}
|
||||
case KCAS_IOCTL_FAILOVER_DETACH: {
|
||||
struct kcas_failover_detach *cmd_info;
|
||||
case KCAS_IOCTL_STANDBY_DETACH: {
|
||||
struct kcas_standby_detach *cmd_info;
|
||||
|
||||
GET_CMD_INFO(cmd_info, arg);
|
||||
|
||||
retval = cache_mngt_failover_detach(cmd_info);
|
||||
retval = cache_mngt_standby_detach(cmd_info);
|
||||
|
||||
RETURN_CMD_RESULT(cmd_info, arg, retval);
|
||||
}
|
||||
case KCAS_IOCTL_FAILOVER_ACTIVATE: {
|
||||
struct kcas_failover_activate *cmd_info;
|
||||
struct ocf_mngt_cache_device_config cfg;
|
||||
case KCAS_IOCTL_STANDBY_ACTIVATE: {
|
||||
struct kcas_standby_activate *cmd_info;
|
||||
struct ocf_mngt_cache_standby_activate_config cfg;
|
||||
|
||||
GET_CMD_INFO(cmd_info, arg);
|
||||
|
||||
retval = cache_mngt_prepare_cache_device_cfg(&cfg,
|
||||
cmd_info->cache_path);
|
||||
retval = cache_mngt_prepare_cache_standby_activate_cfg(&cfg,
|
||||
cmd_info);
|
||||
if (retval)
|
||||
RETURN_CMD_RESULT(cmd_info, arg, retval);
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
|
||||
#define CACHE_INIT_NEW 0 /**< initialize new metadata from fresh start */
|
||||
#define CACHE_INIT_LOAD 1 /**< load existing metadata */
|
||||
#define CACHE_INIT_STANDBY 2 /**< initialize failover standby cache */
|
||||
#define CACHE_INIT_STANDBY_NEW 2 /**< initialize failover standby cache */
|
||||
#define CACHE_INIT_STANDBY_LOAD 3 /**< load failover standby cache */
|
||||
|
||||
struct kcas_start_cache {
|
||||
/**
|
||||
@@ -352,14 +353,14 @@ struct kcas_get_cache_param {
|
||||
int ext_err_code;
|
||||
};
|
||||
|
||||
struct kcas_failover_detach
|
||||
struct kcas_standby_detach
|
||||
{
|
||||
uint16_t cache_id;
|
||||
|
||||
int ext_err_code;
|
||||
};
|
||||
|
||||
struct kcas_failover_activate
|
||||
struct kcas_standby_activate
|
||||
{
|
||||
uint16_t cache_id;
|
||||
char cache_path[MAX_STR_LEN]; /**< path to an ssd*/
|
||||
@@ -498,10 +499,10 @@ struct kcas_failover_activate
|
||||
#define KCAS_IOCTL_REMOVE_INACTIVE _IOWR(KCAS_IOCTL_MAGIC, 37, struct kcas_remove_inactive)
|
||||
|
||||
/** Detach caching drive from failover standby cache instance */
|
||||
#define KCAS_IOCTL_FAILOVER_DETACH _IOWR(KCAS_IOCTL_MAGIC, 38, struct kcas_failover_detach)
|
||||
#define KCAS_IOCTL_STANDBY_DETACH _IOWR(KCAS_IOCTL_MAGIC, 38, struct kcas_standby_detach)
|
||||
|
||||
/** Activate standby failover cache instance */
|
||||
#define KCAS_IOCTL_FAILOVER_ACTIVATE _IOWR(KCAS_IOCTL_MAGIC, 39, struct kcas_failover_activate)
|
||||
/** Activate failover standby cache instance */
|
||||
#define KCAS_IOCTL_STANDBY_ACTIVATE _IOWR(KCAS_IOCTL_MAGIC, 39, struct kcas_standby_activate)
|
||||
|
||||
/**
|
||||
* Extended kernel CAS error codes
|
||||
|
||||
Reference in New Issue
Block a user