Merge pull request #1503 from mmichal10/block-standy

Block standby
This commit is contained in:
Robert Baldyga 2024-09-09 11:16:42 +02:00 committed by GitHub
commit f0727cce62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 72 additions and 28 deletions

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2021 Intel Corporation * Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -26,6 +27,11 @@ static int is_command_hidden(const cli_command* commands, int cmd)
return commands[cmd].flags & CLI_COMMAND_HIDDEN; return commands[cmd].flags & CLI_COMMAND_HIDDEN;
} }
static int is_command_blocked(const cli_command* commands, int cmd)
{
return commands[cmd].flags & CLI_COMMAND_BLOCKED;
}
static void print_short_usage(const app *app_values) static void print_short_usage(const app *app_values)
{ {
cas_printf(LOG_INFO, "Usage: %s %s\n", app_values->name, app_values->info); cas_printf(LOG_INFO, "Usage: %s %s\n", app_values->name, app_values->info);
@ -313,8 +319,10 @@ void print_help(const app *app_values, const cli_command *commands)
break; break;
} }
if (is_command_hidden(commands, i)) if (is_command_hidden(commands, i) ||
is_command_blocked(commands, i)) {
continue; continue;
}
get_short_name_string(commands[i].short_name, short_name); get_short_name_string(commands[i].short_name, short_name);
@ -614,6 +622,11 @@ 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;
}
configure_cli_commands(commands); configure_cli_commands(commands);
if (argc >= 3 && get_help_position(argc, argv) != -1) { if (argc >= 3 && get_help_position(argc, argv) != -1) {

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2021 Intel Corporation * Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -22,7 +23,8 @@ enum CLI_OPTION_FLAGS {
enum CLI_COMMAND_FLAGS { enum CLI_COMMAND_FLAGS {
CLI_SU_REQUIRED = 1 << 0, CLI_SU_REQUIRED = 1 << 0,
CLI_COMMAND_HIDDEN = 1 << 1 CLI_COMMAND_HIDDEN = 1 << 1,
CLI_COMMAND_BLOCKED = 1 << 2
}; };
#define ERROR -1 #define ERROR -1

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -2373,7 +2374,7 @@ static cli_command cas_commands[] = {
.options = standby_params_options, .options = standby_params_options,
.command_handle_opts = standby_handle_option, .command_handle_opts = standby_handle_option,
.handle = standby_handle, .handle = standby_handle,
.flags = CLI_SU_REQUIRED, .flags = (CLI_COMMAND_BLOCKED | CLI_SU_REQUIRED),
.help = standby_help, .help = standby_help,
}, },
{ {

View File

@ -1882,6 +1882,15 @@ int cache_mngt_create_cache_cfg(struct ocf_mngt_cache_config *cfg,
char cache_name[OCF_CACHE_NAME_SIZE]; char cache_name[OCF_CACHE_NAME_SIZE];
uint16_t cache_id; uint16_t cache_id;
switch (cmd->init_cache) {
case CACHE_INIT_STANDBY_NEW:
case CACHE_INIT_STANDBY_LOAD:
printk(KERN_ERR "Standby mode is not supported!\n");
return -ENOTSUP;
default:
break;
}
if (!cmd) if (!cmd)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
@ -2470,6 +2479,15 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
ocf_cache_mode_t cache_mode_meta; ocf_cache_mode_t cache_mode_meta;
ocf_cache_line_size_t cache_line_size_meta; ocf_cache_line_size_t cache_line_size_meta;
switch (cmd->init_cache) {
case CACHE_INIT_STANDBY_NEW:
case CACHE_INIT_STANDBY_LOAD:
printk(KERN_ERR "Standby mode is not supported!\n");
return -ENOTSUP;
default:
break;
}
if (!try_module_get(THIS_MODULE)) if (!try_module_get(THIS_MODULE))
return -KCAS_ERR_SYSTEM; return -KCAS_ERR_SYSTEM;

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -381,6 +382,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
case KCAS_IOCTL_STANDBY_DETACH: { case KCAS_IOCTL_STANDBY_DETACH: {
struct kcas_standby_detach *cmd_info; struct kcas_standby_detach *cmd_info;
return -ENOTSUP;
GET_CMD_INFO(cmd_info, arg); GET_CMD_INFO(cmd_info, arg);
retval = cache_mngt_standby_detach(cmd_info); retval = cache_mngt_standby_detach(cmd_info);
@ -391,6 +394,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
struct kcas_standby_activate *cmd_info; struct kcas_standby_activate *cmd_info;
struct ocf_mngt_cache_standby_activate_config cfg; struct ocf_mngt_cache_standby_activate_config cfg;
return -ENOTSUP;
GET_CMD_INFO(cmd_info, arg); GET_CMD_INFO(cmd_info, arg);
retval = cache_mngt_create_cache_standby_activate_cfg(&cfg, retval = cache_mngt_create_cache_standby_activate_cfg(&cfg,

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2020-2022 Intel Corporation # Copyright(c) 2020-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -23,7 +24,6 @@ casadm_help = [
r"-C --io-class Manage IO classes", r"-C --io-class Manage IO classes",
r"-V --version Print CAS version", r"-V --version Print CAS version",
r"-H --help Print help", r"-H --help Print help",
r"--standby Manage failover standby",
r"--zero-metadata Clear metadata from caching device", r"--zero-metadata Clear metadata from caching device",
r"For detailed help on the above commands use --help after the command\.", r"For detailed help on the above commands use --help after the command\.",
r"e\.g\.", r"e\.g\.",
@ -242,30 +242,7 @@ start_cache_help = [
] ]
standby_help = [ standby_help = [
r"Usage: casadm --standby \{--init|--load|--detach|--activate\}", r"The command is not supported"
r"Manage failover standby",
r"Initialize cache in standby mode:",
r"Usage: casadm --standby --init --cache-id \<ID\> --cache-line-size \<NUMBER\> "
r"--cache-device \<DEVICE\> \[option...\]",
r"Options that are valid with --init are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-x --cache-line-size \<NUMBER\> Set cache line size in kibibytes: \{4,8,16,32,64\}"
r"\[KiB\] \(default: 4\)",
r"-d --cache-device \<DEVICE\> Caching device to be used",
r"-f --force Force the initialization of cache instance",
r"Load cache in standby mode:",
r"Usage: casadm --standby --load --cache-device \<DEVICE\>",
r"Options that are valid with --load are:",
r"-d --cache-device \<DEVICE\> Caching device to be used",
r"Detach cache device in standby mode:",
r"Usage: casadm --standby --detach --cache-id \<ID\>",
r"Options that are valid with --detach are:",
r" -i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"Activate standby cache:",
r"Usage: casadm --standby --activate --cache-id \<ID\> --cache-device \<DEVICE\>",
r"Options that are valid with --activate are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-d --cache-device \<DEVICE\> Caching device to be used"
] ]
zero_metadata_help = [ zero_metadata_help = [

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2019-2022 Intel Corporation # Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -37,6 +38,7 @@ from api.cas.core import CoreStatus
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_standby_neg_cli_params(): def test_standby_neg_cli_params():
""" """
@ -106,6 +108,7 @@ def test_standby_neg_cli_params():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_activate_neg_cli_params(): def test_activate_neg_cli_params():
""" """
@ -186,6 +189,7 @@ def test_activate_neg_cli_params():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_standby_neg_cli_management(): def test_standby_neg_cli_management():
""" """
@ -262,6 +266,7 @@ def test_standby_neg_cli_management():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_start_neg_cli_flags(): def test_start_neg_cli_flags():
""" """
@ -316,6 +321,7 @@ def test_start_neg_cli_flags():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_activate_without_detach(): def test_activate_without_detach():
""" """
@ -379,6 +385,7 @@ def test_activate_without_detach():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("active_cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("active_cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("standby_cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("standby_cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
def test_activate_neg_cache_line_size(): def test_activate_neg_cache_line_size():
@ -470,6 +477,7 @@ def test_activate_neg_cache_line_size():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_standby_init_with_preexisting_metadata(): def test_standby_init_with_preexisting_metadata():
@ -528,6 +536,7 @@ def test_standby_init_with_preexisting_metadata():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
@pytest.mark.parametrizex("filesystem", Filesystem) @pytest.mark.parametrizex("filesystem", Filesystem)
@ -579,6 +588,7 @@ def test_standby_init_with_preexisting_filesystem(filesystem):
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("caches", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("caches", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("caches")) @pytest.mark.require_disk("core", DiskTypeLowerThan("caches"))
def test_standby_activate_with_corepool(): def test_standby_activate_with_corepool():
@ -637,6 +647,7 @@ def test_standby_activate_with_corepool():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.parametrizex("cache_line_size", CacheLineSize) @pytest.mark.parametrizex("cache_line_size", CacheLineSize)
def test_standby_start_stop(cache_line_size): def test_standby_start_stop(cache_line_size):

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2022 Intel Corporation # Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -42,6 +43,7 @@ mountpoint = "/tmp/drbd_functional_test"
test_file_path = f"{mountpoint}/test_file" test_file_path = f"{mountpoint}/test_file"
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("metadata_dev", DiskTypeSet([DiskType.nand])) @pytest.mark.require_disk("metadata_dev", DiskTypeSet([DiskType.nand]))
@pytest.mark.require_disk("core_dev", DiskTypeSet([DiskType.hdd])) @pytest.mark.require_disk("core_dev", DiskTypeSet([DiskType.hdd]))
@pytest.mark.require_disk("raid_dev1", DiskTypeSet([DiskType.optane])) @pytest.mark.require_disk("raid_dev1", DiskTypeSet([DiskType.optane]))
@ -226,6 +228,7 @@ def test_functional_activate_twice_round_trip(filesystem):
TestRun.LOGGER.end_group() TestRun.LOGGER.end_group()
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("metadata_dev", DiskTypeSet([DiskType.nand])) @pytest.mark.require_disk("metadata_dev", DiskTypeSet([DiskType.nand]))
@pytest.mark.require_disk("core_dev", DiskTypeSet([DiskType.hdd])) @pytest.mark.require_disk("core_dev", DiskTypeSet([DiskType.hdd]))
@pytest.mark.require_disk("raid_dev1", DiskTypeSet([DiskType.optane])) @pytest.mark.require_disk("raid_dev1", DiskTypeSet([DiskType.optane]))

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2019-2022 Intel Corporation # Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -28,6 +29,7 @@ offset = 1 # offset is expressed in the number of blocks
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_activate_corrupted(): def test_activate_corrupted():
@ -85,6 +87,7 @@ def test_activate_corrupted():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_load_corrupted(): def test_load_corrupted():

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2019-2022 Intel Corporation # Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -27,6 +28,7 @@ from api.cas.cli_messages import (
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
def test_activate_neg_cache_id(): def test_activate_neg_cache_id():
""" """
@ -98,6 +100,7 @@ def test_activate_neg_cache_id():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_activate_incomplete_cache(): def test_activate_incomplete_cache():
@ -215,6 +218,7 @@ def test_activate_incomplete_cache():
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_activate_neg_core_size(): def test_activate_neg_core_size():

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2022 Intel Corporation # Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -19,6 +20,7 @@ from test_utils.os_utils import sync
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
@pytest.mark.parametrizex("cache_line_size", CacheLineSize) @pytest.mark.parametrizex("cache_line_size", CacheLineSize)

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2022 Intel Corporation # Copyright(c) 2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -14,6 +15,7 @@ from api.cas.cache_config import CacheStatus
@pytest.mark.CI @pytest.mark.CI
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache")) @pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_standby_activate_the_same_cache_path(): def test_standby_activate_the_same_cache_path():

View File

@ -1,5 +1,6 @@
# #
# Copyright(c) 2019-2022 Intel Corporation # Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -385,6 +386,7 @@ def test_cas_startup_negative_missing_cache():
@pytest.mark.os_dependent @pytest.mark.os_dependent
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
@pytest.mark.require_disk("core", DiskTypeSet([DiskType.hdd])) @pytest.mark.require_disk("core", DiskTypeSet([DiskType.hdd]))
@pytest.mark.require_plugin("power_control") @pytest.mark.require_plugin("power_control")
@ -490,6 +492,7 @@ def test_failover_config_startup():
@pytest.mark.os_dependent @pytest.mark.os_dependent
@pytest.mark.skip(reason="Standby mode is not supported")
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
def test_failover_config_startup_negative(): def test_failover_config_startup_negative():
""" """