Merge pull request #1603 from Deixx/attach-error-msg

Fix error messages for metadata found during attach
This commit is contained in:
Robert Baldyga 2025-02-25 16:01:12 +01:00 committed by GitHub
commit 690cebae65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 7 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -1025,6 +1025,22 @@ static int _start_cache(uint16_t cache_id, unsigned int cache_init,
cache_device); cache_device);
} else { } else {
print_err(cmd.ext_err_code); 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; return FAILURE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -151,9 +151,7 @@ struct {
}, },
{ {
OCF_ERR_METADATA_FOUND, OCF_ERR_METADATA_FOUND,
"Old metadata found on device.\nPlease load cache metadata using --load" "Old metadata found on device"
" option or use --force to\n discard on-disk metadata and"
" start fresh cache instance.\n"
}, },
{ {
OCF_ERR_SUPERBLOCK_MISMATCH, OCF_ERR_SUPERBLOCK_MISMATCH,

View File

@ -6,8 +6,8 @@
import re import re
from core.test_run import TestRun
from connection.utils.output import Output from connection.utils.output import Output
from core.test_run import TestRun
load_inactive_core_missing = [ load_inactive_core_missing = [
r"WARNING: Can not resolve path to core \d+ from cache \d+\. By-id path will be shown for that " 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 = [ start_cache_with_existing_metadata = [
r"Error inserting cache \d+", 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"Please load cache metadata using --load option or use --force to",
r" discard on-disk metadata and start fresh cache instance\.", 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 = [ start_cache_on_already_used_dev = [
r"Error inserting cache \d+", r"Error inserting cache \d+",
r"Cache device \'\/dev\/\S+\' is already used as cache\.", r"Cache device \'\/dev\/\S+\' is already used as cache\.",