From 46775aa8844abb286889715b2c703b99936fa345 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 26 Sep 2024 16:14:42 +0200 Subject: [PATCH 1/3] casadm: Exit status 0 for blocked commands Signed-off-by: Michal Mielewczyk --- casadm/argp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/casadm/argp.c b/casadm/argp.c index 1ad53f2..c27555b 100644 --- a/casadm/argp.c +++ b/casadm/argp.c @@ -623,8 +623,8 @@ int args_parse(app *app_values, cli_command *commands, int argc, const char **ar } if (is_command_blocked(commands, i)) { - cas_printf(LOG_ERR, "The command is not supported\n"); - return FAILURE; + cas_printf(LOG_INFO, "The command is not supported\n"); + return SUCCESS; } configure_cli_commands(commands); From cefa6ab121f2909775bbd9bd6ad0484eb1c34973 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 26 Sep 2024 16:27:27 +0200 Subject: [PATCH 2/3] Add missing volume_destroy() in attach Signed-off-by: Michal Mielewczyk --- modules/cas_cache/layer_cache_management.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 8c206c1..7c11d3a 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -2538,20 +2538,27 @@ int cache_mngt_attach_device(const char *cache_name, size_t name_len, result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, OCF_CACHE_NAME_SIZE, &cache); - if (result) + if (result) { + ocf_volume_destroy(attach_cfg->device.volume); goto err_get; + } result = _cache_mngt_lock_sync(cache); - if (result) + if (result) { + ocf_volume_destroy(attach_cfg->device.volume); goto err_lock; + } result = cache_mngt_check_bdev(&attach_cfg->device, attach_cfg->force, true, cache); - if (result) + if (result) { + ocf_volume_destroy(attach_cfg->device.volume); goto err_ctx; + } context = kzalloc(sizeof(*context), GFP_KERNEL); if (!context) { + ocf_volume_destroy(attach_cfg->device.volume); result = -ENOMEM; goto err_ctx; } From f34328adf2a16a6aa7c6a1b95ec84e6e944525f2 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 26 Sep 2024 16:34:07 +0200 Subject: [PATCH 3/3] Disable cache attach and detach The feature is disable due to a possible data corruption which may occur when attaching a new caching device. Once the problem is resolved this commit should be reverted Signed-off-by: Michal Mielewczyk --- casadm/cas_main.c | 4 ++-- modules/cas_cache/service_ui_ioctl.c | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/casadm/cas_main.c b/casadm/cas_main.c index f41fb5a..1e361bd 100644 --- a/casadm/cas_main.c +++ b/casadm/cas_main.c @@ -2237,7 +2237,7 @@ static cli_command cas_commands[] = { .options = attach_cache_options, .command_handle_opts = start_cache_command_handle_option, .handle = handle_cache_attach, - .flags = CLI_SU_REQUIRED, + .flags = (CLI_SU_REQUIRED | CLI_COMMAND_BLOCKED), .help = NULL, }, { @@ -2247,7 +2247,7 @@ static cli_command cas_commands[] = { .options = detach_options, .command_handle_opts = command_handle_option, .handle = handle_cache_detach, - .flags = CLI_SU_REQUIRED, + .flags = (CLI_SU_REQUIRED | CLI_COMMAND_BLOCKED), .help = NULL, }, { diff --git a/modules/cas_cache/service_ui_ioctl.c b/modules/cas_cache/service_ui_ioctl.c index 6f22d5f..567decc 100644 --- a/modules/cas_cache/service_ui_ioctl.c +++ b/modules/cas_cache/service_ui_ioctl.c @@ -86,6 +86,10 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd, GET_CMD_INFO(cmd_info, arg); + printk(KERN_ERR "Cache attach is not supported!\n"); + retval = -ENOTSUP; + RETURN_CMD_RESULT(cmd_info, arg, retval); + cache_name_from_id(cache_name, cmd_info->cache_id); retval = cache_mngt_attach_cache_cfg(cache_name, OCF_CACHE_NAME_SIZE, @@ -104,6 +108,9 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd, char cache_name[OCF_CACHE_NAME_SIZE]; GET_CMD_INFO(cmd_info, arg); + printk(KERN_ERR "Cache detach is not supported!\n"); + retval = -ENOTSUP; + RETURN_CMD_RESULT(cmd_info, arg, retval); cache_name_from_id(cache_name, cmd_info->cache_id);