From 69cdb458d2619123ffe00c4cd97fa7e9bb38f448 Mon Sep 17 00:00:00 2001 From: Daniel Madej Date: Mon, 24 Feb 2025 12:00:06 +0100 Subject: [PATCH 1/2] Error msg for metadata found during attach Signed-off-by: Daniel Madej --- casadm/cas_lib.c | 18 +++++++++++++++++- casadm/extended_err_msg.c | 6 ++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/casadm/cas_lib.c b/casadm/cas_lib.c index dbdb83a..9e0f201 100644 --- a/casadm/cas_lib.c +++ b/casadm/cas_lib.c @@ -1,6 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation -* Copyright(c) 2024 Huawei Technologies +* Copyright(c) 2024-2025 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -1025,6 +1025,22 @@ static int _start_cache(uint16_t cache_id, unsigned int cache_init, cache_device); } else { print_err(cmd.ext_err_code); + if (OCF_ERR_METADATA_FOUND == cmd.ext_err_code) { + /* print instructions specific for start/attach */ + if (start) { + cas_printf(LOG_ERR, + "Please load cache metadata using --load" + " option or use --force to\n discard on-disk" + " metadata and start fresh cache instance.\n" + ); + } else { + cas_printf(LOG_ERR, + "Please attach another device or use --force" + " to discard on-disk metadata\n" + " and attach this device to cache instance.\n" + ); + } + } } return FAILURE; } diff --git a/casadm/extended_err_msg.c b/casadm/extended_err_msg.c index 264e36e..94c3a0f 100644 --- a/casadm/extended_err_msg.c +++ b/casadm/extended_err_msg.c @@ -1,6 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation -* Copyright(c) 2024 Huawei Technologies +* Copyright(c) 2024-2025 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -151,9 +151,7 @@ struct { }, { OCF_ERR_METADATA_FOUND, - "Old metadata found on device.\nPlease load cache metadata using --load" - " option or use --force to\n discard on-disk metadata and" - " start fresh cache instance.\n" + "Old metadata found on device" }, { OCF_ERR_SUPERBLOCK_MISMATCH, From 37431273ea3ff602034c01f0109fcda104528151 Mon Sep 17 00:00:00 2001 From: Daniel Madej Date: Mon, 24 Feb 2025 12:00:06 +0100 Subject: [PATCH 2/2] Add error message in test api Signed-off-by: Daniel Madej --- test/functional/api/cas/cli_messages.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/functional/api/cas/cli_messages.py b/test/functional/api/cas/cli_messages.py index eb7e0de..248f9d3 100644 --- a/test/functional/api/cas/cli_messages.py +++ b/test/functional/api/cas/cli_messages.py @@ -6,8 +6,8 @@ import re -from core.test_run import TestRun from connection.utils.output import Output +from core.test_run import TestRun load_inactive_core_missing = [ r"WARNING: Can not resolve path to core \d+ from cache \d+\. By-id path will be shown for that " @@ -17,11 +17,18 @@ load_inactive_core_missing = [ start_cache_with_existing_metadata = [ r"Error inserting cache \d+", - r"Old metadata found on device\.", + r"Old metadata found on device", r"Please load cache metadata using --load option or use --force to", r" discard on-disk metadata and start fresh cache instance\.", ] +attach_cache_with_existing_metadata = [ + r"Error inserting cache \d+", + r"Old metadata found on device", + r"Please attach another device or use --force to discard on-disk metadata", + r" and attach this device to cache instance\.", +] + start_cache_on_already_used_dev = [ r"Error inserting cache \d+", r"Cache device \'\/dev\/\S+\' is already used as cache\.",