Merge pull request #1146 from arutk/stats2

Update casadm -P implementation for standby mode
This commit is contained in:
Robert Baldyga 2022-03-30 12:27:04 +02:00 committed by GitHub
commit 49c6dccb22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -632,12 +632,20 @@ static int cache_stats(int ctrl_fd, const struct kcas_cache_info *cache_info,
bool by_id_path) bool by_id_path)
{ {
struct kcas_get_stats cache_stats = {}; struct kcas_get_stats cache_stats = {};
bool standby;
cache_stats.cache_id = cache_id; cache_stats.cache_id = cache_id;
cache_stats.core_id = OCF_CORE_ID_INVALID; cache_stats.core_id = OCF_CORE_ID_INVALID;
cache_stats.part_id = OCF_IO_CLASS_INVALID; cache_stats.part_id = OCF_IO_CLASS_INVALID;
if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats) < 0) standby = !!(cache_info->info.state & (1 << ocf_cache_state_standby));
if (!standby) {
if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats)) {
print_err(cache_stats.ext_err_code);
return FAILURE; return FAILURE;
}
}
begin_record(outfile); begin_record(outfile);
@ -645,7 +653,7 @@ static int cache_stats(int ctrl_fd, const struct kcas_cache_info *cache_info,
cache_stats_conf(ctrl_fd, cache_info, cache_id, outfile, by_id_path); cache_stats_conf(ctrl_fd, cache_info, cache_id, outfile, by_id_path);
/* Don't print stats for a cache in standby state */ /* Don't print stats for a cache in standby state */
if (cache_info->info.state & (1 << ocf_cache_state_standby)) if (standby)
return SUCCESS; return SUCCESS;
if (stats_filters & STATS_FILTER_USAGE) if (stats_filters & STATS_FILTER_USAGE)
@ -770,6 +778,17 @@ int cache_status(unsigned int cache_id, unsigned int core_id, int io_class_id,
goto cleanup; goto cleanup;
} }
if ((cache_info.info.state & (1 << ocf_cache_state_standby)) &&
core_id != OCF_CORE_ID_INVALID) {
/* Explicitly fail due to standby mode rather than
* bouncing off the fact that there are 0 cores in the
* cache and saying "no such core device"
*/
print_err(OCF_ERR_CACHE_STANDBY);
ret = FAILURE;
goto cleanup;
}
/* Check if core exists in cache */ /* Check if core exists in cache */
if (core_id != OCF_CORE_ID_INVALID) { if (core_id != OCF_CORE_ID_INVALID) {
for (i = 0; i < cache_info.info.core_count; ++i) { for (i = 0; i < cache_info.info.core_count; ++i) {

2
ocf

@ -1 +1 @@
Subproject commit a64fc614136916b02c4e77f2a9fb125b84382651 Subproject commit ca8531a421b4a90cddb641dc377b4607b06a0775